简体   繁体   English

如何在Selenium WebDriver中设置可执行IE驱动程序的路径

[英]How to set path for executable IE drivers in Selenium WebDriver

I am trying to run the following code on my machine (win XP & IE8) 我想在我的机器上运行以下代码(win XP&IE8)

public class bookie {                
  private WebDriver driver;        
  private String baseUrl;         
  private boolean acceptNextAlert = true;        
  private StringBuffer verificationErrors = new StringBuffer();        

  @Before    
  public void setUp() throws Exception {    
    DesiredCapabilities caps = DesiredCapabilities.internetExplorer();    
    caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);    
    driver = new InternetExplorerDriver(caps);     
    baseUrl = "http://book.theautomatedtester.co.uk/";     
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);    
  }

  @Test     
  public void testbookie() throws Exception {    
    System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");    
    driver.get(baseUrl + "/");    
    driver.findElement(By.linkText("Chapter1")).click();    
    driver.findElement(By.id("radiobutton")).click();    
    new Select(driver.findElement(By.id("selecttype"))).selectByVisibleText("Selenium Core");    
    driver.findElement(By.linkText("Home Page")).click();     
    driver.findElement(By.linkText("Chapter2")).click();    
    driver.findElement(By.id("but1")).click();     
    driver.findElement(By.xpath("//input[@value='Sibling Button']")).click();     
    driver.findElement(By.linkText("Index")).click();      
    driver.findElement(By.linkText("Chapter1")).click();     
    new Select(driver.findElement(By.id("selecttype"))).selectByVisibleText("Selenium Grid");     
    driver.findElement(By.linkText("Home Page")).click();      
    driver.quit();
  }

But the stack trace which i was provided is 但我提供的堆栈跟踪是

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.ie.driver system property; java.lang.IllegalStateException:驱动程序可执行文件的路径必须由webdriver.ie.driver系统属性设置; at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105) at org.openqa.selenium.ie.InternetExplorerDriverService.access$1(InternetExplorerDriverService.java:1) at org.openqa.selenium.ie.InternetExplorerDriverService$Builder.build(InternetExplorerDriverService.java:230) at org.openqa.selenium.ie.InternetExplorerDriver.setupService(InternetExplorerDriver.java:263) at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:182) at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:159) at bookie.setUp(bookie.java:19) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCa 在Org.openqa.selenium.ie上的org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:105)org.openqa.selenium.ie.InternetExplorerDriverService.access $ 1(InternetExplorerDriverService.java:1)。 InternetExplorerDriverService $ Builder.build(InternetExplorerDriverService.java:230)位于org.openqa.selenium.ie.InternetExplorerDriver.setupService(InternetExplorerDriver.java:263)org.openqa.selenium.ie.InternetExplorerDriver。(InternetExplorerDriver.java:182)at at org.openqa.selenium.ie.InternetExplorerDriver。(InternetExplorerDriver.java:159)at bookie.setUp(bookie.java:19)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown)来自org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:47)atg的java.lang.reflect.Method.invoke(未知来源)的sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) .junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCa llable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclips llable.java:12)org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)atg.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)org.junit .internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70 )org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:238)at org.junit.runners.ParentRunner $ 1.schedule(ParentRunner。 java:63)org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)org.junit.runners.ParentRunner.access $ 000(ParentRunner.java:53)at org.junit.runners.ParentRunner $ 2.evaluate (ParentRunner.java:229)org.junit.runners.ParentRunner.run(ParentRunner.java:309)org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)at org。文摘 e.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) e.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)位于org.eclipse.jdt的org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)。在org.eclipse.jdt.internal.junit的org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)的internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)。 runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Place the driver in some location like C:\\Selenium\\iexploredriver.exe 将驱动程序放在某个位置,如C:\\ Selenium \\ iexploredriver.exe

Then 然后

File file = new File("C:/Selenium/iexploredriver.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();

Below line should be first line of setUp() function 下面的行应该是setUp()函数的第一行

System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");   

Similar to the above solution but with Desired Capabilities 与上述解决方案类似,但具有所需功能

System.setProperty("webdriver.ie.driver","C:\\IEDriverServer.exe");
DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);  //If IE fail to work, please remove this and remove enable protected mode for all the 4 zones from Internet options
WebDriver driver = new InternetExplorerDriver(dc);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何设置可执行IE 11驱动程序的路径 - how to set path for executable IE 11 drivers Selenium WebDriver 2.53 - 设置Firefox可执行文件路径 - Selenium WebDriver 2.53 - set Firefox executable path Selenium webdriver:多个驱动程序 - Selenium webdriver : Multiple drivers 错误:驱动程序可执行文件的路径必须由webdriver.ie.driver系统属性设置 - Error: he path to the driver executable must be set by the webdriver.ie.driver system property Selenium with Java、IntelliJ 和 Gradle - 驱动程序可执行文件的路径必须由 webdriver.gecko.driver 系统属性设置 - Selenium with Java, IntelliJ and Gradle - The path to the driver executable must be set by the webdriver.gecko.driver system property 带有 Chrome 驱动程序的 Selenium 网格(WebDriverException:驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置) - Selenium grid with Chrome driver (WebDriverException: The path to the driver executable must be set by the webdriver.chrome.driver system property) 使用 Java 的 Selenium - 驱动程序可执行文件的路径必须由 webdriver.gecko.driver 系统属性设置 - Selenium using Java - The path to the driver executable must be set by the webdriver.gecko.driver system property org.openqa.selenium.WebDriverException:必须通过webdriver.gecko.driver系统属性设置驱动程序可执行文件的路径; - org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.gecko.driver system property; IllegalStateException:必须通过webdriver.gecko.driver系统属性设置驱动程序可执行文件的路径; (硒) - IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; (Selenium) Selenium:-java.lang.IllegalStateException: 驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置 - Selenium:-java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM