'TypeError: 'module' object is not callable ( when importing selenium )
i have problem when running this code :
>>> from selenium import webdriver
>>> driver = webdriver.firefox()
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
driver = webdriver.firefox()
TypeError: 'module' object is not callable
i have searched for the problem and i got some results. but unfortunately , they didn't work. So , how can i solve this?
thanks.
Solution 1:[1]
You have made a typo.
webdriver.Firefox()
Note the capital F.
Solution 2:[2]
the same goes for other browsers!
e.g.
webdriver.chrome Vs. webdriver.Chrome
(its even harder to notice this!)
thanks so much for the help! ;)
Solution 3:[3]
Another way is:
from selenium.webdriver import Chrome.
driver = Chrome()
When typing "Chrome" Note the capital C.
You probably gonna need to specify the executable_path for chromedriver.exe:
driver = Chrome(executable_path="path_in_here")
Solution 4:[4]
This error message...
TypeError: 'module' object is not callable
......implies that your program is trying to call a python module.
You need a minor modification in the offending line of code. You have used:
driver = webdriver.firefox()
Where as firefox is a module for example as in:
selenium.webdriver.firefox.options
So you have to change firefox() to Firefox() and your effective line of code will be:
driver = webdriver.Firefox()
Likewise:
For Chrome:
driver = webdriver.Chrome()For Internet Explorer:
driver = webdriver.Ie()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tadgh |
| Solution 2 | Frank Musteman |
| Solution 3 | Yeonathan Aizenberg |
| Solution 4 | undetected Selenium |
