【问题标题】:How to launch IE browser using selenium webdriver 3.4.0如何使用 selenium webdriver 3.4.0 启动 IE 浏览器
【发布时间】:2017-09-20 10:22:52
【问题描述】:

如何使用 selenium webdriver 3.4.0 启动 IE 浏览器?我试过了,但无法打开IE浏览器。我已经下载了 IE 驱动程序并遵循了启动 firefox 驱动程序的方法。

火狐浏览器启动正常,下面是命令行

System.setProperty("webdriver.gecko.driver","C:\\Users\\vidhya.r\\Desktop\\Automation\\Jars\\geckodriver.exe"); FirefoxOptions options = new FirefoxOptions(); options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); driver = new FirefoxDriver(options);

【问题讨论】:

  • System.setProperty("webdriver.ie.driver", "IE驱动路径"); WebDriver driver = new InternetExplorerDriver();使用这个

标签: selenium webdriver


【解决方案1】:

下载IEDriverServer,放到path或者使用

System.setProperty("webdriver.ie.driver", ieDriverPath);

通过

启动
driver = new InternetExplorerDriver();

【讨论】:

  • 感谢您的回复。我已经尝试了上述方法,但它抛出异常,“java.lang.IllegalsStateException”
  • 我遇到了同样的异常。我忘记从“webdriver.chrome.driver”更改为“webdriver.ie.driver”(以防从 chrome 切换到 ie)
【解决方案2】:
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
capability.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
capability.setCapability(InternetExplorerDriver.ELEMENT_SCROLL_BEHAVIOR, 1); 
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);        

System.setProperty("webdriver.ie.driver", ieDriverPath);
WebDriver driver = new InternetExplorerDriver(capability);

【讨论】:

  • 感谢您的回复。实际上它打开了 2 个 IE 浏览器。在第一页中,它显示为“这是 WebDriver 服务器的初始起始页”。第二页,它正在连接到 url 但没有继续执行代码
  • 确认 IEDriver.exe 与您的 IE 浏览器兼容。无论您的 IE 浏览器是 32/64 位,请使用 IEDriver-32.exe。 64 位 IEDriver 很慢。
【解决方案3】:

首先从Link下载IEDriver

使用这个:

System.setProperty("webdriver.ie.driver", "Path of IE driver");
WebDriver driver = new InternetExplorerDriver();

如果您想添加一些功能,请使用DesiredCapabilities

【讨论】:

  • 设置geckodriver的路径很简单,你可以下载IEdriver并在setproperty()中设置路径并运行
  • 感谢您的回复。上面的方法我都试过了,就是连不上
  • "java.lang.IllegalsStateException" IE 浏览器启动:System.setProperty("webdriver.ie.driver","driver path\\IEDriverServer.exe");WebDriver driver=new InternetExplorerDriver();
  • 请粘贴您提供的存储 IEdriver 的路径
  • System.setProperty("webdriver.ie.driver", "C:\\Users\\vidhya.r\\Desktop\\IEDriverServer.exe"); WebDriver driver=new InternetExplorerDriver();
猜你喜欢
  • 1970-01-01
  • 2016-11-08
  • 1970-01-01
  • 1970-01-01
  • 2021-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多