Driver executable must be set by the webdriver.ie.driver system property

后端 未结 5 1202
天命终不由人
天命终不由人 2020-11-28 05:09

I am using Selenium for automating the tests. My application exclusively uses IE, it will not work on other Browsers.

Code:

import org.openqa.seleniu         


        
相关标签:
5条回答
  • 2020-11-28 05:51

    The error message says

    "The path to the driver executable must be set by the webdriver.ie.driver system property;"

    You are setting the path for the Chrome Driver with "webdriver.chrome.driver" property. You are not setting the file location when for InternetExplorerDriver, to do that you must set "webdriver.ie.driver" property.

    You can set these properties in your shell, via maven, or your IDE with the -DpropertyName=Value

    -Dwebdriver.ie.driver="C:/.../IEDriverServer.exe" 
    

    You need to use quotes because of spaces or slashes in your path on windows machines, or alternatively reverse the slashes other wise they are the string string escape prefix.

    You could also use

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

    inside your code.

    0 讨论(0)
  • 2020-11-28 05:51

    I just put the driver files directly into my project to not get any dependency to my local machine.

    final File file = new File("driver/chromedriver_2_22_mac");
    System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
    
    driver = new ChromeDriver();
    
    0 讨论(0)
  • 2020-11-28 05:55

    You will need have to download InternetExplorer driver executable on your system, download it from the source (http://code.google.com/p/selenium/downloads/list) after download unzip it and put on the place of somewhere in your computer. In my example, I will place it to D:\iexploredriver.exe

    Then you have write below code in your eclipse main class

       System.setProperty("webdriver.ie.driver", "D:/iexploredriver.exe");
       WebDriver driver = new InternetExplorerDriver();
    
    0 讨论(0)
  • 2020-11-28 05:59

    For spring :

    File inputFile = new ClassPathResource("\\chrome\\chromedriver.exe").getFile();
    System.setProperty("webdriver.chrome.driver",inputFile.getCanonicalPath());
    
    0 讨论(0)
  • 2020-11-28 06:00
    1. You will need InternetExplorer driver executable on your system. So download it from the hinted source (http://www.seleniumhq.org/download/) unpack it and place somewhere you can find it. In my example, I will assume you will place it to C:\Selenium\iexploredriver.exe

    2. Then you have to set it up in the system. Here is the Java code pasted from my Selenium project:

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

    Basically, you have to set this property before you initialize driver

    0 讨论(0)
提交回复
热议问题