0

I used to have a selenium script code in Python for a firefox website that worked fine.After a while I updated Firefox (48) and selenium 2.9.1.1, python is 3.5.0

the code,

    # -*- coding: utf-8 -*-
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support.ui import Select
    from selenium.common.exceptions import NoSuchElementException
    from selenium.common.exceptions import NoAlertPresentException
    import unittest, time, re, os

    class Jqueryx(unittest.TestCase):
        def setUp(self):
            self.driver = webdriver.Firefox()
            self.driver.implicitly_wait(30)
            self.base_url = "http://127.0.0.1:8080/"
            self.verificationErrors = []
            self.accept_next_alert = True
            self.path_upload_quest = r'C:\\Users\jl\Documents\DONNEES\DONNEES_LIMONDE'
            self.path_upload_ref = r'C:\\Users\jl\Documents\DONNEES\DONNEES_LIMONDE\ref'

        def test_jqueryx(self):

            driver = self.driver
            driver.get(self.base_url + "/lim/home.php")

If I run the script now i ve got this message:

os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' >executable needs to be in PATH.

So I download this geckodriver thing and try to add it to the python but nothing works yet,

I try to add this in the script;

os.environ["PATH"] += r'C:\Users\jl\geckodriver'

without success or adding a .pth file in the site-package folder but no change too...

What can I do to get this script back on track ?

thx

krifur
  • 870
  • 4
  • 16
  • 36
  • 1
    This might be an issue with how you are modifying `PATH`. You need to include a path separator before appending the geckodriver path: `os.environ["PATH"] += os.pathsep + r'C:\Users\jl\geckodriver'` – elethan Sep 23 '16 at 15:11
  • 1
    There are on-going issues between Selenium and any Firefox version after (and including) 47. You might be best served by downgrading to 46 until the issues are worked out. – Levi Noecker Sep 23 '16 at 18:40
  • thx no luck with changin the way to include the path, however it looks like it s definitely the source of the problem.I will have to upgrade firefox anyway so I rather looking forward this problem and how to fix it. – krifur Sep 26 '16 at 15:07

2 Answers2

0

Copy the GeckoDriver to the folder where you have your code, and then change the following in your code

self.driver = webdriver.Firefox("path/to/your/current/folder")

This should work fine

noob_coder
  • 72
  • 3
  • 6
0

you can do one of the following:

first method: place the driver in the PATH environment variable and than run the script

second method (Add to path during the test): add the driver during the test by running

os.environ["PATH"] += r'/path/to/dir/where/your/driver/is'

in your case:

os.environ["PATH"] += r'C:\Users\jl'

this code must be executed before calling browser = webdriver.Firefox()

third method (full path to driver):

browser = webdriver.Firefox(executable_path=r'/full/path/to/driver')

in your case:

browser = webdriver.Firefox(executable_path=r'C:\Users\jl\geckodriver')
yogev
  • 189
  • 5