power_settings_new

org.testng.TestNGException: [closed]

by (391 points)
+1 vote
637 views
Cannot instantiate class testCases.LoginPage
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:40)
    at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:373)
    at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:285)
    at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:126)
    at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:191)
    at org.testng.TestClass.getInstances(TestClass.java:104)
    at org.testng.TestClass.initTestClassesAndInstances(TestClass.java:90)
    at org.testng.TestClass.init(TestClass.java:82)
    at org.testng.TestClass.<init>(TestClass.java:45)
    at org.testng.TestRunner.initMethods(TestRunner.java:422)
    at org.testng.TestRunner.init(TestRunner.java:252)
    at org.testng.TestRunner.init(TestRunner.java:222)
    at org.testng.TestRunner.<init>(TestRunner.java:171)
    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:604)
    at org.testng.SuiteRunner.init(SuiteRunner.java:170)
    at org.testng.SuiteRunner.<init>(SuiteRunner.java:117)
    at org.testng.TestNG.createSuiteRunner(TestNG.java:1359)
    at org.testng.TestNG.createSuiteRunners(TestNG.java:1346)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1200)
    at org.testng.TestNG.runSuites(TestNG.java:1124)
    at org.testng.TestNG.run(TestNG.java:1096)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
    ... 25 more
Caused by: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
    at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
    at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:120)
    at testCases.LoginPage.<init>(LoginPage.java:22)
    ... 30 more

1 Answer

by (171 points)
0 votes

Above question is already answered here.

 

http://mayurshah.in/87/i-am-getting-error-while-setting-chrome-in-selenium-grid-2?show=89#a89

 

1. You will need Chrome driver executable on your system. So download it from (http://www.seleniumhq.org/download/) unzip it somewere in your system. I will assume you will place it to C:\chromedriver.exe
 
2. Then you have to set it up in the system properties. Here is the Java code pasted from my Selenium project:
File file = new File("C:/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
WebDriver driver = new ChromeDriver();
 
Basically, you have to set this property before you initialize driver
 
Hope that helps
add
...