gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:10:19 25 4
gpt4 key购买 nike

在我的系统上,我有 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

最佳答案

好的,我将在此处对日志进行注释,希望您将来可以了解如何读取它并从中进行调试。对于任何不准确的地方,我深表歉意,因为我已经习惯了 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'

所以这是下一条线索 - 在我们连接之前浏览器似乎已经退出。输出是:错误:没有指定显示 - 所以这表明问题是你正在 headless 运行,SeleniumLibrary 期望找到一个显示(如果我错了请纠正我)所以你可能需要创建一个,这比听起来容易得多 - 您需要安装 PyVirtualDisplay然后从 robotframework - 尝试使用 |图书馆 | pyvirtualdisplay.smartdisplay.SmartDisplay | 在使用 SeleniumLibrary 之前。

------------------------------------------------------------------------------
[ 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 - 使用 Robot Framework 执行 selenium 示例时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14898372/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com