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

789 Views Asked by At

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()
1

There are 1 best solutions below

5
On BEST ANSWER

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()