Watir :: IE.attach (: title, / x /) does not work correctly on Win 7 IE8

System: Window 7 Internet Explorer 8 Ruby 1.8 Watir 1.6.5

If I manually open a browser window, and then go to the site that causes the second browser window to open, and then use the Watir :: IE.attach method to find the second browser window, everything works fine. The problem is that I open the first Internet Explorer window using the Watir :: IE.new command, and then go to the site that causes the second browser window to open. When I use Watir :: IE.attach to find the second browser window, I now get: Watir :: Exception :: NoMatchingWindowFoundException: Can't place the window with the title (? -Mix: x) from / ie -class.rb: 297 : in 'attach_browser_window' by / ie -class.rb: 149: in '_attach_init' by / ie -class.rb: 143: by 'attach' by (irb): 15

Has anyone encountered this problem and developed a solution?

I did a bit more research, and I run my script as administrator, and it opens IE8 as an administrator, and then tries to open a new window. I tried to open IE8 as an administrator manually, and then open a new window from the browser, and then run the attach command using watir, and I made the same mistake as if I created the initial window using watir.

I want to be able to run my script as an administrator.

I tried to execute the watir command manually and also run in the script:

========================

rubygems required

watir is required

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 /)

========================

+4
source share
3 answers

Watir currently assumes that the window you want to connect is called Internet Explorer. I think the name of IE8 may be different from this. You can change this on line 238 ie-class.rb.

Bret

+1
source

I have the same problem. I explored it a bit more, and the problem seems to be that when there is already an instance of IE8 that has been opened with administrative privileges, Watir will not see any other IE8 windows that run as admin, including opening it itself.

I came to this realization by doing this:

Watir::IE.each do |window| puts window.title end 

The cases I tried were:

  • Previously, not open IE windows led to the fact that watir only listed the new browser, and not the one that he created (to which I wanted to connect).
  • One or more previously opened non-admin-IE windows would display previously existing browser instances, as well as themselves, but again would not display the new window that it spawned.
  • One or more of the previously opened IE windows, run as admin, was a little different, since it was writing off all pre-existing windows, but would not display itself and any additional windows that it created.

This led me to conclude that Watir will not keep any IE8 instances that are privileged to the administrator, which it creates after the existing open IE8 is open.

The solution I'm using now is to simply not run my scripts as admin. I understand that in some cases this is not an option, but this is the best I managed to find.

+1
source

Disable user account control (set the lowest setting). Go to Control Panel-> System and Security-> Action Center-> Change user account management settings and uncheck the slider to the lowest setting.

I had the same issue and this fixed it for me.

+1
source

Source: https://habr.com/ru/post/1307504/


All Articles