3

I'm running tests in Ruby Mine 2.7.1 using Page-Object + Rspec.

Environment: Windows 7 x64, Ruby 1.9.3 p551, IE 11.

Gems: watir, rspec, bundler, page-object

When i run tests in Chrome or Firefox everything is ok.

But when i try to run them in IE, the IE window with correct page gets opened and after that i get an error specified in Subject: "Watir::Exception::NoMatchingWindowFoundException: browser window was closed"

The point is that the browser is actually open at that moment and shows a correct page. (See the screencast showing what happens: http://screencast.com/t/06prRy3OMLM)

Test gets finished with an error and the config.after do section doesn't get executed because the browser window remains opened.

That error happens when the following code is executed:

before(:each) do

visit <ClassName>

end

Seems like the IEDriverServer loses connection with IE right after the page is opened.

The most confusing this is that in very rare cases, everything is working good, and in even more rare cases everything is working with significant slowdowns with timeout error at the end.

sleep <n> delays don't help.

I tried different versions of selenium-webdriver gem (it is required by watir gem), different versions of IEDriverServer for both x86 and x64 platforms - result is the same.

Exception description in lib/watir-classic/exceptions.rb says the following:

# This exception is raised if the window cannot be found class NoMatchingWindowFoundException < WatirException; end

What do i do to set IEDriverServer not to lose the IE browser?

2 Answers2

2

UPD: I found a solution. It consists of two steps.

Step 1.

Fisrt of all, an answer to the above question is explicitly described here, "Required Configuration" section, paragraph 5 "For IE 11 only, ...": (https://code.google.com/p/selenium/wiki/InternetExplorerDriver)

`For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates.

For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.`

If this value contains somethings except of 0, the IEDriverServer will lose connection to IE browser as described in my case.

So, RTFM! (c) See Step 2 in the next comment.

  • Step 2. (See Step 1 in previous comment) Here (http://selenium-release.storage.googleapis.com/index.html) you can download two different versions of IEDriverServer: Win32 and x64. The point is that even if you have x64 Windows (maybe it is related to Windows 7 x64 only because i have that one) you **should download and use Win32 version** of IEDriverServer anyway or you'll have dramatical slow-downs that will finish in timeout exceptions. Watch this video to see the difference between usage of Win32 and x64 versions in Windows 7 x64 with IE 11: (http://screencast.com/t/VCNAOSNUT5B) – balzatul von Lemberg Aug 05 '15 at 10:03
0

If you require 'watir' and you specify IE, the implementation defaults to watir-classic behavior.

Try:

require "watir" Watir.driver = :webdriver browser = Watir::Browser.new :ie

titusfortner
  • 4,099
  • 2
  • 15
  • 29
  • Alternately you could do: `require "watir-webdriver"` – titusfortner Aug 04 '15 at 16:12
  • First proposition does not work as well. I'm getting: `SystemStackError: stack level too deep C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:57 Showing full backtrace because every line was filtered out. See docs for RSpec::Configuration#backtrace_exclusion_patterns and RSpec::Configuration#backtrace_inclusion_patterns for more information.` This happens after i add `require watir`. For the second proposition, this is namely what i did when the problem appeared. – balzatul von Lemberg Aug 05 '15 at 06:25