Watir::IE.attach(:title,/x/) 在 Win 7 IE8 上无法正常工作

发布于 2024-08-30 03:56:44 字数 1084 浏览 4 评论 0原文

系统: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁吢 2024-09-06 03:56:44

现在,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

勿忘初心 2024-09-06 03:56:44

关闭用户帐户控制(设置为最低设置)。转到控制面板 -> 系统和安全 -> 操作中心 -> 更改用户帐户控制设置,然后将滑块拉至最低设置。

我遇到了同样的问题,这为我解决了。

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.

提笔书几行 2024-09-06 03:56:44

我遇到了同样的问题。我对此进行了更多调查,问题似乎是,当已经存在一个以管理员权限打开的 IE8 实例时,Watir 将看不到任何其他以管理员身份运行的 IE8 窗口,包括那些窗口它会自行打开。

我通过这样做意识到了这一点:

Watir::IE.each do |window|

  puts window.title

end

我尝试过的情况是:

  1. 以前没有打开过 IE 窗口导致 watir 只列出新浏览器,而不是它创建的浏览器(我想要附加到的浏览器)。
  2. 一个或多个先前打开的非管理 IE 窗口将列出预先存在的浏览器实例及其本身,但同样不会列出它生成的新窗口。
  3. 以管理员身份运行的一个或多个先前打开的 IE 窗口略有不同,因为它会列出所有预先存在的窗口,但不会列出自身或它创建的任何其他窗口。

这使我得出结论,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:

Watir::IE.each do |window|

  puts window.title

end

The cases I tried out were:

  1. No previously opened IE windows resulted in watir listing only the new browser, not the one it created (that i wanted to attach to).
  2. One or more previously opened non-admin IE windows would list the pre-existing browser instances, as well as itself, but again it would not list the new window it spawned.
  3. One or more previously opened IE windows run as admin was slightly different in that it would list off all of the pre-existing windows, but would not list itself nor any additional windows it created.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文