chrome webdriver selenium code example
Example 1: chromedriver selenium python
# For Linux, but it is similar for Windows
# First make sure first that you have chrome browser installed on your system.
# a simple way to get the driver is:
sudo apt-get install chromium-chromedriver
# this will download 75MB of files.
# another way is:
1. Download the lastest version of driver from:
https://sites.google.com/a/chromium.org/chromedriver/ # only 5-7MB
2. Unzip the file.
3. Paste the file in /usr/local/bin using this command:
sudo mv chromedriver /usr/local/bin # this makes sure that the directory is in your PATH variable.
4. Make your file executable:
sudo chmod +x /usr/local/bin/chromedriver
Now you can use this in python:
>>from selenium import webdriver
>>browser = webdriver.Chrome()
# it will work fine
Example 2: selenium webdriver python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
Example 3: selenium chromedriver
Supports Chrome version 89
Resolved issue 3667: Timed out receiving a message from rendererResolved issue 3675: GetElementLocation uses inView method which mishandles boolean as arrayResolved issue 3682: GetElementRegion returns incorrect size for elements which are partially out of viewportResolved issue 3690: ChromeDriver fails if extensions use chrome.windows API
Example 4: chrome webdriver download
Supports Chrome version 88
Resolved issue 3611: getText() output in protractor different from .innerTextResolved issue 3625: Improve element screenshot compatibilityResolved issue 3628: Stale Element Reference and wrong URL reported back with URL having another URL as part of its pathResolved issue 3631: Add support for the `webauthn:extension:largeBlob` capabilityResolved issue 3635: Chromedriver 86 - chromedriver .quit() doesn't seem to pass unload event properlyResolved issue 3649: Copying selected text to clipboard does not work on Windows 10 when using headless modeFor more details, please see the release notes.