Drive Opera with selenium python

前端 未结 3 1344
深忆病人
深忆病人 2020-12-10 09:31

I added to my environment variable

SELENIUM_SERVER_JAR = C:\\selenium_drivers\\selenium-server-standalone.jar

Which I downloaded here http

3条回答
  •  长情又很酷
    2020-12-10 10:22

    Based on your question it looks like you are using an old driver for Opera version 12 and older. Assuming that you're trying to use the most recent version of Opera you'll want to use the driver available at the following site: OperaChromiumDriver

    The site lists sample python code which I have confirmed works on my machine to open and drive Opera: Python Examples for OperaChromiumDriver

    import time
    
    from selenium import webdriver
    from selenium.webdriver.chrome import service
    
    
    webdriver_service = service.Service('C:\\Users\\Kris\\Downloads\\WinPython-32bit-2.7.9.2\\operadriver.exe')
    webdriver_service.start()
    
    driver = webdriver.Remote(webdriver_service.service_url, webdriver.DesiredCapabilities.OPERA)
    
    driver.get('https://www.google.com/')
    input_txt = driver.find_element_by_name('q')
    input_txt.send_keys('operadriver\n')
    
    time.sleep(5) #see the result
    driver.quit()
    

    EDIT: Looking into the change logs for selenium it looks like support for Presto-based Operas was discontinued after 2.45 which is why you're getting the error messages:CHANGELOG

提交回复
热议问题