To work with any browser, we need the executable
driver for specific browsers. Here, I will explain about 3 major browsers &
their executable driver that we are using in Windows environment.
1
|
Mozilla Firefox
|
Geckodriver.exe
|
System.setProperty(“webdriver.gecko.driver”,”/path/to/geckodriver.exe”)
|
2
|
Chrome
|
Chromedriver.exe
|
System.setProperty(“webdriver.chrome.driver”,”/path/to/chromedriver.exe”)
|
3
|
IE
|
IEDriverServer.exe
|
System.setProperty(“webdriver.ie.driver”,”/path/to/
IEDriverServer exe”)
|
In the above table I have added the Browser Name,
Executable Driver & How to set the driver in selenium. Click here
to download the executable drivers. Extract the .zip file & place in your
workspace.
So,
our drivers are now ready, let’s start our 1st selenium script to
open firefox browser & navigate to any URL.
To
do that, Open eclipse > Right click on Project’s src > New > Class > Insert the class name > Select the
check box public static void main(String[] args) > Click on Finish
This
will create a default package & inside that there will be a class with main
method.
In
the above class, write the below code to open firefox browser & navigate to
URL.
System.setProperty("webdriver.gecko.driver","path/to/geckodriver.exe");
WebDriver
driver = new FirefoxDriver();
driver.get("
http://the-automation-testing.blogspot.in/");
System.out.println(driver.getTitle());
Code Overview:
- In the 1st line, we have set the path of browser driver.
- In 2nd line, we have created the instance of Firefox driver.
- In 3rd line, we are navigating to the site URL.
- In 4th line, we are printing the title of the web page.
Similarly,
to open application in chrome or IE we need to set the path of browser driver
& need to create instance for specific driver as below:
For
chrome:
System.setProperty("webdriver.chrome.driver","path/to/chromedriver.exe");
WebDriver driver = new ChromeDriver();
For
IE:
System.setProperty("webdriver.ie.driver","path/to/IEServerDriver.exe");
WebDriver driver = new InternetExplorerDriver ();
NOTE
: After creating the object for any browser, we need to import the driver class
from org.openqa.selenium
Very nice post & good information.
ReplyDeleteBest Selenium Training Institute in Bangalore | Software Testing Training in Bangalore | Selenium Training in Bangalore
i would like to share best automation services near you
ReplyDeletevisit-https://www.dynamisers.com/automation-testing/
Interesting syntax & useful tips for the QA analysts.
ReplyDeleteLooking for the Automation Testing Company to improve you business efficiency, Reach Way2Smile.
Good information... Many companies and businesses planning to use automation testing their business to make their business productive.
ReplyDeleteBest Regards - Vigneshwaran P ( Android App Development Services)
Thanks for sharing this insightful article.Keep sharing such technical information articles.
ReplyDeleteTop Mobile App Developers
Best Android App Development Company
This blog is great source of information which is very useful for me. Thank you very much for sharing this!
ReplyDeleteCRM Development Companies in Chennai
Top CRM Development Companies in Chennai
CRM Developers in Chennai
software development company in chennai
Top mobile app development companies in Chennai
app developers in chennai
Thanks for providing this greatest information. It was very inspired by us. thank you so much.
ReplyDeletebulk sms service provider in chennai
chennai bulk sms
best bulk sms service provider in chennai
bulksms in chennai
bulk sms service in chennai