python - 接收属性错误 'FirefoxBinary'对象没有属性 '_get_firefox_output'

标签 python firefox testing selenium selenium-webdriver

周三,我的代码工作了。我今天回来了,我的代码不再有效。没有人碰过它,包括我自己。我收到以下错误消息:

'FirefoxBinary' object has no attribute '_get_firefox_output'

我正在使用 Selenium/Python 的 SST 框架。我的代码不会直接调用 browser.py 文件,因为我只调用操作、案例和配置。我卸载并重新安装了 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'

最佳答案

enter image description here

(取自 Learn to Read the Source, Luke )

在探索了 selenium python 绑定(bind)的源代码后,我在 selenium 2.44 中发现了这一点。 FirefoxBinary 类中不再有可用的 _get_firefox_output() 方法。与 contained it 版本 2.43 相反:

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/

相关文章:

python - copy.copy 与 python 中的赋值不同吗

firefox - 如何在 Vimperator 中右键单击?

reactjs - 如果某些列在某些浏览器中是固定的,为什么表头和数据在 Ant 表中会重叠?

firefox - 可以让 Firefox DevTools Inspector 高亮显示吗?

javascript - 获取使用 Jest 运行的测试列表(不运行套件)

javascript - 在 Mocha 中 before 的范围问题

python正则表达式: match one of listed substrings

Python Pandas - 如何使用键的存在过滤具有包含字典的列的数据框?

python - 用于展平嵌套列表的递归生成器

java - 带有外部库的 Robolectric NoClassDefFoundError