Jump to content

Selenium: Difference between revisions

no edit summary
m (Protected "Selenium" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite) [Delete=Allow only administrators] (indefinite)))
No edit summary
Line 3:
<br />
 
Install Selenium
pip3 install selenium
 
Install Firefox:
sudo apt install firefox
 
Install geckodriver:
Download latest geckodriver from [https://github.com/mozilla/geckodriver/releases github.com]
wget https://github.com/mozilla/geckodriver/releases/download/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz
tar -xf geckodriver-v0.29.0-linux64.tar.gz
cp geckodriver /usr/local/bin/
 
 
<syntaxhighlight lang="python">
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
import json
 
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
 
options = Options()
options.binary_location = r"/usr/bin/firefox"
options.add_argument("--headless")
 
browser = webdriver.Firefox(options=options, firefox_profile=profile, executable_path="/home/ubuntu/geckodriver")
browser.get('https://testsite.com/')
 
driver.close()
</syntaxhighlight>
 
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.