最大化浏览器窗口,RobotFramework

时间:2018-12-30 16:10:17

标签: python 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
    [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

4 个答案:

答案 0 :(得分:3)

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

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

查看它是否可以解决您的问题。让我知道是否可以。

答案 1 :(得分:0)

尝试此代码。

Open Browser    about:blank    safari
Maximize Browser Window

希望可以帮助您。

答案 2 :(得分:0)

答案 3 :(得分:-1)

通用测试设置

    [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}