selenium chrome webdriver code example
Example 1: chromedriver selenium python
sudo apt-get install chromium-chromedriver
1. Download the lastest version of driver from:
https://sites.google.com/a/chromium.org/chromedriver/
2. Unzip the file.
3. Paste the file in /usr/local/bin using this command:
sudo mv chromedriver /usr/local/bin
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()
Example 2: selenium set chrome executable path
chromedriver = "/path/to/chromedriver"
options = Options()
options.binary_location = '/path/to/chrome'
driver = webdriver.Chrome(chromedriver, chrome_options=options)
Example 3: 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 4: chromedriver = webdriver.Chrome(“D:\driver\chromedriver.exe”)
driver = webdriver.Chrome(executable_path=r'DRIVER_PATH')
Example 5: selenium chrome python
import timefrom selenium import webdriverdriver = webdriver.Chrome('/path/to/chromedriver')
Example 6: chromedriver = webdriver.Chrome(“D:\driver\chromedriver.exe”)
"chromedriver = webdriver.Chrome(“D:\driver\chromedriver.exe”)" doesnt work for me
so i found out if i use "driver = webdriver.Chrome(executable_path=r'DRIVER_PATH')"
it works