If we would like to run our scripts on Chrome we need "chromedriver"along with the actual Chrome Browser.If you try to start the Chrome Browser with the below statement alone
WebDriver driver = new ChromeDriver();
Then you will notice below error statements
"You need to have both chromedriver and a version of chrome browser installed
@BeforeTest setUpDriver
java.lang.IllegalStateException: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromedriver/downloads/list
at com.google.common.base.Preconditions.checkState(Preconditions.java:172)
atorg.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:114)"
In our scripts if we dont specify where is chromedriver is located then we cant start chrome browser using WebDriver.
Here are steps to setup chromedriver
1.Download chromedriver from
http://code.google.com/p/chromedriver/downloads/list
2.Unzip the file .Say you downloaded it on your desktop folder named "Automation" and unzipped it then location will be like
C:\\Users\\<<User Name>>\\Desktop\\Automation\chromedriver_win_19.0.1068.0\\chromedriver.exe
3.Use the below code to start chrome
System.setProperty("webdriver.chrome.driver","C:\\Users\\<<UserName>>\\Desktop\\Automation\\chromedriver_win_19.0.1068.0\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
Now you are done. :)
If you are using the TestNG framework then here is the sample code :
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; public class chromeDriver { WebDriver driver; @BeforeTest public void setUpDriver(){ System.setProperty("webdriver.chrome.driver", "C:\\Users\\<>\\Desktop\\Automation\\chromedriver_win_19.0.1068.0\\chromedriver.exe"); driver = new ChromeDriver(); } @Test public void start(){ driver.get("http://www.google.com/"); } }
This is the great job for providing the nice opportunity in this blog. I had really like this information and adding two things in this technology.
ReplyDeleteThis was GREAT! THANKS!! Everth was clear and perfectly answered my problem! )) // Alex A.
ReplyDeleteExcellent, whะฐt a weblog it is! This weblog provides useful facts to us, keep it up.
ReplyDeleteAlso visit my web-site : tickets online
I do ัonsider ะฐll of the ัoncepts yฮฟu've introduced on your post. They are very convincing and can definitely work. Nonetheless, the posts are too short for novices. Could you please lengthen them a little from subsequent time? Thank you for the post.
ReplyDeleteFeel free to surf my homepage Calling Cards
chrome web driver is working. but when click on the any menu links in web page, brothersoft tool bar is installed. brothersoft header is displayed in the chrome wed driver browser, same code is working in FF and IE.
ReplyDeleteWebDriver will always open the browser in incognito window.This is not something to do with WebDriver.
ReplyDeleteI tried playing on google site and it worked fine.
Can you try on other website ?