Using Selenium to Test Internet Explorer in Different Document Modes

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

I searched for a feature request during WebDriver development but didn't see what happened to it.

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

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


source to share

1 answer

Yes, the following is via Selenium, but this is the only way I know right now.

The DocumentMode can be controlled using the title tag meta

on the page. Determining document compatibility AND you can modify the web response before it hits the browser using Fiddler This way you can configure Fiddler to add a meta content tag for each response. I did a quick proof of concept by adding the code below to the FiddlerScript handler OnBeforeResponse

. After saving the change, loading the page caused that page to be in Prescribed Document Mode (below IE8).

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


Note. If you set document mode using the F12 tools, remember what is held for that page until the browser is closed, so if you don't see the expected behavior, re-launch IE.



All Articles