【发布时间】:2021-08-19 04:16:23
【问题描述】:
有人可以发布示例代码来创建两个浏览器实例并在使用 Robot Framework 的浏览器(不使用 SeleniumLibrary)库之间切换吗?
即:如何为Switch Browser关键字获取正确的browser id。
Switch Browser ${browser_id}
到目前为止的完整代码:
Library Browser
Library String
Library Collections
** Variables **
${url1}= https://www.google.com
${url1}= https://www.bing.com
@{browser_ids}= Create List
** Test Cases **
Open Browser 1
[Tags] UI dev
New Browser chromium headless=false
New Context viewport={'width': 1920, 'height': 1080}
New Page ${url1}
Open Browser 2
[Tags] UI dev
New Browser chromium headless=false
New Context viewport={'width': 1920, 'height': 1080}
New Page ${url2}
Page Switch tests
[Tags] UI dev
Switch to Browser1
Get Element text=Gmail
Switch to Browser2
Get Element text=© 2021 Microsoft
** Keywords **
Switch to Browser2
Switch Page ${browser_ids}[1]
Switch to Browser1
Switch Page ${browser_ids}[0]
Store Active Browser Id
${active_id}= Get Page Ids ACTIVE ACTIVE ACTIVE
Log To Console ${active_id}
${active_id}= Split String ${active_id}[0] =
Log To Console ${active_id}[1]
Append To List ${BROWSER_IDS} ${active_id}
【问题讨论】: