首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Robot Framework执行selenium示例时出错

使用Robot Framework执行selenium示例时出错
EN

Stack Overflow用户
提问于 2013-02-15 23:52:19
回答 1查看 6.5K关注 0票数 3

在我的系统上,我安装了Python 2.6和Robot框架。我已经按照下面的链接安装了Selenium2Library:https://github.com/rtomac/robotframework-selenium2library,但当我尝试运行这个例子时,它给了我以下错误信息,并且没有打开firefox窗口。

代码语言:javascript
复制
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/

我的运行错误是:

代码语言:javascript
复制
$ 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
EN

回答 1

Stack Overflow用户

发布于 2013-02-20 18:44:37

好的,在这里,我将对日志进行注释,希望您将来可以看到如何读取它并从中进行调试。我为任何不准确的地方道歉,因为我已经习惯了Selenium2Library:

代码语言:javascript
复制
$ 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正在尝试截图,但是没有看到浏览器打开-你看到浏览器打开了吗?它是否打开到正确的页面?

代码语言:javascript
复制
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 -在使用| Library | pyvirtualdisplay.smartdisplay.SmartDisplay |之前尝试使用SeleniumLibrary。

代码语言:javascript
复制
------------------------------------------------------------------------------
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open

这又是第一条线索。

代码语言:javascript
复制
Open Selenium Page [Documentation] TestCase for open Selenium page    | FAIL |
No browser is open

这是因为之前的问题。

代码语言:javascript
复制
------------------------------------------------------------------------------
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14898372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档