【问题标题】:Error occurs during executing the examples of selenium with Robot Framework使用 Robot Framework 执行 selenium 示例时发生错误
【发布时间】:2013-01-31 15:28:25
【问题描述】:

在我的系统上,我有 Python 2.6 和 Robot 框架。我已经按照以下链接的说明安装了 Selenium2Library: https://github.com/rtomac/robotframework-selenium2library 但是当我尝试运行该示例时,它给了我以下错误并且没有打开任何 Firefox 窗口。

ERROR:  clean-python26-env]$ python testExeJS.py 
======================================================================
ERROR: test_exe_javascript (__main__.ExecuteJavascriptTestCase)
----------------------------------------------------------------------

Traceback (most recent call last):
  File "testExeJS.py", line 7, in setUp
    selenium.setTimeout("60000")
NameError: global name 'selenium' is not defined

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)

任何帮助真的很感激

编辑

对不起,我刚刚看到你的回复。可能这将帮助您更多地了解我的问题。 示例代码链接为: `http://www.wallix.org/2011/07/26/how-to-use-robotframework-with-the-selenium-library/

我的运行错误是:

$ pybot myFirstTest.txt 

==============================================================================
myFirstTest :: This is your first test                                        
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
Go To Google Page [Documentation] Go to google page and search som... | FAIL |
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'
------------------------------------------------------------------------------
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
Open Selenium Page [Documentation] TestCase for open Selenium page    | FAIL |
No browser is open
------------------------------------------------------------------------------
myFirstTest :: This is your first test                                | FAIL |
2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Output:  /data/home/sadikhan/ironport/Selenium/output.xml
Log:     /data/home/sadikhan/ironport/Selenium/log.html
Report:  /data/home/sadikhan/ironport/Selenium/report.html

【问题讨论】:

标签: selenium python-2.7 selenium-webdriver robotframework


【解决方案1】:

好的,所以我将在这里对日志进行注释,以便您将来可以看到如何阅读它并从中进行调试。对于任何不准确之处,我深表歉意,因为我已经习惯了 Selenium2Library:

$ pybot myFirstTest.txt 
==============================================================================
myFirstTest :: This is your first test                                        
==============================================================================
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open

好的,这是您的第一个线索 - selenium 正在尝试截取屏幕截图,但没有看到打开的浏览器 - 您看到打开的浏览器了吗?它是否打开到正确的页面?

Go To Google Page [Documentation] Go to google page and search som... | FAIL |
WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: Error: no display specified\n'

所以这是下一个线索 - The browser appears to have exited before we could connect. The output was: Error: no display specified - 所以这表明问题是你正在无头运行,而 SeleniumLibrary 期望找到一个显示(如果我错了,请纠正我)所以你可能需要创建一,这比听起来容易得多 - 您需要安装PyVirtualDisplay,然后从robotframework - 在使用SeleniumLibrary之前尝试使用| Library | pyvirtualdisplay.smartdisplay.SmartDisplay |

------------------------------------------------------------------------------
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open

这又是第一个线索。

Open Selenium Page [Documentation] TestCase for open Selenium page    | FAIL |
No browser is open

这是因为之前的问题。

------------------------------------------------------------------------------
myFirstTest :: This is your first test                                | FAIL |
2 critical tests, 0 passed, 2 failed
2 tests total, 0 passed, 2 failed
==============================================================================
Output:  /data/home/sadikhan/ironport/Selenium/output.xml
Log:     /data/home/sadikhan/ironport/Selenium/log.html
Report:  /data/home/sadikhan/ironport/Selenium/report.html

【讨论】:

  • 酷,如果这有帮助,请随意编辑它以添加任何信息并接受答案,以便其他有相同问题的人可以看到它有帮助,否则回答您自己的问题和接受。
猜你喜欢
  • 1970-01-01
  • 2020-12-09
  • 2020-11-12
  • 2013-03-18
  • 2015-04-25
  • 2022-11-30
  • 2022-01-27
  • 2016-12-16
  • 1970-01-01
相关资源
最近更新 更多