2013-02-15 102 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

相關問題