自动化测试 - 如何启动IE driver

1. 在做自动化测试时候,如果想在Win7 上启动IE driver:


可以用如下代码来设置环境变量后启动IE driver:

 System.setProperty("webdriver.ie.driver", "D:\\XXX\\IEDriverServer.exe");
  InternetExplorerDriver ieDriver = new InternetExplorerDriver();
  

或者如下代码来启动并设置IE属性:
  DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
  dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
  InternetExplorerDriver driver = new InternetExplorerDriver();


2. 在启动IE driver的时候,可能会遇到如下错误:

Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 739 milliseconds


3. 如何解决该错误?

1) 运行 regedit.exe

2) 找到 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones

3)可以看到


如果1-4号Key下面都有名叫2500的属性,则将其值改为相同的非零值



你可能感兴趣的:(自动化测试 - 如何启动IE driver)