python 最大化浏览器窗口,RobotFramework

fquxozlt  于 11个月前  发布在  Python
关注(0)|答案(5)|浏览(110)

我正在学习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

字符串
一切都工作正常,但浏览器窗口没有最大化,请帮助我,我怎么能做到这一点。
这是我的pip配置

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

lndjwyie

lndjwyie1#

首先,您可以在打开浏览器后使用Maximize Browser Window关键字。
如果这不起作用;这里建议可能的修复方法:https://github.com/robotframework/SeleniumLibrary/issues/123
看看它是否能解决你的问题。如果能,告诉我。

oxf4rvwz

oxf4rvwz2#

试试这个代码。

Open Browser    about:blank    safari
Maximize Browser Window

字符串
希望能帮到你。

rqenqsqc

rqenqsqc3#

打开浏览器http://www.amazon.in Chrome
最大化浏览器窗口
更多信息:http://robotframework.org/Selenium2Library/Selenium2Library.html#Maximize%20Browser%20Window

liwlm1x9

liwlm1x94#

如果您需要在打开URL之前最大化浏览器窗口,那么您可能需要添加步骤Go To

Open Browser            about:blank    Chrome
    Maximize Browser Window
    Go To                   https://google.com

字符串

t8e9dugd

t8e9dugd5#

通用测试设置

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

字符串

相关问题