51Testing软件测试论坛

标题: 出现如下错误,大神帮帮忙 [打印本页]

作者: liaoxiping    时间: 2016-6-19 11:01
标题: 出现如下错误,大神帮帮忙
不能正常打开火狐浏览器,  是什么原因呢
# coding = utf-8
... from selenium import webdriver
>>> browser = webdriver.Firefox()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py",
line 85, in __init__
    keep_alive=True)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 90, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 177, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 234, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connectio
n.py", line 401, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connectio
n.py", line 432, in _request
    resp = self._conn.getresponse()
  File "C:\Python27\lib\httplib.py", line 1013, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 402, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 360, in _read_status
    line = self.fp.readline()
  File "C:\Python27\lib\socket.py", line 430, in readline
    data = recv(1)
socket.error: [Errno 10054]
>>> browser.get("http://www.baidu.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'browser' is not defined
>>> browser.find_element_by_id("kw").send_keys("selenium")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'browser' is not defined
>>> browser.find_element_by_id("su").click()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'browser' is not defined
>>>
作者: 若尘_51    时间: 2016-6-20 08:34
NameError: name 'browser' is not defined

你的脚本写错了。  引用了未定义的变量
作者: 掉渣饼    时间: 2016-6-20 11:42
你的火狐浏览器firefox.exe所在的路径是否添加到了环境变量中的Path中呢?
作者: 北京狼族    时间: 2016-6-20 12:22
你的默认浏览器是IE而不是火狐
作者: 清晨一缕阳光    时间: 2016-6-20 12:39
把你的脚本贴出来看看。
作者: liaoxiping    时间: 2016-6-21 18:29
谢谢大家,问题解决了   因为火狐47不支持




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2