作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
星期三,我的代码成功了。我今天回来,我的代码不再有效。没有人碰过它,包括我自己。我收到以下错误消息:
'FirefoxBinary' object has no attribute '_get_firefox_output'
我正在为 Selenium/Python 使用 SST 框架。我的代码没有直接调用 browser.py 文件,因为我只调用 Action 、案例和配置。我卸载并重新安装了 SST 和 Firefox,结果相同。
这是我的代码:
import unittest
from sst.actions import *
from sst import cases, config
class TestMyTest(cases.SSTTestCase):
def test_mytestcase_home_page(self):
config.results_directory = "C:/Users/Brenda/test/SST-Test-Project/results"
go_to('http://www.myhomepage.com')
assert_title_contains('My Home Page')
take_screenshot(filename='home_page.png',add_timestamp=True)
assert_element(tag='a', text='Log in')
我已将 Firefox 从 34.0.5 降级到 32。我正在运行 python 2.7.8。我也在运行 SST 0.2.4。完整的回溯错误信息是:
C:\Python27\python.exe C:/Users/Brenda/test/SST-Test-Project/MySSTTest.py
E
======================================================================
ERROR: test_mytestcase_home_page (__main__.TestMyTest)
----------------------------------------------------------------------
_StringException: Traceback (most recent call last):
File "C:\Python27\lib\site-packages\sst\cases.py", line 75, in setUp
self.start_browser()
File "C:\Python27\lib\site-packages\sst\cases.py", line 102, in start_browser
self._start_browser()
File "C:\Python27\lib\site-packages\sst\cases.py", line 95, in _start_browser
self.browser = self.browser_factory.browser()
File "C:\Python27\lib\site-packages\sst\browsers.py", line 211, in browser
return self.webdriver_class(self.profile)
File "C:\Python27\lib\site-packages\sst\browsers.py", line 183, in __init__
firefox_profile, FirefoxBinary(), timeout, capabilities, proxy)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 59, in __init__
self.binary, timeout),
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 66, in launch_browser
self._wait_until_connectable()
File "C:\Python27\lib\site-packages\sst\browsers.py", line 172, in _wait_until_connectable
% (self._get_firefox_output(),))
AttributeError: 'FirefoxBinary' object has no attribute '_get_firefox_output'
最佳答案
(取自Learn to Read the Source, Luke)
在探索了 selenium
python 绑定(bind)的源代码之后,我发现在 selenium 2.44
中FirefoxBinary
类中不再有可用的 _get_firefox_output()
方法。与 2.43
版本相反 contained it :
def _get_firefox_output(self):
return self.process.communicate()[0]
def _wait_until_connectable(self):
"""Blocks until the extension is connectable in the firefox."""
count = 0
while not utils.is_connectable(self.profile.port):
if self.process.poll() is not None:
# Browser has exited
raise WebDriverException("The browser appears to have exited "
"before we could connect. The output was: %s" %
self._get_firefox_output())
if count == 30:
self.kill()
raise WebDriverException("Can't load the profile. Profile "
"Dir: %s Firefox output: %s" % (
self.profile.path, self._get_firefox_output()))
count += 1
time.sleep(1)
return True
换句话说,SST 0.2.4
与 selenium 2.44
不兼容。将 selenium
降级到 2.43
。
关于python - 接收属性错误 'FirefoxBinary' 对象没有属性 '_get_firefox_output',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27236915/
星期三,我的代码成功了。我今天回来,我的代码不再有效。没有人碰过它,包括我自己。我收到以下错误消息: 'FirefoxBinary' object has no attribute '_get_fir
我是一名优秀的程序员,十分优秀!