Robotframework 机器人框架,chrome新标签问题
我有一个简单的机器人框架脚本Robotframework 机器人框架,chrome新标签问题,robotframework,Robotframework,我有一个简单的机器人框架脚本 *** Settings *** Documentation Simple Amazon.in demo Library SeleniumLibrary *** Variables *** ${MESSAGE} Hello, World *** Test Cases *** User must sign in to check out [Documentation] This is some basic info about the test
*** Settings ***
Documentation Simple Amazon.in demo
Library SeleniumLibrary
*** Variables ***
${MESSAGE} Hello, World
*** Test Cases ***
User must sign in to check out
[Documentation] This is some basic info about the test
[Tags] Smoke
Open Browser http://www.amazon.in chrome
Input text id=twotabsearchtextbox Ferrari 458
Click Button xpath=//div[@class='nav-search-submit nav-sprite']/input[@class='nav-input' and 1]
Wait until page Contains results for "Ferrari 458"
Click Link css=#result_0 a.s-access-detail-page
Wait until Page Contains Back to search results for "Ferrari 458"
Click Button id=add-to-cart-button
Wait Until Page Contains 1 item added to Cart
但每当chrome进入点击Link css=#result_0 a.s-access-detail-page
就会打开一个新的选项卡,我的机器人脚本就会失败。我怎样才能改正呢。请帮助您可以使用关键字和获取窗口标题
关键字在它们之间导航获取窗口标题
关键字将返回标题列表该列表中的最后一个索引是已打开的新选项卡,要从列表中访问它,您可以执行以下操作${Tabs[1]}
(与此代码一样,列表中只有2个值)
结果:
==============================================================================
Amazon :: Simple Amazon.in demo
==============================================================================
User must sign in to check out :: This is some basic info about th...
DevTools listening on ws://127.0.0.1:29864/devtools/browser/75b8be3c-6e76-474f-b391-d340fb322895
User must sign in to check out :: This is some basic info about th... | PASS |
------------------------------------------------------------------------------
Amazon :: Simple Amazon.in demo | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output: C:\development\robot-scripts\sssss\output.xml
Log: C:\development\robot-scripts\sssss\log.html
Report: C:\development\robot-scripts\sssss\report.html
我更改了代码的最后一行,因为它不是有效文本。请参阅代码中的注释。您是否尝试使用将selenium的焦点更改为新窗口?
==============================================================================
Amazon :: Simple Amazon.in demo
==============================================================================
User must sign in to check out :: This is some basic info about th...
DevTools listening on ws://127.0.0.1:29864/devtools/browser/75b8be3c-6e76-474f-b391-d340fb322895
User must sign in to check out :: This is some basic info about th... | PASS |
------------------------------------------------------------------------------
Amazon :: Simple Amazon.in demo | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output: C:\development\robot-scripts\sssss\output.xml
Log: C:\development\robot-scripts\sssss\log.html
Report: C:\development\robot-scripts\sssss\report.html