How to Run Selenium WebDriver 2.0 Script with Firefox Browser

0
172
Firefox browser

 

We will start our first Selenium Script with Firefox browser using Selenium 2.0 version.By default, Selenium 2.0 supports Firefox browser meaning Firefox is the native browser of Selenium 2.0 version which comes with the Server standalone file. No need to call the respective Firefox server to execute the scripts, like we do for IE and Chrome Browser.

Program on Firefox browser using Selenium 2.0 version :

 

Explanation of Above Code :

Line 1 :  Import org.openqa.selenium.WebDriver – To invoke any new browser we need to have an reference from the WebDriver Interface.Using those references we can instantiate the new browser.

Line 2 : Import org.openqa.selenium.firefox.FirefoxDriver –Will Create an object of the firefoxDriver class and is assigned to WebDriver interface.

Line 7 : WebDriver interface is creating the reference driver and assigning it to newly opened Firefox browser.

WebDriver driver = new FirefoxDriver() ;

Line 8 : Launching the url as given within the quotes http://www.google.com

Line 10 : Will quit the newly opened browser in line 7.

LEAVE A REPLY

Please enter your comment!
Please enter your name here