Basic Selenium WebDriver Script in NetBeans using Chrome Browser

Follow the following steps to run our first Selenium WebDriver Automation Tool program. In this article we are using NetBeans to run our scripts. You can check Selenium WebDriver Tutorial with Eclipse also.

Selenium WebDriver Script in NetBeans using Chrome

Test Scenario: In Selenium WebDriver Automation Tool get website’s title name in NetBeans using Chrome Browser

Step 1: Open NetBeans
Step 2: Go to File -> New Project -> Java -> Java Application

Selenium WebDriver Automation Tool

Selenium WebDriver Automation Tool

Step 3: Give Project Name and click on Finish button.

Selenium WebDriver Automation Tool

Step 4: Then we have to add Selenium’s Jar files to run our scripts. Download Selenium’s Jar files

Step 5: To add downloaded jar file, Go to Projects tab -> Right click on Libraries options and select Add JAR/ Folder

Selenium WebDriver Automation Tool

Step 6: Add downloaded Selenium’s Jar file
Selenium WebDriver Automation Tool

Step 7: After adding JAR file, It will be displayed in Libraries.

Selenium WebDriver Automation Tool

Step 8: Type following code in class

Test Scenario: In Selenium WebDriver Automation Tool get website’s title name in NetBeans with Chrome Browser.

package javaapplication1;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class JavaApplication1

{

public static void main(String[] args)

{

System.setProperty("webdriver.chrome.driver", "C:\\Users\\SURAJ\\Downloads\\chromedriver_win32\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.navigate().to("http://softwaretestingbooks.com/");

String appTitle = driver.getTitle();

System.out.println("Application title is : "+appTitle);

driver.quit();

}

}

—> Output:

When you are using NetBeans along with Chrome browser. Following code are compulsory to write.

You required chromedriver –> Download & type its downloaded path in System.setProperty method.

System.setProperty(“webdriver.chrome.driver”,”C:\\Users\\SURAJ\\Downloads\\chromedriver_win32\\chromedriver.exe”);

Selenium WebDriver Script in NetBeans using Chrome


Also Check:

Leave a Reply

Your email address will not be published. Required fields are marked *