xiaobo234 发表于 2017-5-8 18:25:52

求助:python+selenium 报错

#!/usr/bin/python
# -*- coding: UTF-8 -*-

from selenium import webdriver

browser = webdriver.firefox()

browser.get("http://www.baidu.com")

browser.close()

运行后报错:
Traceback (most recent call last):
File "D:/Python27/Lib/uuu.py", line 6, in <module>
    browser = webdriver.firefox()
TypeError: 'module' object is not callable

谁知道原因啊:'(

jingzizx 发表于 2017-5-8 19:24:22

帮顶

cq520131517 发表于 2017-5-8 19:37:27

请大写:webdriver.Firefox(),小写是错误

cq520131517 发表于 2017-5-8 19:38:16

调用浏览器,千万不要小写。python中大写和小写有很大区别的!

掉渣饼 发表于 2017-5-9 08:54:59

一楼正解,顺便补充,如果调用火狐浏览器是webdriver.Firefox(),如果调用谷歌浏览器是webdriver.Chrome(),如果调用IE浏览器是webdriver.Ie()

梦想家 发表于 2017-5-9 09:03:33

:)

梦想家 发表于 2017-5-9 09:03:41

1楼正解

xiaobo234 发表于 2017-5-9 13:05:35

很感谢大家的回复,改成大写后,仍然不行啊,报错如下:
Traceback (most recent call last):
File "D:/Python27/Lib/daxie.py", line 6, in <module>
    browser = webdriver.Firefox()
File "D:\Python27\selenium\webdriver\firefox\webdriver.py", line 60, in __init__
    self.binary, timeout),
File "D:\Python27\selenium\webdriver\firefox\extension_connection.py", line 45, in __init__
    self.profile.add_extension()
File "D:\Python27\selenium\webdriver\firefox\firefox_profile.py", line 143, in add_extension
    self._install_extension(extension)
File "D:\Python27\selenium\webdriver\firefox\firefox_profile.py", line 336, in _install_extension
    shutil.rmtree(tmpdir)
File "D:/Python27/Lib\shutil.py", line 247, in rmtree
    rmtree(fullname, ignore_errors, onerror)
File "D:/Python27/Lib\shutil.py", line 256, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
File "D:/Python27/Lib\shutil.py", line 254, in rmtree
    os.rmdir(path)
WindowsError: : 'c:\\users\\bj-01-~1\\appdata\\local\\temp\\tmpm_weh5.webdriver.xpi\\components'

xiaobo234 发表于 2017-5-9 13:06:12

已经倒腾了很久了,周围也没有人会:'(
页: [1]
查看完整版本: 求助:python+selenium 报错