简体   繁体   中英

TypeError: 'module' object is not callable error. How do I solve this issue?

Below is the code:

from selenium import webdriver
from selenium.webdriver.common import keys

driver = webdriver.firefox()
driver.get ("http://www.python.org")

Error message:

Traceback (most recent call last):
  File "C:/pselenium/sample.py", line 4, in <module>
    driver = webdriver.firefox()
TypeError: 'module' object is not callable

I check the directory firefox is all lowercase and not "Firefox". I dont know whats the problem. I have even updated the browser.

Try this:

driver = webdriver.Firefox('./geckodriver')

By the way, besides installing the Selenium python package using pip you have to download the geckodriver and pass its location to the Firefox class when initializing the driver.

The command for installing Selenium is this:

pip install -U selenium

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM