0

I just installed selenium with pip like

pip install selenium

and installed

geckidriver.exe

and put it in

C:\\Program Files\\Mozilla Firefox

where my

firefox.exe

is in.

But when I run a code

from selenium import webdriver
browser = webdriver.Firefox()

it returns

C:\Users\asd\PycharmProjects\tomato\venv\Scripts\python.exe C:/Users/asd/Downloads/pycharmprojects/tomato/test.py
Traceback (most recent call last):
  File "C:/Users/asd/Downloads/pycharmprojects/tomato/test.py", line 2, in <module>
    browser = webdriver.Firefox()
AttributeError: module 'selenium.webdriver' has no attribute 'Firefox'

Process finished with exit code 1

I'm using python3 in anaconda3(32bit), on windows7(64bit).

What did I wrong?

user159234
  • 171
  • 1
  • 1
  • 5
  • Check this discussion https://stackoverflow.com/questions/48267633/python-no-module-named-selenium/48269228#48269228 – undetected Selenium Apr 29 '18 at 13:35
  • @DebanjanB I followed the answer, my python is `python3.6.1`, pip is fine, selenium is `3.11.0`. but when I open `pycharm` and run that code, same result came out. – user159234 Apr 29 '18 at 14:01
  • Can you try to execute the commands one by one through the _CLI_ and update the question with the results (error stack trace if any)? – undetected Selenium Apr 29 '18 at 15:01

1 Answers1

0

Before start firefox, you need set the path where the binary is:

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox')
driver = webdriver.Firefox(firefox_binary=binary)
j.barrio
  • 1,006
  • 1
  • 13
  • 37