0

When i am using below code i am getting error : "java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property;"

    import io.github.bonigarcia.wdm.ChromeDriverManager;
    import io.github.bonigarcia.wdm.EdgeDriverManager;
    import io.github.bonigarcia.wdm.FirefoxDriverManager;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeOptions;
    import org.openqa.selenium.edge.EdgeDriver;
    import org.openqa.selenium.edge.EdgeOptions;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.firefox.FirefoxOptions;

    public enum  InitialDrivers {
        INSTANCE;
        public static InitialDrivers getInstance()
        {
            return INSTANCE;
        }

        public static WebDriver driver = null;
        public void selectDriver() {
            Drivers driverName = Drivers.valueOf(readXML("baseData","driver"));
            switch (driverName) 
                case Chrome: {
                    ChromeDriverManager.getInstance().setup(); 
                    ChromeOptions options = new ChromeOptions();
                    options.setCapability("browserName","chrome");
                    driver = new ChromeDriver(options);
                    break;
                }
                case Firefox: {
                    FirefoxDriverManager.getInstance().setup(); 
                    FirefoxOptions options = new FirefoxOptions();
                    options.setCapability("marionette", true);
                    driver = new FirefoxDriver(options);
                    break;
                }

                case Edge: {
                    EdgeDriverManager.getInstance().setup(); 
                    EdgeOptions options = new EdgeOptions();
                    options.setCapability("browserName", "MicrosoftEdge");
                    driver = new EdgeDriver(options);
                    break;
                }
            }
      }

    public enum Drivers {Chrome, Firefox, Edge}
}

I'am using this dependency:

<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>2.1.0</version>

This code works well on one machine, but fails on another. Help me to solve this issue, thanks

  • Can you share the code in which you use this enum? Can you provide more details about the machine in which is failing? (I mean... is always failing in the second machine? What is the difference to the first one?) – Boni García Mar 06 '18 at 12:03
  • enum is used in XML file , example ` Chrome` So, if XML tag contains Chrome , chromedriver will run. Both machines have Win10 , the difference is that second one is notebook and it is new, maybe it doesn’t have some drivers – Kolia Kulka Mar 06 '18 at 12:15
  • Are you using TestNG? The piece of XML you provide is not enough to reproduce the problem. And again: Is always failing in your second machine or is it intermittent? – Boni García Mar 06 '18 at 13:26
  • Yes, TestNG, and yes always failing on second machine – Kolia Kulka Mar 06 '18 at 13:30
  • The only way to find the issue is to reproduce it. If you don't provide the full example (complete XML config, tests, etc) it is impossible to find the problem. – Boni García Mar 06 '18 at 13:34
  • XML : Chrome – Kolia Kulka Mar 06 '18 at 15:19
  • It just takes name "Chrome" or other browser from XML file, and according to it run mothod selectDriver() that I discriberd in question, and webdriver should run (and it run but not on my second computer HP ProBook 450 G4, Win10) – Kolia Kulka Mar 06 '18 at 15:33

0 Answers0