Running Selenium WebDriver python bindings in chrome.

SeleniumAutomation TestingTesting Tools

We can run Selenium webdriver with Python bindings in Chrome. This can be done by downloading the chromedriver.exe file. Visit the link: https://chromedriver.chromium.org/downloads. There shall be links available for download for various chromedriver versions.

Select the version which is compatible with the Chrome browser in the local system. Click on it. As the following page is navigated, select the zip file available for download for the operating system which is compatible with our local operating system.

Once the zip file is downloaded, extract it and save the chromodriver.exe file at a location. To launch the Chrome, we have to add the statement from selenium import webdriver. Also, we must have a webdriver object created.

With the help of this webdriver object we should be able to access the webdriver.Chrome(). The location of the chromedriver.exe is passed as a parameter to the Chrome class with the help of the property called the executable_path.

Example

from selenium import webdriver
#path of chromedriver.exe
driver = webdriver.Chrome (executable_path="C:\\chromedriver.exe")
#launch browser
driver.get ("https://www.tutorialspoint.com/index.htm")
#close browser
driver.close()
raja
Published on 30-Jan-2021 12:53:29
Advertisements