cannot figure out how to debug the error. i am using java 8,eclipse ,selenium 3 and writing testNG

334 views
Skip to first unread message

vinayak hurkadli

unread,
Apr 20, 2017, 9:08:06 AM4/20/17
to testng-users
java-eclipse-testNG code is below

package testNG_tutorial;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

public class myapplication {
System.setProperty("webdriver.gecko.driver","C:\\SeleniumGecko\\geckodriver.exe");
//System.setProperty("webdriver.gecko.driver","C:\\SeleniumGecko\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
@Test
public void startApp()
{
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS );
String currentURL=driver.getCurrentUrl();
Assert.assertTrue(currentURL.contains("auth/login"));
}
@Test(dependsOnMethods="startApp")
public void loginApp()
{
driver.findElement(By.xpath(".//*[@id='divUsername']/span")).sendKeys("Admin");
driver.findElement(By.xpath(".//*[@id='divPassword']/span")).sendKeys("admin");
driver.findElement(By.xpath(".//*[@id='btnLogin']")).click();
boolean status=driver.findElement(By.xpath(".//*[@id='menu_admin_viewAdminModule']/b")).isDisplayed();
  Assert.assertTrue(status);
}
@Test(dependsOnMethods="loginApp")
public void logoutApp()
{
driver.findElement(By.xpath(".//*[@id='welcome']")).click();
driver.findElement(By.xpath("//a[text()='Logout']")).click();
Assert.assertTrue(driver.findElement(By.xpath(".//*[@id='txtUsername']")).isDisplayed());
}
}
===============================
the stracktrace for the above code is below
============================================
org.testng.TestNGException: 
Cannot instantiate class testNG_tutorial.myapplication
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:31)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:410)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:323)
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:99)
at org.testng.TestClass.initTestClassesAndInstances(TestClass.java:85)
at org.testng.TestClass.init(TestClass.java:77)
at org.testng.TestClass.<init>(TestClass.java:42)
at org.testng.TestRunner.initMethods(TestRunner.java:423)
at org.testng.TestRunner.init(TestRunner.java:250)
at org.testng.TestRunner.init(TestRunner.java:220)
at org.testng.TestRunner.<init>(TestRunner.java:169)
at org.testng.remote.support.RemoteTestNG6_10$1.newTestRunner(RemoteTestNG6_10.java:28)
at org.testng.remote.support.RemoteTestNG6_10$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_10.java:61)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:616)
at org.testng.SuiteRunner.init(SuiteRunner.java:185)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:131)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1383)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1363)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1217)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
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:23)
... 25 more
Caused by: java.lang.Error: Unresolved compilation problems: 
Syntax error on token ".", @ expected after this token
Syntax error on token ",", < expected
Syntax error, insert "SimpleName" to complete QualifiedName
Syntax error, insert "Identifier (" to complete MethodHeaderName
Syntax error, insert ")" to complete MethodDeclaration

at testNG_tutorial.myapplication.<init>(myapplication.java:13)
... 30 more
=============================================================

Reply all
Reply to author
Forward
0 new messages