在Selenium IDE中打开新窗口后保持焦点 [英] Keeping the focus after opening a new window in the Selenium IDE

查看:453
本文介绍了在Selenium IDE中打开新窗口后保持焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IDE中使用openWindow命令后,我遇到了问题。此问题仅适用于同一测试套件中的第二个测试用例试图与新打开的窗口进行交互的情况。例如,我有一个由不同的测试用例组成的测试套件来执行以下操作:
$ b


  1. 登录到站点A

  2. 输入一些交易数据

  3. 提交交易以进行批准

  4. 打开一个新窗口并登录到站点B

  5. 批准B站点中的交易并关闭窗口
  6. 继续处理站点A中的交易


    如果我在与openWindow相同的测试用例(即合并测试用例4和5)中执行测试用例5的站点B操作,则所有的命令都会执行而不会出错。如果我在不同的测试用例中执行相同的操作,那么新窗口将失去焦点,所有的Selenium命令都会被引导回原来的窗口。



    这个有趣的部分在测试用例5中执行selectWindow name = siteB_URL导致出现错误信息Window not not在第5步中试图识别并重新选择new窗口。

    如果这看起来像一个硒错误...。

    然后,我想我会打电话给storeAllWindowNames和回声的结果,至少看到窗口名称Selenium知道关于在不同的点。如果我这样做了测试用例4中的最后两个命令,我得到了预期的结果 - echo,siteB_URL被记录下来。如果我在测试用例五的前两行做同样的事情,我会得到回声。这是得到我的部分 - 简单地改变测试用例似乎失去了对新窗口的引用。

    有没有人提出了解决这个问题的方法或解决方案Selenium IDE?



    我今天上午花了几个小时在网上搜寻,各种论坛都在寻找建议,无济于事。

    预先感谢,

    Glenn
    $ b 4-7-12 - 更新 - 这是一个

      [info]执行:| openWindow | http://www.google.com.au | google2 | 
    [info]执行:| selectWindow | google2 | |
    [info]执行:| storeAllWindowNames | allWindows | |
    [info]执行:| echo | $ {allWindows} | |
    [info] echo:,google2
    [info]执行:| storeAllWindowNames | allWindows | |
    [info]执行:| echo | $ {allWindows} | |
    [info] echo:
    [info]执行:| selectWindow | name = google2 | |
    [error]窗口不存在。如果这看起来像一个硒错误,请确保阅读http://seleniumhq.org/docs/04_selenese_commands.html#alerts-popups-and-multiple-windows寻找潜在的解决方法。


    解决方案

    b

      selectWindow()

    ()中提供窗口标题名称。

    例如:
    窗口标题是Testing,然后

     命令:selectWindow 
    title:测试

    要知道新打开窗口的标题,请按照以下步骤操作:

    转到新窗口



    右键 - >查看页面源码

    按ctrl + F。



    您将获得新窗口的标题。



    我希望这有助于...
    感谢
    Sathiya


    I'm having a problem retaining the focus after using the openWindow command in the IDE. This problem only applies when a second test case within the same test suite tries to interact with the newly-opened window. For example, I have a test suite consisting of separate test cases to do the following:

    1. Log into site A
    2. Enter some transactional data
    3. Submit the transaction for approval
    4. Open a new window and log into site B
    5. Approve the transaction in site B and close the window
    6. Continue processing the transaction in site A

    If I do the test case 5 "site B" actions in the same test case as the "openWindow" (ie. merge test cases 4 and 5) then all commands execute without error. If I do the same actions in a different test case then the new window loses the focus and all Selenium commands are directed back to the original window.

    The interesting part of this is trying to identify and reselect the "new" window in step 5.

    Executing "selectWindow name=siteB_URL" in test case 5 results in the error message "Window does not exist. If this looks like a Selenium bug...".

    I then figured I'd call storeAllWindowNames and echo the results to at least see the window names Selenium knows about at various points. If I do this as the last two commands in test case 4 I get the expected result - "echo ,siteB_URL" is logged. If I do the same thing as the first two lines in test case five I get "echo ". This is the part that gets me - simply changing test cases seems to lose the reference to the new window.

    Has anyone come up with a workaround or solution to this problem in the Selenium IDE?

    I've spent several hours this morning scouring the web and various forums looking for suggestions to no avail.

    Thanks in advance,

    Glenn

    4-7-12 - Update - here's a simplified example of the scenario above:

    [info] Executing: |openWindow | http://www.google.com.au | google2 |
    [info] Executing: |selectWindow | google2 | |
    [info] Executing: |storeAllWindowNames | allWindows | |
    [info] Executing: |echo | ${allWindows} | |
    [info] echo: ,google2
    [info] Changed test case
    [info] Executing: |storeAllWindowNames | allWindows | |
    [info] Executing: |echo | ${allWindows} | |
    [info] echo:
    [info] Executing: |selectWindow | name=google2 | |
    [error] Window does not exist. If this looks like a Selenium bug, make sure to read http://seleniumhq.org/docs/04_selenese_commands.html#alerts-popups-and-multiple-windows for potential workarounds. 
    

    解决方案

    Try with option:

    selectWindow()
    

    Just provide the window title name within ().

    For Ex: Window Title is Testing, then

    command : selectWindow
    title : Testing 
    

    To know the title of the newly opened window follow the steps:

    Go to the new window

    Right click->view page source

    Press ctrl+F.

    Type title and search.

    You will get the title of the new window.

    I hope this helps... Thanks Sathiya

    这篇关于在Selenium IDE中打开新窗口后保持焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆