zoukankan      html  css  js  c++  java
  • [Selenium] 应对使用 Internet Explorer Driver 多个实例时的 cookie 共享问题

    在使用 IEDriverServer 可执行文件时,从理论上来说是可通过它来创建并使用多个同时存在的 Internet Explorer Driver 实例的。但在实际使用过程中,总是会碰到与 cookie 相关的问题、窗口焦点的问题、浏览器多实例等可能会面临的问题。如果真想希望使用 Internet Explorer Driver 的多个实例并且尽可能的避免前述可能遇到的问题,建议考虑 RemoteWebDriver 的方式,并通过多台虚拟机来隔离干扰

      有一种解决方案来应对使用 Internet Explorer Driver 多个实例时的 cookie 共享问题,即在Internet Explorer 启动时先清理回话中的脏数据。可通过将 IE_ENSURE_CLEAN_SESION 参数传递给 Internet Explorer Driver 并在此模式下启动 Internet Explorer Driver 来达到目的,代码如下

    pachage com.learningselenium.simplewebdriver;

    import org.openqa.selenium.*;

    import org.openqa.selenium.ie.InternetExplorerDriver;

    import org.openqa.selenium.remote.DesiredCapabilities;

    public class testInternetExplorerDriver{

      public static void main(String[] args){

        System.setProperty("webdriver.ie.driver", "D:DriverIEDriverServer_ Win32_ 2.37.0_latestIEDriverServer.exe");

        //设置DesiredCapabilities 的属性包含IE_ENSURE_CLEAN_SESSION 以确保在浏览器实例启动之前清理会话的脏数据

        DesiredCapabilities capab = DesiredCapabilities.internetExplorer();

        capab.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true); 

        Webdriver driver = new InternetExplorerDriver(capab);

        driver.get("http://www.baidu.com");

      }

    }

  • 相关阅读:
    rabbitmq发送消息的两种格式:发送json数据和直接发送对象以及对json与对象之间的相互转换
    rabbitmq 的hello world程序
    rabbitmq用户管理、角色、权限管理以及UI管理界面的使用
    redis设置密码以及安装到服务
    mybatis- generator自动生成代码
    COGS 有标号的二分图计数系列
    Codeforces183D T-shirt
    bzoj3473 字符串
    51Nod1782 圣诞树
    51Nod1601 完全图的最小生成树计数
  • 原文地址:https://www.cnblogs.com/feifeidxl/p/4549192.html
Copyright © 2011-2022 走看看