最大化浏览器窗口,机器人框架



我正在学习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
    [Tags]  Smoke
    Open Browser  http://www.amazon.in  firefox
    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

一切正常,但浏览器窗口未最大化,请帮助我,我该怎么做。

这是我的点配置

robotframework                 3.1
robotframework-requests        0.5.0
robotframework-seleniumlibrary 3.2.0
selenium                       3.141.0

首先,您可以在打开浏览器后使用 Maximize Browser Window 关键字。

如果这不起作用;这里有建议的可能修复:https://github.com/robotframework/SeleniumLibrary/issues/123

看看它是否能解决您的问题。让我知道它是否确实如此。

试试这段代码。

Open Browser    about:blank    safari
Maximize Browser Window

希望对您有所帮助。

打开浏览器 http://www.amazon.in 铬

最大化浏览器窗口

更多信息:http://robotframework.org/Selenium2Library/Selenium2Library.html#Maximize%20Browser%20Window

通用测试设置

    [Documentation]  All test cases should use this in Test Setup.
    set test variable  ${BooleanLoggedIn}  ${False}
    Login Detail for Admin or Resp Decision
    run keyword if      "${REMOTE}"=="False"   run keywords  TFNR_Utilities.Open Chrome Maximized
    ...                 ELSE IF     "${REMOTE}"=="True"    run keywords  TFNR_Utilities.Run Tests on Cross Browser Platform
    ...                 ELSE        log   Check the value of Global variable 'REMOTE'
    SeleniumLibrary.Go To  ${LOGIN URL}
    SeleniumLibrary.Maximize Browser Window
    Login.Login To TFNR SPA UI  ${VALID USER}   ${VALID PASSWORD}
    #DB Data pull if required to Validate Dashboard Page dispaly Name and Default ACTING AS Resp Org Selection
    Set Tags  Browser_${BROWSER}    Tests_ON_${Environment}_Environment
    set test variable  ${BooleanLoggedIn}  ${True}

最新更新