我已经在Robot IDE Framework中编写了现有的selenium测试,我试图在Sauce Labs中运行。
我使用本教程中的示例测试来查看是否可以运行至少一个测试。 http://datakurre.pandala.org/2014/03/cross-browser-selenium-testing-with.html
测试在本地传递,并通过Sauce Labs上的所有测试,但随后超时并给出错误,"测试没有看到90秒的新命令。计时。 错误"因为它没有断开远程Web驱动程序。
我已经在"关闭测试浏览器"结束时一起尝试了所有这些。功能:
我还尝试在关闭过程中运行的一个python函数中添加((RemoteWebDriver)getCurrentWebDriver())。quit()。我是Selenium和Robot Framework的新手,所以我不确定如何获取远程Web驱动程序。
以下是代码,如果有帮助:
*** Settings ***
Test Setup Open test browser
Test Teardown Close test browser
Resource ../../Keywords/super.txt
Library Selenium2Library
Library ../../Library/SauceLabs.py
*** Variables ***
${LOGIN_FAIL_MSG} Incorrect username or password.
${COMMAND_EXECUTOR} http://username:key@ondemand.saucelabs.com:80/wd/hub
${REMOTE_URL} http://username:key@ondemand.saucelabs.com:80/wd/hub
${DESIRED_CAPABILITIES} username:name,access-key:key,name:Testing RobotFramework,platform:Windows 8.1,version:26,browserName:CHROME,javascriptEnabled:True
*** Test Cases ***
Incorrect username or password
[Tags] Login
Go to https://saucelabs.com/login
Page should contain element id=username
Page should contain element id=password
Input text id=username anonymous
Input text id=password secret
Click button id=submit
Page should contain ${LOGIN_FAIL_MSG}
[Teardown]
*** Keywords ***
Open test browser
Open browser http://www.google.com ${BROWSER} \ remote_url=${REMOTE_URL} desired_capabilities=${DESIRED_CAPABILITIES}
Close test browser
Run keyword if '${REMOTE_URL}' != '' Report Sauce status ${SUITE_NAME} | ${TEST_NAME} ${TEST_STATUS} ${TEST_TAGS} ${REMOTE_URL}
Close all browsers
Process close
Stop selenium server
答案 0 :(得分:1)
您无需执行任何特殊操作即可关闭连接。我的猜测是,您的测试中存在阻止浏览器关闭的内容。我的建议是从一个更简单的例子开始,然后从命令行开始。让它工作,然后一路努力,从RIDE中运行更复杂的东西。
这是一个工作示例,我删除了测试中的所有额外内容。我可以从命令行和Windows上的RIDE运行它。但是,您必须添加自己的密钥:
*** Settings ***
| Library | Selenium2Library
*** Variables ***
| @{_tmp}
| ... | name:Testing RobotFramework Selenium2Library,
| ... | browserName:internet explorer,
| ... | platform:Windows 8,
| ... | version:10
| ${CAPABILITIES} | ${EMPTY.join(${_tmp})}
| ${KEY} | <put your username:key here>
| ${REMOTE_URL} | http://${KEY}@ondemand.saucelabs.com:80/wd/hub
| ${URL} | https://saucelabs.com/login
| ${LOGIN_FAIL_MSG} | Incorrect username or password.
*** Test cases ***
| Example of connecting to saucelabs via robot
| | [Setup]
| | ... | Open Browser
| | ... | ${URL}
| | ... | remote_url=${REMOTE_URL}
| | ... | desired_capabilities=${CAPABILITIES}
| |
| | Page should contain element | id=username
| | Page should contain element | id=password
| |
| | Input text | id=username | anonymous
| | Input text | id=password | secret
| | Click button | id=submit
| |
| | Page should contain | ${LOGIN_FAIL_MSG}
| |
| | [Teardown] | Close all browsers