Watir::IE.attach(:title,/x/) 在 Win 7 IE8 上无法正常工作
系统: 7号窗口 互联网浏览器 8 红宝石1.8 Watir 1.6.5
如果我手动打开浏览器窗口,然后访问导致打开第二个浏览器窗口的站点,然后使用 Watir::IE.attach 方法查找第二个浏览器窗口,则一切正常。问题是,当我使用命令 Watir::IE.new 打开第一个 Internet Explorer 窗口,然后访问导致打开第二个浏览器窗口的站点时。当我使用 Watir::IE.attach 查找第二个浏览器窗口时,我现在得到: Watir::Exception::NoMatchingWindowFoundException:无法定位标题为 (?-mix:x) 的窗口 来自 /ie-class.rb:297:in 'attach_browser_window' 来自 /ie-class.rb:149:in '_attach_init' 来自 /ie-class.rb:143:in 'attach' 来自 (irb):15
有没有人遇到过这个问题并制定了解决方案?
我做了更多的调查,我正在使用管理权限运行我的脚本,它以管理员身份打开 IE8,然后尝试打开一个新窗口。我尝试以管理员身份手动打开 IE8,然后从浏览器打开一个新窗口,然后使用 watir 运行附加命令,但我确实得到了与使用 watir 创建初始窗口相同的错误。
我确实希望能够以管理员身份运行我的脚本。
我尝试手动执行 watir 命令并在脚本中运行:
======================
require 'rubygems'
require 'watir'
ie = Watir:: IE.start("http://www.quackit.com/html/codes/html_open_link_in_new_window .cfm")
ie.link(:text,"HTML 帮助").click
ie2 = Watir::IE.attach(:title,/Help/)
============ =========
System:
Window 7
Internet Explorer 8
Ruby 1.8
Watir 1.6.5
If I manually open a browser window and then visit a site that causes a second browser window to open and then use the Watir::IE.attach method to find the second browser window everything work fine. The problem is when I open the first Internet Explorer window with the command Watir::IE.new and then visit a site that causes a second browser window to open. When I use Watir::IE.attach to find the second browser window I now get:
Watir::Exception::NoMatchingWindowFoundException: Unable to location a window with title of (?-mix:x)
from /ie-class.rb:297:in 'attach_browser_window'
from /ie-class.rb:149:in '_attach_init'
from /ie-class.rb:143:in 'attach'
from (irb):15
Has anyone run into this problem and developed a solution?
I have done a little more investigating and I am running my script with administrative rights, and it is opening IE8 as administrator and then trying to open a new window. I tried to open IE8 as administrator manually and then open a new window from the browser then run the attach command with watir and I did get the same error as if I created the initial window with watir.
I do want to be able to run my script as administrator.
I have tried executing the watir command manually and also running in a script:
======================
require 'rubygems'
require 'watir'
ie = Watir::IE.start("http://www.quackit.com/html/codes/html_open_link_in_new_window.cfm")
ie.link(:text,"HTML Help").click
ie2 = Watir::IE.attach(:title,/Help/)
======================
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
现在,watir 假设您要附加的窗口称为“Internet Explorer”。我想IE8的名字可能和这个不一样。您可以在 ie-class.rb 的第 238 行更改此设置。
布雷特
Right now watir assumes that the window you want to attach to is called "Internet Explorer". I think the name of the IE8 might be different from this. You can change this on line 238 of ie-class.rb.
Bret
关闭用户帐户控制(设置为最低设置)。转到控制面板 -> 系统和安全 -> 操作中心 -> 更改用户帐户控制设置,然后将滑块拉至最低设置。
我遇到了同样的问题,这为我解决了。
Turn off User Account Control (set to the lowest setting). Go to Control Panel->System and Security->Action Center->Change User Account Control settings, and drop the slider to the lowest setting.
I was experiencing the same issue, and this fixed it for me.
我遇到了同样的问题。我对此进行了更多调查,问题似乎是,当已经存在一个以管理员权限打开的 IE8 实例时,Watir 将看不到任何其他以管理员身份运行的 IE8 窗口,包括那些窗口它会自行打开。
我通过这样做意识到了这一点:
我尝试过的情况是:
这使我得出结论,Watir 不会在其列表中保留在打开现有管理员特权 IE8 后创建的任何具有管理员特权的 IE8 实例。
我现在使用的解决方案是不以管理员身份运行我的脚本。我意识到在某些情况下这并不是一个真正的选择,但这是迄今为止我能找到的最好的选择。
I'm getting the same issue. I've investigated it a little bit more, and the issue seems to be that when there already exists an instance of IE8 that was opened with adminstrative privs, Watir won't see any other IE8 windows that are being run as admin, including ones it opens itself.
I came to this realization by doing this:
The cases I tried out were:
Which led me to the conclusion that Watir will not retain in its list any admin-privileged instances of IE8 that it creates after there is an existing admin-privilaged IE8 open.
The solution that I'm using right now is to just not run my scripts as admin. I realize that's not really an option in some cases, but it's the best I've been able to find so far.