18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Exception is displayed even when control exists
Hi,
I am using the following script to fill in a text box, press enter(return) key and then find a link on the resulting page.
_setValue(_textbox(1),"Some Text");
_keyPress(_textbox(1),13);
_isVisible(_link("More"));
On executing the code using the controller, false is returned even when the link is present, executing the same code from that page results in appropriate results.
I am facing the same problem when i use sahi java api. I get a NullPointerException.
Any workarounds ?
I am using the following script to fill in a text box, press enter(return) key and then find a link on the resulting page.
_setValue(_textbox(1),"Some Text");
_keyPress(_textbox(1),13);
_isVisible(_link("More"));
On executing the code using the controller, false is returned even when the link is present, executing the same code from that page results in appropriate results.
I am facing the same problem when i use sahi java api. I get a NullPointerException.
Any workarounds ?
This discussion has been closed.
Comments
Use the "Evaluate Expression" box to execute individual steps rather than multiple steps.
In your code snippet, you should be asserting for isVisible.
"I am facing the same problem when i use sahi java api. I get a NullPointerException."
Please elaborate with code.
Regards,
Narayan
But using that in my java code:
browser.wait(5000) or even browser.execute("_sahi._wait('5000')")
sahi does not wait. but immediately exits with failed assertion.
Ref : "I am facing the same problem when i use sahi java api. I get a NullPointerException."
The Java code that I am using is:
browser.textbox(1).setValue("Some Text");
browser.execute("_sahi._keyPress("+browser.textbox(1)+",13);");
assertTrue(browser.link(More).isVisible());
The exception on the third line is:
java.lang.NullPointerException
at WebBPAInterfaces.Home.FavouriteInterface.markAsFavourite(FavouriteInterface.java:17)
at WebBPAInterfaces.Home.FavouriteInterface.markAsFavourite(FavouriteInterface.java:46)
at WebBPAInterfaces.Home.ArchiveInterface.prepareArchiveProcess(ArchiveInterface.java:53)
at WebBPATests.ProcessModel.ArchiveProcessModel_tp.init(ArchiveProcessModel_tp.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:398)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:82)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:166)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:103)
at org.testng.TestRunner.runWorkers(TestRunner.java:689)
at org.testng.TestRunner.privateRun(TestRunner.java:566)
at org.testng.TestRunner.run(TestRunner.java:466)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:301)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:296)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:276)
at org.testng.SuiteRunner.run(SuiteRunner.java:191)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:808)
at org.testng.TestNG.runSuitesLocally(TestNG.java:776)
at org.testng.TestNG.run(TestNG.java:701)
at org.testng.TestNG.privateMain(TestNG.java:840)
at org.testng.TestNG.main(TestNG.java:818)
browser.waitFor(5000)
You are using Object.wait which is not what we want.
I am not sure why it is failing. Is the page loaded properly for the assertion to be true? Is the page loading slowly?
Regards,
Narayan
The page loads properly, everything is fine. And now the code runs fine.
Thanks for the help.
Regards,
Ajay