Submitted by Gener Joseph Tomas
To start working and install selenium and its pre-requisite packages do the following,
sudo apt-get update
sudo apt install chromium-browser -y
sudo apt install chromium-chromedriver
pip install selenium
To test the installed selenium do the following,
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
options.add_argument("--remote-debugging-port=9222")
options.headless = True
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver", desired_capabilities=options.to_capabilities()) # Optional argument, if not specified will search path.
driver.get('http://www.google.com/');
search_box = driver.find_element_by_name('q')
search_box.send_keys('Domino Data Lab')
search_box.submit()
driver.save_screenshot('headless_chrome_test.png')
driver.quit()
The chromium-chromedriver version is very dependent on the chromium-browser version, so if you aren’t installing them at the same time, then be careful of that.
options.headless = True is required or it will error.
Comments
0 comments
Please sign in to leave a comment.