Highlighted
Micro Focus Expert
Micro Focus Expert
425 views

<(UFT) support tip>Taking advantage of IE 11 Emulation options from UFT

Most of our large organizations are upgrading Internet Explorer (IE) to version 11 (if they haven’t done so already) because of its improved security, new technologies support, better performance, and, of course, because older versions are getting out of support on January next year.

The thing is that many of our internal/external web applications aren’t prepared for this change yet and this ends up with multiple application issues when they are rendered with the latest version. Here is where the great backward compatibility of IE 11 comes into play. It offers high-fidelity emulation for older versions of Internet Explorer, so that, we can upgrade to Internet Explorer 11 more quickly and easily.

Now, from testers point of view, isn't it awesome that we can manipulate the different emulation modes that IE 11 offers so we can run our scripts using the settings that better suit our testing needs? We can find more information about the emulation options in this link.

 

All those settings shown in the image above, are saved in JSON format in a file named settings.json which can be found under “%localappdata%\Microsoft\F12\emulation”. This means that we can modify such settings prior to opening IE from our script (note: if your IE F12 settings look different and you’re unable to find setting.json file, you probably have one of the initial IE 11 versions. Try after installing the most recent IE 11 updates)

Let’s say we have as requirement to run our script using different combinations of Document Mode and Browser Profile. Now, in order for the changes made to settings.json file to take effect next time we open IE 11, we also need to set the shouldPersistSettings as well. Here is a sample script on how to do it (feel free to modify it if you require playing around with other options as well):

Public Function ModifyIESettings(shouldPersistSettings, documentMode, browserProfile)
    ModifyIESettings = "{""0"":{""EmulationSettings.json"":{""shouldPersistSettings"":" + shouldPersistSettings + "," & _
    """documentMode"":""" + documentMode + """,""browserMode"":""" + browserProfile + """,""orientation"":""Landscape""," & _
    """userAgentString"":"""",""resolution"":null,""geolocationState"":""Off"",""geolocation"":{""latitude"":null,""longitude"":null}}},""1"":{}}"
End Function

public sub WriteNewIESettings(NewfileContents, path)
    Dim fso, file
    Set fso = createobject("Scripting.FileSystemObject")
    Set file = fso.OpenTextFile(path, 2)
    file.WriteLine NewfileContents
    file.Close
End sub

IEEmulationSettingsFilePath = createobject("Wscript.Shell").ExpandEnvironmentStrings("%LOCALAPPDATA%") + "\Microsoft\F12\emulation\settings.json"
WriteNewIESettings ModifyIESettings("true","9","Desktop") ,IEEmulationSettingsFilePath

SystemUtil.Run "iexplore.exe""www.hpe.com"

After this, if we open Developer Tools (F12), we can confirm that IE is launched with the settings used from our script:

 

Alvaro

HPE support

If you find this useful, mark Kudos.

Note: the opinions expressed in my post are mine alone, and do not reflect the opinions of my employer. No warranties express or implied for any answered posted.

 

Labels (1)
0 Replies
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.