Test Fails When Using The Validation With Any Type

17 views
Skip to first unread message

Alok Agarwal

unread,
Apr 4, 2019, 4:50:40 AM4/4/19
to Selenium Users
I am not able to get the result pass for validating the element present. I tried with name, xpath, cssselector, text, etc.
Please assist.

Here is the snipped of my code:
public void validateElementPresent() throws InterruptedException {
ext_test.log(Status.INFO, "Validating The Element's Presence.");
Thread.sleep(2500);
//if (!isElementPresent(objectKey)) 
if(!(driver.findElement(By.className(objectKey)).isDisplayed()));
// report a failure
{
reportFailure("This Element is not present on the webpage: " + objectKey);
}
}

Here is the error snippet:
FAILED: dashboardLogin({Username=test1234, Password=test1234, Runmode=Y, Browser=Mozilla})
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.Shree_Automate_Feb2019.driver.driverScript.executeKeywords(driverScript.java:76)
at com.Shree_Automate_Feb2019.suiteA.DashboardLogin.dashboardLogin(DashboardLogin.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.AssertionError: The following asserts failed:
null
at org.testng.asserts.SoftAssert.assertAll(SoftAssert.java:43)
at com.Shree_Automate_Feb2019.keywords.GenericKeywords.reportFailure(GenericKeywords.java:230)
at com.Shree_Automate_Feb2019.keywords.GenericKeywords.validateElementPresent(GenericKeywords.java:139)
... 31 more

Reply all
Reply to author
Forward
0 new messages