Search code examples
djangopython-3.xseleniumoperaoperadriver

Selenium with Python- Message: 'operadriver' executable needs to be in PATH


Checking whether a website loads in opera using selenium with python, using the code below:

def test_opera_compatability(self):
    driver = webdriver.Opera("functional_tests/operadriver")
    driver.get("https://www.google.com/")
    driver.quit()

It returns the following error:

Message: 'operadriver' executable needs to be in PATH.

Similar code for chrome works as intended, which looks like this:

def test_chrome_compatability(self):
    driver = webdriver.Chrome('functional_tests/chromedriver')
    driver.get("https://www.google.com/")
    driver.quit()

Solution

  • You can use the Key executable_path to pass the absolute path of the operadriver binary as follows:

    def test_opera_compatability(self):
        driver = webdriver.Opera(executable_path='/path/to/functional_tests/operadriver')
        driver.get("https://www.google.com/")
        driver.quit()