If we planning to perform automation
testing in any web application then is there any priority our web site smoothly
work with Chrome browser then we need to make a script that is computability with
chrome browser. Normally to run web driver, we just need a browser and a
selenium server jar file.
Selenium by-default support Firefox browser. Then the next question is arise. How to run web driver API in other browsers.
Selenium by-default support Firefox browser. Then the next question is arise. How to run web driver API in other browsers.
Selenium web driver API supports to
run web driver in other browsers by just adding an chrome .exe path.
Now to run selenium web driver API
in Chrome browser, we need to download Chrome Driver.
First of all, download latest
version of ChromeDriver go to http://docs.seleniumhq.org/download/
and go “Third Party Browser Drivers NOT
DEVELOPED by seleniumhq” section and download the Chrome driver.
In selenium web driver script code
you need to set the system property for chrome driver as
System.setProperty("web driver API. chrome. driver", "pathofchromedriver\\chromedriver.exe");
System.setProperty("web driver API. chrome. driver", "pathofchromedriver\\chromedriver.exe");
Please find the below example
program using java and give the Chrome driver path. After writing the below
code, execute it to run your test in chrome browser
import
org.openqa.selenium.Web driver API;
import
org.openqa.selenium.chrome.ChromeDriver;
public
class chromebrowsertest {
public static void main(String args[])
{
System.setProperty("web driver API.chrome.driver",
"E://chromedriver.exe");
Webdriver chromedriver=new ChromeDriver();
chromedriver.get("http://silenumnmisc.blogspot.com");
}
}
No comments:
Post a Comment