首页 文章

选择使用JavaScript创建的窗口

提问于
浏览
0

在我的机器人脚本中,单击编辑描述链接后,将打开一个窗口(即Java脚本窗口)图像
图1 ::
enter image description here

图片2 ::窗口图像和页面源
enter image description here

我需要的是一个 . 选择窗口(java脚本)b . 在文本区域中输入文本,然后单击确定 .

我试图使用Select Window new / Select window描述但是控制正在等待无限@Select Window关键字它不向前移动 . 我必须强行杀死Control .

*** Settings ***
Documentation    Suite description
Library  Selenium2Library       run_on_failure=Nothing
Library  Collections

*** Test Cases ***
Log into Command center
    [Tags]    DEBUG
    open browser        http://11.8.180.***/BCC     ie

    input text          xpath=//*[@id='LoginName']   User
    input password      Password   Pwd@123
    click element       LoginBtn
    wait until keyword succeeds     30 sec       5 sec     page should contain element      AppTitle
    sleep   3s
    ${Title}    Get Page Title
    log  ${Title}
    Navigation to Usrs
    Click on Window popup and enter text

CloseBrowser
    close all browsers

*** Keywords ***
Click on Window popup and enter text
    Click Link   //*[@id="aspnetForm"]/table/tbody/tr[1]/td[2]/a
    Sleep  5s
Select Window By Unique Identifier Element With Delay   //*[@id="descript"]

Select Window By Unique Identifier Element With Delay
    [Arguments]  ${element}   ${delay_time}=10
    sleep  ${delay_time}
    @{wins}=  Get Window Handles
    Log  ${wins}<--these are window names   console=true
    :FOR  ${windowName}  IN  @{wins}
    \   Log   ${windowName}   console=true
    \   run keyword and ignore error  Select Window  ${windowName}
    \   ${found_flag}=   run keyword and return status  page should contain  ${element}
    \   Run keyword if  ${found_flag}  input text  ${element}  this is text
    \   exit for loop if  ${found_flag}

Get Page Title
    Log  Control came to GET PAGE TITLE
    run keyword and return  Get Title

Navigation to Usrs
    Go to   http://11.8.180.***/BCC/role.aspx

任何想法如何选择新窗口?并输入文字命中好 .

A.Get Window Identifiers --> Jus hangs it neither moves nor throw any error 
B. Get Window Names gives this error {URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>..}. 
C. Get Window Handles returns this {    [u'b0ce0f28-f6d4-4943-93f7-f65fd5f1de2a', u'c0442110-4ea9-40a4-b126-eee09d9f3eb0']} 
I am not sure how to identify which window have these id's

提前致谢

1 回答

  • 0

    它应该被识别为浏览器中的新窗口,因此您可以使用:

    Select Window   Description
    

相关问题