Running your first
Selenium Webdriver script with TestNG
You can use any IDE for developing your
Install the below
1. JDK
2. Selenium Webdriver: Download it from here: http://seleniumhq.org/download
3. TestNG : Download TestNG from http://testng.org/doc/download.html. Unzip. The files will get extracted to a folder called
testng .
4. Eclipse : Download eclipse from http://www.eclipse.org/downloads/.Choose the "Eclipse IDE for Java Developers". Unzip
the downloaded file. The files will get extracted to a folder called 'eclipse'.
5.TestNG plug-in for Eclipse: Start Eclipse by clicking the eclipse icon in
the eclipse folder that's mentioned earlier. Click on Help->Install New
Softwares. Enter "http://beust.com/eclipse/" in the "Work
With:" and press Enter. You should see TestNG. Select it and then press
Next till you reach Finish. Restart Eclipse.
Good that we have finished installing everything that we needed to start with selenium and TestNG. You could always work with selenium andtestng without
eclipse in which case you wont have to install Eclipse and the TestNG plug-in
required for eclipse. But its better to have an IDE (like Eclipse or anyother )
so that its far easier to write the scripts.
Let's start with the Selenium Webdriver andTestNG script now:
1. Open eclipse. Start by creating a new project : File->New->Java
Project. Give a name say 'Automation'.
4. Eclipse
5.
Good that we have finished installing everything that we needed to start with selenium and TestNG. You could always work with selenium and
Let's start with the Selenium Webdriver and
1. Open eclipse. Start by creating a new project
2. Add the required jars. Select the project-’Automation’, Right click Build Path->Configure Build Path. Click Libraries->Add External Jars. You will have to add the
3. Create a new package in the project. Select the project -'Automation' and then right click New->Package. Give a name say 'First'.
4. Create a new
5. Copy paste the whole below code into eclipse( GoogleTC).
@Test
driver.get("http://www.google.com"); // open google.com
Thread. sleep( 2000); // This statement is used to wait for 2 seconds
Thread. sleep( 5000);
Thread. sleep( 2000);
}
}
6. Make changes so that your testng script looks like below:
Great!!!!! Your first
This is
7. Now run the
Your script should run successfully.