切換頁面

切換頁面一般有如下兩種情況:
在當前瀏覽器裏打開多個窗口,窗口間切換
打開多個瀏覽器,瀏覽器之間切換

切換窗口

該操作適用於:打開兩(多)個窗口頁面,在打開的窗口頁面進行切換操作
主要需要用Select Windows 和Close Windows來處理彈出的窗口

*** Settings ***
Suite Setup       open baidu
Suite Teardown
Library           Selenium2Library
Library           Collections

*** Test Cases ***
test
    input text    css=#kw[name="wd"]    csdn
    Click Element    css=input[id="su"]
    sleep    3s
    Wait Until Page Contains Element    xpath=//*[@id="1"]/h3/a[1][@target="_blank"]
    sleep    3s
    Click Element    xpath=//*[@id="1"]/h3/a[1][@target="_blank"]
    sleep    3s
    
#Get Window Titles 關鍵字
    ${titles}    Get Window Titles
    ${titles1}    get from list    ${titles}    1   #第二個頁面
    ${titles3}    get from list    ${titles}    2   #第三個頁面
    Select Window    title=${titles3}
    
#Get Window Handles 關鍵字
    #${titles}    Get Window Handles
    #Select Window    ${titles[2]}  #第三個頁面  

    Click Element    xpath=//*[@id="csdn_container_tool"]/div/ul/li[3]/a

*** Keywords ***
open baidu
    Open Browser    https://www.baidu.com/    chrome
    Selenium2Library.Set Window Size    1920    1080
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章