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.
Sahi not working on more than one javascript function
hi
i have two javascript functions in my code like
browser.setBrowserJS("function input(){var inputFields = new Array();inputFields=document.getElementsByTagName('input');
return inputFields;}"); and second javascript function
browser.setBrowserJS("function div(){ar divFields = new Array();divFields=document.getElementsByTagName('div');
return divFields;}");
System.out.println("value="+ browser.fetch("input()"));
System.out.println("value="+ browser.fetch("div()"));
I can execute the first function , but the call to second function throws error like
error:_sahi.setServerVarPlain('___lastValue___Tue Feb 14 17:45:27 IST 2012', div())
TypeError: Object expected
No trace available
at net.sf.sahi.client.Browser.executeStep(Browser.java:227)
at net.sf.sahi.client.Browser.execute(Browser.java:194)
at net.sf.sahi.client.Browser.fetch(Browser.java:451)
at in.co.sahi.newClass.getAlltextbox(newClass.java:188)
at in.co.sahi.JavaClientTest.testGoogle(JavaClientTest.java:109)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
can anyone help on this issue.
thanks and regards in advance
i have two javascript functions in my code like
browser.setBrowserJS("function input(){var inputFields = new Array();inputFields=document.getElementsByTagName('input');
return inputFields;}"); and second javascript function
browser.setBrowserJS("function div(){ar divFields = new Array();divFields=document.getElementsByTagName('div');
return divFields;}");
System.out.println("value="+ browser.fetch("input()"));
System.out.println("value="+ browser.fetch("div()"));
I can execute the first function , but the call to second function throws error like
error:_sahi.setServerVarPlain('___lastValue___Tue Feb 14 17:45:27 IST 2012', div())
TypeError: Object expected
No trace available
at net.sf.sahi.client.Browser.executeStep(Browser.java:227)
at net.sf.sahi.client.Browser.execute(Browser.java:194)
at net.sf.sahi.client.Browser.fetch(Browser.java:451)
at in.co.sahi.newClass.getAlltextbox(newClass.java:188)
at in.co.sahi.JavaClientTest.testGoogle(JavaClientTest.java:109)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
can anyone help on this issue.
thanks and regards in advance