How to Run Selenium WebDriver Script in Chrome browser
Executing Selenium WebDriver Script in Chrome Browser:
Here in this post, we see how to run Selenium WebDriver Script in Chrome Browser. Moving forward, we need to have Chromedriver.exe and Selenium WebDriver.
Assuming that you have already Installed Selenium WebDriver.
If you want to install Selenium WebDriver, click on the link below to install Selenium WebDriver in few clicks.
How To Download And Install Selenium WebDriver
Each and every browser has its own Driver to execute Selenium WebDriver Scripts. Selenium WebDriver supports browsers such as Mozilla Firefox, Google Chrome, Internet Explorer, Opera, Safari etc.,
Here we are going to see how to run Selenium WebDriver Script in Chrome Browser.
What is ChromeDriver and What it does?
ChromeDriver is a separate executable that WebDriver uses to control Chrome. This executable starts a server on local system to run the Selenium WebDriver Test Scripts.
Also find,
Steps to run Selenium WebDriver Script in Chrome Browser
Step 1: Download ChormeDriver.exe
Click here to download Chrome driver
Download the latest release of Chrome driver which is compatible to your test environment. Unzip the downloaded compressed file and keep it somewhere on a known location on your system.
Step 2: Executing the Test Script in Chrome Browser
Find the sample script (using Java) mentioned below to run test script in Chrome browser. Execute it to run the test in Chrome browser which will first open chrome browser and then open the appropriate URL mentioned in the script
Quick note:
To launch Chrome Browser, we have to do as mentioned below:
1. Set a system property “webdriver.chrome.driver” to the path of executable file “Chromedriver.exe“. If you miss this, you will face an error “The path to the driver executable must be set by the webdriver.chrome.driver system property“.
2. Instantiate a ChromeDriver class
package seleniumTutorial; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class ChormeBrowserScript { public static void main(String [] args) throws InterruptedException{ //System.setProperty("webdriver.chrome.driver",path of executable file "Chromedriver.exe") System.setProperty("webdriver.chrome.driver", "D:/SeleniumEnvironment/chromedriver_win32/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://www.softwaretestingmaterial.com/software-testing-interview-questions-free-ebook/"); System.out.println("Selenium Webdriver Script in Chrome browser | Software Testing Material"); driver.close(); } }
Hi
For selenium3.6, how will i execute script using gecko driver on chrome and IE?
I’ve used for gecko driver for Firefox and successfully running on FF browser but coming to IE and Chrome i couldn’t able to execute using geckodriver.
If possible can you please share the code for to execute code in IE and Chrome browser.
Regards
Shilpa
Hi Shilpa, Gecko driver is to run firefox..
Check this link to run your code on Chrome
Check this link to run on IE
Check this link – Selenium Complete Tutorial
Thank You Raj Kumar for quick reply
Welcome Shilpa.