MoKhajavi75
MoKhajavi75

Reputation: 2712

Selenium not working in Python

I have problem with Selenium! I tried both 3.6 and 2.7 but no difference! I'm using win7 (64bit)

let's start with a simple code:

binary = FirefoxBinary(r"C:\Program Files\Mozilla Firefox\firefox.exe")
fp = webdriver.FirefoxProfile()
driver = webdriver.Firefox(firefox_binary=binary, firefox_profile=fp)

And so, i get these errors:

C:\Python27\python.exe E:/Python/MathBattle_Solver/test.py

Traceback (most recent call last): File "E:/Python/MathBattle_Solver/test.py", line 13, in download("https://www.google.com")

File "E:/Python/MathBattle_Solver/test.py", line 9, in download browser = webdriver.Firefox(capabilities=firefox_capabilities, executable_path=r'C:\Windows\System32\geckodriver.exe')

File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in init self.service.start()

File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'geckodriver.exe' executable needs to be in PATH.

I downloaded the "geckodriver.exe", put it into the system32 folder and added into PATH system variable from the environment variables but nothing happened! still the same error!

Any idea?

Upvotes: 3

Views: 2432

Answers (2)

GHULAM NABI
GHULAM NABI

Reputation: 496

Selenium requires a driver to interface with the chosen browser. Firefox, for example, requires geckodriver, which needs to be installed before the below examples can be run. Make sure it’s in your PATH, e. g., place it in /usr/bin or /usr/local/bin.

Failure to observe this step will give you an error selenium.common.exceptions.WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH

Put geckodriver.exe in the script folder and then call webdriver.Firefox with

Upvotes: 1

fedterzi
fedterzi

Reputation: 1164

It works for me on 52.0.2 (64bit) and Geckodriver 0.15.0-win64 (from https://github.com/mozilla/geckodriver/releases).

Put geckodriver.exe in the script folder and then call webdriver.Firefox with

driver = webdriver.Firefox(firefox_binary=binary, firefox_profile=fp, executable_path='geckodriver.exe')

Upvotes: 3

Related Questions