Steps To Write Any WebDriver Script

1. Launch Eclipse IDE and go to File Menu -> New -> Java project and create a project named “TestClass”.

r1

2 . Inside this Project, create a new package named “home”.

r3

3 . Under this package “home”, create a new class “test1”.

r4

4 . In the code editor which is provided at the right side, there under the class test1, create a method “testclass()”.

r5

5 . Add an annotation “@Test” above the method name testClass(). Once you add this annotation you will get an error.

r6

6 . In order to solve this error you need to hover mouse over the @Test annotation and click on the option “Import ‘Test'(org.junit)” link.

s1

7 . Once we resolve the above error, “import org.junit.Test” will be added to your code.

s2

8 . In Selenium WebDriver, we  need to specify the web browser on which you want to run your test script. So on whatever browser you want to run your test script you can specify in your script.

s3

9 . To resolve the above error first you need to hover the mouse over the WebDriver and “import org.openqa.selenium.WebDriver” .

b

10 . Then to resolve the second the error you need to hover the mouse over FirefoxDriver and select the option “import org.openqa.selenium.WebDriver.firefox” .

b1

11. Once you resolve the above errors, you will be able to see some import statements.

b2

12 .  All the errors are resolved now, so we can add some more piece of code. Suppose you want to add a webPage URL.

You just need to type “driver.get”, a box will get opened there. You just need to chose the option.

b3

13 . You need to select the first option and then replace arg(0) with your URL “http://seleniumtutorialpoint.com/”.

b4

14 . Now save the selenium WebDriver test script and run it.

b5

15 . Once you run it, it will direct you to the site, the one you have mentioned in the URL.

Add Comment