2013-02-15 100 views
2

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

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) 

任何帮助真的apreciated

编辑

我很抱歉,我刚才看到您的回复。可能这会帮助你更多地理解我的问题。 示例代码的链接是: `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 
+0

你可以链接到你吃的例子吗?看看这个页面,我只能看到[https://github.com/rtomac/robotframework-selenium2library/blob/master/demo/rundemo.py](https://github.com/rtomac/robotframework-selenium2library/blob/ master/demo/rundemo.py) – theheadofabroom 2013-02-16 10:05:02

+0

对不起,我刚刚看到你的评论。可能这会帮助你更好地理解我的问题: – user1512496 2013-02-18 15:22:31

+0

请参阅下面的答案,并留下评论,如果它不能解决您的问题 – theheadofabroom 2013-02-23 09:30:31

回答

1

好了,所以在这里我要注释日志,以便希望你可以看到如何阅读和调试从它的未来。我对任何不准确之处表示歉意,因为我用Selenium2Library#m的:

$ 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' 

因此,这里的下一个线索 - 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 
+0

感谢您的回复。我确实用vnc server – user1512496 2013-02-27 19:39:40

+0

解决了它很酷,如果有帮助的话,可以自由地编辑它来添加任何信息并接受答案,以便有相同问题的其他人可以看到它有所帮助,否则它可能有助于回答你自己的问题,接受。 – theheadofabroom 2013-02-28 07:17:19

相关问题