Calling custom Java code
TypeError: Cannot call property … in object
Section titled “TypeError: Cannot call property … in object”Symptom: I’m trying to use java functions from sahi but I get the following error. TypeError: Cannot call property getCount in object [JavaPackage com.test.MyUtils]. It is not a function, it is “object”.
Cause: The error message is not very intuitive, but what this means is that MyUtils is not available in the classpath. This is essentially a classpath problem.
Resolution: As mentioned above, MyUtils.class is not available in the classpath.
- Ensure that your jar contains the MyUtils.class with the correct package heirarchy. You can use Export | Java | Jar facility from Eclipse to build your jar file. It will automatically create the correct package heirarchy.
- Kindly refer to this section for details on how to add custom jars to the Sahi classpath. Ensure that you have copied the jar to the correct location.
Unable to View Test Run Reports
Section titled “Unable to View Test Run Reports”Symptom: Test run reports are not visible on adding Apache Xalan library externally to userdata/extlib/ folder.
Cause: Apache Xalan library may affect the functioning of Sahi’s code to display report.
Resolution: To fix this, add below property line in sahi_pro/userdata/config/userdata.properties
sahi.xml_transformer_factory_classname=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
