在 Sauce Labs 上运行 RobotFramework 测试 - 超时错误 [英] Running RobotFramework Tests on Sauce Labs - error with timing out

查看:68
本文介绍了在 Sauce Labs 上运行 RobotFramework 测试 - 超时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用 Robot IDE Framework 编写的现有 selenium 测试,我正尝试在 Sauce Labs 中运行这些测试.

I have existing selenium tests written in Robot IDE Framework that I'm trying to run in Sauce Labs.

我正在使用本教程中的示例测试来查看是否可以运行至少一个测试.http://datakurre.pandala.org/2014/03/cross-browser-selenium-testing-with.html

I'm using the sample test from this tutorial to see if I can get at least one test running. http://datakurre.pandala.org/2014/03/cross-browser-selenium-testing-with.html

测试在本地通过,并通过了 Sauce Labs 上的所有测试,但随后超时并给出错误消息,测试在 90 秒内没有看到新命令.超时.错误",因为它没有断开远程 Web 驱动程序.

The test passes locally, and passes all the tests on Sauce Labs, but then times out and gives and error, "Test did not see a new command for 90 seconds. Timing out. error" because it's not disconnecting Remote Web Driver.

我已经在关闭测试浏览器"功能结束时一起和单独尝试了所有这些:

I've tried all of these, together and separately at the end of the "Close test browser" function:

  • 关闭所有浏览器
  • 进程关闭
  • 停止 selenium 服务器

我还尝试在关闭过程中运行的 Python 函数之一中添加 ((RemoteWebDriver) getCurrentWebDriver()).quit().我是 Selenium 和 Robot Framework 的新手,所以我不确定如何获取远程 Web 驱动程序.

I've also tried adding ((RemoteWebDriver) getCurrentWebDriver()).quit() in one of the python functions that runs during the closing process. I'm new to Selenium and Robot Framework, so I'm not sure how to grab the Remote Web Driver.

这是代码,以防万一:

    *** 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

推荐答案

您无需执行任何特殊操作即可关闭连接.我的猜测是,您的测试中有一些东西阻止了浏览器被关闭.我的建议是从一个更简单的例子开始,从命令行开始.开始工作,然后逐步提高,以便能够在 RIDE 中运行更复杂的东西.

You shouldn't need to do anything special to close down the connection. My guess is, there's something in your test that is preventing the browser from being closed. My recommendation is to start with a simpler example, and start from the command line. Get that working, and then work your way up to being able to run something more complex from within RIDE.

这是一个工作示例,我删除了测试中的所有额外内容.我可以从命令行和 Windows 上的 RIDE 运行它.但是,您必须添加自己的密钥:

Here is a working example where I removed all of the extra stuff in the test. I am able to run this both from the command line and via RIDE on Windows. You'll have to add in your own key, however:

*** 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

这篇关于在 Sauce Labs 上运行 RobotFramework 测试 - 超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆