10

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.

4 Answers 4

24

You have made a typo.

webdriver.Firefox()

Note the capital F.

Sign up to request clarification or add additional context in comments.

Comments

5

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! ;)

Comments

1

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

1 Comment

I have kept the chromedriver.exe in the same folder as my project and it works without adding the path explicitly.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.