Axe Test Automation PlatformGeneral discussion relating to the Axe Test Automation Platform from Odin Technology |
||
Posts by Odin employees marked:
|
Hi
I have re-used your MyObjectExists function from the lib folder of the Odin Sample project. We have a couple of custom functions written into _testSuffix of the SeleniumJava.ActionMap and I placed your code there: public static String MyObjectExists(Default selenium, String locator) { String value = new Boolean(selenium.isElementPresent(locator)).toString(); value = value.substring(0, 1).toUpperCase() + value.substring(1).toLowerCase(); return value; } I have also put a val.ObjectExists action into the Java.ActionMap file as follows: action = val.ObjectExists command = Dispatch.put(axe,"ResultCode", Dispatch.call(axe,"StepValidateEqual","%DATA%",MyObjectExists(Dispatch.get(axe,"Value").getString()))) However, on trying to use the function, AXE returns an error on build: TEST:java:71:MyObjectExists(com.thoughtworks.selenium.DefaultSelenium,java.lang.String) in TEST cannot be applied to (java.lang.String) Dispatch.put(axe,"ResultCode", Dispatch.call(axe,"StepValidateEqual","%DATA%",MyObjectExists(Dispatch.get(axe,"Value").getString()))) Is there anything obvious that you can see I am doing wrong? Many thanks Mark
Hi Mark,
Glad you have solved it. A couple of points to add though: 1. The get.exists example in OdinPortal is more complex than needed, as it is used as a way to demonstrate how a full custom method is added. You can actually achieve the same result with a single line custom action without a custom function/method. 2. There is no need for a custom val.objectexists function. Infact, it is very rare to ever need a custom 'val' action. The 'get' does the work retrieving the value from the system-under-test (SUT). The val should not really interact with the SUT and is normally just a straight text comparison. Sam
Thanks Sam, yes, having looked at it the get is much more obvious.
One question that I couldn't find covered in the help section for AXE with Selenium is the importing of custom libraries. As mentioned above, I have added code to the test_Suffix action in the SeleniumJava.ActionMap - if I wanted to pull the code out of there and add to the lib folder, how would I then go about importing it via the ActionMap? Also, would it need to be a .jar file or would .java be sufficient? Many thanks
Hi Mark,
For Java, look in the section 'Adding additional references' under 'Axe Java Scripting'. Also see the OdinPortal sample (OdinPortal.jar). This is much cleaner than putting a lot of code in the ActionMap. My general rule-of-thumb is that if is more than 3 lines of code, stick it in an external library. Sam
Thanks Sam
I have the file as a .java file at the moment, however converting this into a .jar file and setting the package name are a bit confusing for me as I do not have a great deal of Eclipse knowledge - I realise this is outside of the scope of AXE, therefore I will probably leave the code in the ActionMap for now Thanks Mark
Hi Mark,
Its actually pretty easy and you dont have to do it from Eclipse. e.g. here is a sample 2-line batch file for creating the OdinPortal.jar: javac -classpath "<PATH>\selenium-java-client-driver-1.0.1\selenium-java-client-driver.jar;<PATH>\Axe.jar" -d <PATH>\odinportal\lib OdinPortal\OdinPortalLib.java jar cf OdinPortal.jar OdinPortal Sam
Thanks Sam
The batch file did not work so I ran the first command through cmd prompt and am receiving a "javac: file not found: CustomLib.java" error. Note that I also tried with the OdinPortal java file to make sure it was not something specific to my project and received the same error
Did you change all the <PATH> vars to your local environment? If you email or post your batch file I will check for any obvious errors.
Sam
Thanks Sam
This is the content of the .bat file: javac -classpath "C:\Program Files\selenium-remote-control-1.0.3\selenium-java-2.0b3\selenium-java-2.0b3.jar;C:\Program Files\Odin Technology\Axe\Axe.jar" -d C:\LRS\lib CustomLib.java jar cf CustomLib.jar CustomLib Thanks Mark |