Steps To Write Any WebDriver Script

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


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


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


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


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


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.


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


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.


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


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” .


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


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.


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


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


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

Add Comment