This is most awaited article for you, currently in there are lots of opening in market on selenium webdriver so this article very useful to initiate in automation.
How to write script in selenium WebDriver
I will describe each and every thing in brief regarding what is WebElement? Where we can search WebElement? And so on…
At first selenium doesn’t recognise controls as it is like, dropdown as dropdown, text box and text box, in simple way, selenium don’t know list box, drop down, textbox, button and so on
This is very simple!! Let me describe in simple way how to write script in selenium
Selenium considering as WebElement for each and every control like selenium consider to text box as WebElement, considering button also is an WebElement.
In simple word, selenium webdriver treating to all controls as WebElement.
WebDriver is a tool for automating web application testing, and in particular to verify that they work as expected
Now, giving you to idea how to write script in selenium webdriver
Before start writing a script, you need to create new project in the eclipse.
Just open Eclipse and create new project and specify the any appropriate name to the project like “seleniumfirst”
Under that new project, you have to create new package with any appropriate name to understand easily as per company standard process like “Selenium programmes”
Create new class with appropriate name with standard rule under same package like “Openbrowser”
Now, actual turns to start scripting in eclipse
At first, you need to open the Firefox browser using selenium Webdriver, for that see the below the script.
WebDriver driver = new FirefoxDriver ();
Remember that all letters are case sensitive, script will get fail if you are not following letter case sensitive, like WebDriver (W and D in Uppercase and other in lowercase)
Now move to eclipse and write a script in practical way
Press Ctrl+Shift+O to import the file which are highlighted in shape
After writing the script in selenium, press Ctrl+Fun+F11 key if you working in laptop
Or just press F11 key to compile the script in selenium webdriver.
See your script is compiled and browser is opened successfully.
Greetings !!! now you feel you are automation engineer and able to write automation script.
Now, you can pass the any URL in the browser by using selenium script.
In the selenium, they provided only one method to perform one action like they provided “get” method to access the URL
Let’s move to selenium webdriver and write a script
Press Ctrl+ S to save the script in the selenium. This how to write script in selenium webdriver.
Press Ctrl + Fun + F11 key
See your script is compiled and browser is opened successfully and Google is opened in the Firefox browser.
In the next article on testingnotes i will describe how to launch chrome browser with same script, also I am trying to provide more and more information in details, so you can get more confidence in the automation script.
Thank you for reading my article !