简体   繁体   English

Watir WebDriver:新窗口隐藏在主窗口后面

[英]Watir webdriver: new window hiding behind main window

I've been doing some dabbling with test automation using Ruby and Watir webdriver... 我一直在尝试使用Ruby和Watir Webdriver进行测试自动化...
I am running into an oddity where I open a new window, but when I act upon it, it performs all my actions behind the parent window 我在打开新窗口时遇到了一个奇怪的问题,但是当我对它执行操作时,它将在父窗口后面执行我的所有操作
Here's how I set it up (using Firefox if that makes a difference): 这是我的设置方法(如果有帮助,请使用Firefox):

# opens new window
b.button(:text => 'Upload').click
b.window(:url => 'urlname'). use do
    # action performed on the new window
    b.select_list(:id => 'selector').select 'Foo'
end

Note: it correctly performs actions on the select list present, but it does this behind the main browser. 注意:它会正确地对当前的选择列表执行操作,但是会在主浏览器后面执行。

Is there something specific I need to write in order for it to remain in front of the main window? 我需要写一些特定的内容以使其保留在主窗口的前面吗?

This should work: 这应该工作:

b.window(:url => 'urlname').focus

Put that line just after your .use line, and you should see the new window called to the foreground. 将那行放在您的.use行之后,您应该看到调用了前台的新窗口。 You may actually find that you don't end up needing the .use line (or the do/end ) at all. 您可能实际上发现您根本不需要使用.use行(或do/end )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM