zoukankan      html  css  js  c++  java
  • [Selenium] 如何使 InternetExplorerDriver 每次启动的端口不会随机变化

    InternetExplorerDriver 在不指定任何参数的情况下,启动监听端口会随机变化。如果需要保证其端口固定不变,可通过InternetExplorerDriverService 达到目的。示例代码:

    public class testInternetExplorerService{

      public static void main(String[] args){

        System.setProperty("webdriver.ie.driver", "D:DriverIEDriverServer_Win32_2.37.0_latestIEDriverServer.exe");

        

        InternetExplorerDriverService.Builder builder = new InternetExplorerDriverService.Builder();

        InternetExplorerDriverService internetExplorerService = builder.usingPort(5678).withHost("127.0.0.1").build();

        DesiredCapabilities capab = DesiredCapabilities.internetExplorer();

        capab.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);

        capab.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

        WebDriver driver = new InternetExplorerDriver(internetExplorerService, capab);

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

      }

    }

  • 相关阅读:
    LeetCode 43 字符串相乘
    HDU 1031 Design T-Shirt
    HDU 1728 逃离迷宫
    HDU 1285 确定比赛名次
    HDU 1116 Plays on words
    HDU 1195 Open the lock
    HDU 1072 Nightmare
    HDU 1272 小希的迷宫
    HDU 1273 漫步森林
    HDU 1269 迷宫城堡
  • 原文地址:https://www.cnblogs.com/feifeidxl/p/4551381.html
Copyright © 2011-2022 走看看