I am New To MAVEN in Selenium Eclipse so getting Below issue when I am running the Program

38 views Asked by At

I am Getting below error when I run testng.xml with testNg Suite and this is the MAVEN Project as when I run with help of POM.xml it runs but doesn't launch the Browser and when i run with help of testng.xml it gives the below error.

org.testng.TestNGException: 
Cannot instantiate class mavenpackage.LoginNCPDPApplication
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:40)
    at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:377)
    at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:290)
    at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:125)
    at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:190)
    at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:130)
    at org.testng.TestRunner.initMethods(TestRunner.java:424)
    at org.testng.TestRunner.init(TestRunner.java:247)
    at org.testng.TestRunner.init(TestRunner.java:217)
    at org.testng.TestRunner.<init>(TestRunner.java:169)
    at org.testng.remote.support.RemoteTestNG6_9_10$1.newTestRunner(RemoteTestNG6_9_10.java:28)
    at org.testng.remote.support.RemoteTestNG6_9_10$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_9_10.java:61)
    at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:594)
    at org.testng.SuiteRunner.init(SuiteRunner.java:168)
    at org.testng.SuiteRunner.<init>(SuiteRunner.java:117)
    at org.testng.TestNG.createSuiteRunner(TestNG.java:1319)
    at org.testng.TestNG.createSuiteRunners(TestNG.java:1306)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1160)
    at org.testng.TestNG.run(TestNG.java:1064)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:152)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:57)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
    ... 21 more
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
    at com.google.common.base.Preconditions.checkState(Preconditions.java:754)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
    at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
    at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:115)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:329)
    at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:103)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
    at mavenpackage.LoginNCPDPApplication.<init>(LoginNCPDPApplication.java:16)
    ... 26 more
    enter code here
1

There are 1 answers

0
Hezi Israeli On

I think that maven is not the issue here. see your exception :

The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases

somewhere in your code, before init the driver you should do (JAVA)

System.setProperty("webdriver.gecko.driver", "path/to/geckodriver.exe");