Forums

init() got an unexpected keyword argument 'options'

New to PythonAnywhere and trying to open and run Selenium but am experiencing the error: init() got an unexpected keyword argument 'options' when trying to run the below code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://placeholder.myshopify.com/admin/reports/sales_over_time?since=-1m&until=-1m&over=month")
username = driver.find_element_by_name("account[email]")
username.send_keys("emailaddress")
username.send_keys(Keys.ENTER)
password = driver.find_element_by_name("account[password]")
password.send_keys("password")
password.send_keys(Keys.RETURN)
sales = driver.find_elements_by_xpath("//div[@class='_1FKPr _2j7wJ']")
print(sales)
driver.exit()

I'm on the glastonbury system image.

Are you using our default Selenium and Chrome driver? It looks like an old version error.