Extending Selenium via –userExtensions argument not working from an ant target ? Need Help?
To be very short and specific , I'm launching the "Selenium Server" from an ant task of my project "build.xml" as follows : -
<target name="startServer">
<java jar="${basedir}/lib/selenium-server.jar" fork="true" spawn="true">
<arg value="-userExtensions"/>
<arg value="${basedir}/lib/user-extensions.js"/>
</java>
</target>
Where开发者_开发问答 as, below is the simple code chunk for my "user-extensions.js" file
Selenium.prototype.doMyMethod = function(locator) { var element = this.page().findElement(locator); element.click(); };
However, when i call this method in my "java driven test case" as follows , it's not working at all :-
Controller.commandProcessor.doCommand("myMethod",new String[] {"btnG"}); //user extension
Where, "commandProcessor" being an instance of "HttpCommandProcessor" as follows and being accessible as public static property within another custom coded java file "Controller" :-
public static HttpCommandProcessor commandProcessor; commandProcessor = new HttpCommandProcessor('localhost', 4444, '*firefox', 'http://www.google.com/');
Moreover, other built-in function calls like "type, getTitle" are working correctly, but this extension part not working properly and giving an error on this line as : -
ERROR: Unknown command: 'myMethod'
com.thoughtworks.selenium.SeleniumException: ERROR: Unknown command: 'myMethod'
Which is clearly an evidence that "user-extension.js" was not added actually !
Is there a way to work around this particular problem when launching selenium from an ant target as above !
Any quick help would be appreciated !
Magically, i got it working, i guess some network problem (internet connectivity) at my end was causing it to fail, I'm not sure upon it, but now it's working perfectly fine. In short, that "user-extension.js" should be in the same directory, where your "selenium-server.jar" is located, and the above way of passing "-userExtensions" via "ant target" is the right perfect way :) !
精彩评论