首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >硒互联网络探测驱动程序兼容性模式

硒互联网络探测驱动程序兼容性模式
EN

Stack Overflow用户
提问于 2015-04-24 09:43:34
回答 2查看 1.9K关注 0票数 0

是否有任何方法强制webdriver/internetexplorerdriver在兼容模式下打开站点?每次我通过Nunit运行我的测试时,所有的历史和兼容性模式列表(我之前列出的站点在哪里)都会被清除。

我不能改变网站的代码。我可以添加项目到兼容性模式列表或打开网站的具体版本的IE (我有11,我需要在7打开它与文件类型5)。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-04-25 17:39:24

这是更好的描述我的问题:我需要测试一个网站,我不能编辑。该网站只工作在兼容模式在我的IE 11 (它是为ie 7文档类型5)。我想做测试,饼干应该在那之前清理干净。但是,如果我设置为"EnsureCleanSession = true“,那么除了cookie之外,它还会清除IE中的兼容列表。因为它,它是不可能测试的网站。

我已经找到了可能的解决方案,但我得测试一下.我发现兼容性列表在注册表中,我可以在清除它之前加载它的值,然后再次设置它的值:

代码语言:javascript
复制
        const string keyName = @"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData";     
        var a = Registry.GetValue(keyName, "UserFilter" , "Return this default if NoSuchName does not exist.");
        // value of registry is removed
        Registry.SetValue(keyName, "UserFilter", a);
        Console.ReadLine();

但就像我说的,我不知道它是否能起作用.

更新

好的,它适用于小范围的工作(因为IE必须在注册表更改后重新启动)

代码语言:javascript
复制
    [SetUp]
    public void SetUp()
    {
        //read the compatibility mode list from registry
        const string path = @"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData";
        const string key = "UserFilter";
        var regValue = Registry.GetValue(path, key, "Return this default if NoSuchName does not exist.");

        //run IE driver with cleaning of cookies and history
        var options = new InternetExplorerOptions
        {
            IntroduceInstabilityByIgnoringProtectedModeSettings = true,
            EnsureCleanSession = true
        };
        _driver = new InternetExplorerDriver(IeDriversPath, options);

        //cloase IE
        _driver.Quit();
        _driver.Dispose();

        //put the compatibility mode list back into registry 
        Registry.SetValue(path, key, regValue);

        //run IE driver without cleaning of cookies and history
        options.EnsureCleanSession = false;
        _driver = new InternetExplorerDriver(IeDriversPath, options);
    }
票数 0
EN

Stack Overflow用户

发布于 2015-04-24 13:14:49

不幸的是,除非您更改了源代码,否则不会。作为解决办法,我使用VMS。如果您想使用相同的路由,请考虑使用使用Microsoft的免费VM。见我关于这里问题的另一个答案

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29844094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档