Selenium + IE8: force IE8 compatibility view


I’m running Selenium in singleWindow mode and IE8.

If i start IE8 manually the IE8 mode is set, but when i launch it with Selenium, the mode set is IE7 using the compatibility mode.

Anyone knows why the compatibility mode is not the IE8 view when launching the browser with Selenium?

Or, how can i disable totally the compatibility mode in IE and force it to use always the IE8 view?

  • You must to post comments

I’ve given the question a +1 because it’s a very good question — it’s not obvious how to do this, and if you need to test both modes, then it is a necessary thing to do.

You could get the site to serve <meta http-equiv="X-UA-Compatible" content="IE=7" /> within the page when running the tests. This should force the output mode.

Obviously, that’s not ideal, because it means changing your code to produce the meta tag on demand. I’d normally consider it a bad thing if you’re having to change the main codebase in to add code for the specific use of your test suite, but in this case I can’t see any other solution.

Given that we’ve decided to go down this path, you could write your code to accept a specified argument in the URL that triggers the meta tag to be served. The IE7 tests could then be written to send that URL argument.

By the way, it’s worth pointing out that IE8’s IE7-compatibility mode is not 100% identical to IE7; it has its own quirks and bugs which are distinct from those of a real IE7 browser. For the most part it should be fine, but it’s worth being aware of this if you’re expecting your tests to confirm that the site works in IE7. See this blog post for more info

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.