QueueHammer
QueueHammer

Reputation: 10824

Using Selenium to test internet explorer in different document modes

Is it possible to change the document mode in Internet Explorer using selenium.

I was looking over a feature request during the development of WebDriver but did not see what ended up happening with it.

I was also looking for a command line parameter that I could use to force Explorer into a specific document mode. Though I'm new to using WebDriver and don't know if it supports that.

The question is how can I use Selenium to test Explorer in a specific document mode?

Upvotes: 3

Views: 1291

Answers (1)

OCary
OCary

Reputation: 3311

Yes, the following isn't via Selenium, but it is the only way I know of right now.

The DocumentMode can be controlled via a meta header tag on the page. Defining Document Compatability And you can modify a web response before it gets to the browser using Fiddler Thus, you can setup Fiddler to add a meta content tag to each response. I did a quick proof-of-concept by adding the code below to the FiddlerScript OnBeforeResponse handler. After saving the change, loading a page resulted in that page being in the prescribed document mode (below it is IE8).

oSession.utilReplaceInResponse("</title>", "</title><meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\" >");

Note: If you set the Document Mode via the F12 tools, remember that holds for that page until the browser is closed, so if you aren't seeing expected behavior, re-open IE.

Upvotes: 2

Related Questions