Firefox配置文件首选项与Chrome选项vs IE所需的功能 [英] Firefox profile preferences vs Chrome options vs IE desired capabilities

查看:219
本文介绍了Firefox配置文件首选项与Chrome选项vs IE所需的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>


  • 不同的浏览器甚至浏览器版本都支持不同的功能集。有些人甚至缺乏共同的东西。其中一些功能被硒覆盖,以便提供基本的功能。这个例子会比较老,IE不支持xPath,Selenium必须模拟这个行为。 你不能假设它增加了每个浏览器的每一个怪癖的行为来创建一个共同的平台(这将是一个邪恶的问题)。



    我建议你阅读邪恶的问题:解决邪恶问题的策略

    知道如何在Firefox中禁用缓存,怎样才能知道如何在...?



    <要在chrome中做同样的事情,你可以使用 - disable-application-cache 参数运行chrome驱动程序。要查看您当前的Chrome可以设置的标志,您可以浏览到chrome内的 chrome:// flags / 。另一种方法是查找可用的

    IE的另一个名字是怪癖的母亲。这是你需要做研究的地方。一种方法是调用 RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess nr



    其中 nr 标志栏




    • 255(删除所有记录)
    • 2
    • (仅删除Cookies)

    • 8(仅删除临时Internet
      文件)

    • 16(仅删除表单数据)

    • 32(仅删除密码历史记录)



    此源声称截至2013年5月,IE可能有 desiredCapabilities.ensureCleanSession 来清除缓存,但是我还没有测试过它。


    I've seen (and actually answered) several selenium-specific questions where there is a need to set some particular browser preference to change it's behavior, for example:

    In other words, there are tons of questions which can be grouped in two types:

    • I know how to set this preference in browser X, how to do the same in browser Y?
    • How to make browser X, Y and Z do something by configuring their preferences?

    This is usually done via setting/configuring:

    • FirefoxProfile for Firefox
    • ChromeOptions for Chrome
    • DesiredCapabilities for Internet Explorer

    What is a preferred and most efficient strategy to find browser-specific solutions for a particular problem? Is there a mapping between preferences across major browsers?

    For example, I've found out that to disable cache in Firefox, I can set browser.cache.disk.enable, browser.cache.memory.enable, browser.cache.offline.enable and network.http.use-cache preferences to false. How can I know how to do the same in Chrome and IE?

    解决方案

    To highlight what I mean will crunch down Wikipedia article to 1 sentence :

    Selenium WebDriver ... is implemented through a browser-specific browser driver, which ... aims to provide a basic set of building blocks from which developers can create their own Domain Specific Language.

    What is a preferred and most efficient strategy to find browser-specific solutions for a particular problem?

    Rather try to think it this way: If particular browser implements a feature then there is a good chance that selenium driver exposes it. You know if feature is implemented if you can solve it manually.

    I decently effective problem solving algorithm for you: CS || RTM || UTSL

    1. [CS] Can you solve problem manually? Try to use same steps.
    2. [RTM] Can you find the manual or example? Chances are that others have solved you problem.
    3. [UTSL] If common sense and RTM did not work, then
      • Manual can tell you how stuff should work.
      • Source can tell you how stuff does work.

    Image is from Jeff Atwood blog post.

    Is there a mapping between preferences across major browsers?

    No, preferences are not consolidated across drivers. Drivers have their specifics and tradeoffs.

    Different browsers or even browser versions support different sets of capabilities. Some of them lack even common things. Some of those features are covered by selenium in order for it to provide basic functionality that it has. Example of this would be older IE does not support xPath and Selenium has to simulate this behavior. You can not make assumption it adds behavior to take account for every quirk in every browser to create a common platform (that would be a wicked problem).

    I suggest you read Wicked problem : Strategies to tackle wicked problems.

    Knowing how to disable cache in Firefox, how can I know how to do the same in ...?

    To do same in chrome you could run chrome driver with --disable-application-cache argument. To see what flags your current Chrome can set you can browse to chrome://flags/ inside chrome. Alternative way would be to look up available source.

    Alternative name for IE would be mother lode of quirks. This is where you need to do research. One way would be to call RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess nr

    Where nr is flag field:

    • 255 (Deletes ALL History)
    • 1 (Deletes History Only)
    • 2 (Deletes Cookies Only)
    • 8 (Deletes Temporary Internet Files Only)
    • 16 (Deletes Form Data Only)
    • 32 (Deletes Password History Only)

    This source claims that as of May 2013 IE might have desiredCapabilities.ensureCleanSession to clear cache, however I have not tested it.

    这篇关于Firefox配置文件首选项与Chrome选项vs IE所需的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆