How to execute Selenium Webdriver in Chrome Browser

Hello Welcome to Selenium Tutorial, today we will discuss Launch Chrome Browser using Selenium Webdriver.

Selenium Webdriver by default support firefox browser only that is the reason we did not face any issue while working with Firefox.In order to execute your script in the different browser like chrome, IE etc.

If you are working with IE browser then you should know the challenges as well which you will face while working with IE browser. This is one of the most important question in interviews as well.
We have to download separate drivers and we have to specify the path as well with the location of the driver.
Note- Selenium Webdriver supports chrome latest version.

 

 

You can refer complete YouTube video

 

 

Step 1: Download Chrome Drive

Open any browser and open http://www.seleniumhq.org/download/
Here you will get third party driver section and you can get all the external driver for different browsers.
Click on 2.22 link
Note- Latest chrome version is 2.22 so you will get the latest version

Launch Chrome Browser using Selenium Webdriver

 

Here you will get the driver zip file which you can extract, after extraction, you will get chromedrive.exe file

 

Note- Selenium provides only 32 bit but you can use the same for 64-bit machines as well. Practically I tried and it works fine

Launch Chrome Browser using Selenium Webdriver

 

Program for Run Selenium Webdriver in chrome Browser

 

Output:-

Launch Chrome Browser using Selenium Webdriver

Script in ChromeBrowser

Your test case will fail and you will get IllegalStateException which says we need to specify the chrome driver path where it resides.

If you notice Selenium also gives a very meaningful message that we need to add some chrome variable also while running the script.

Variable name is – webdriver.chrome.driver

In Java to set variable we use setProperty method of System class so let us add the same in our program

Sample Program for Launch Chrome Browser using Selenium Webdriver

 

Thanks for visiting my blog. Keep reading. Have a nice day 🙂

 

29 Comments

  1. Nitin
  2. thejaswini
  3. sharath
  4. naresh
  5. Div_QueenBee (@bug_huntress)
  6. Rahul
      • Dilshad Randhawa
      • Swetha
  7. Mitali Singh
  8. sara
  9. Aarohi
  10. Manjunath
  11. Gajendra
  12. Gajendra

Leave a Reply