File size: 819 Bytes
6b88f68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options

# 1. Path to the Browser
firefox_path = "/usr/lib/firefox/firefox" 

# 2. Path to the Driver (CHANGE THIS LINE)
# We moved it to 'local/bin', so we must tell Python that!
driver_path = "/usr/local/bin/geckodriver"

service = Service(executable_path=driver_path)
options = Options()
options.binary_location = firefox_path

try:
    print(f"Launching Browser: {firefox_path}")
    print(f"Using Driver:    {driver_path}")

    driver = webdriver.Firefox(service=service, options=options)
    
    driver.get("https://google.com")
    print("\nSUCCESS: It works!")
    print("Page Title:", driver.title)
    driver.quit()

except Exception as e:
    print("\nERROR:")
    print(e)