How to use JQuery in Selenium?
jquery, selenium
Solution
You can try using my selenium lib at github.
It handles almost the entire jquery API minus the functions that use/require handler passing:
HtmlUnitDriver drv = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
drv.setJavascriptEnabled(true);
try {
jQueryFactory jq = new jQueryFactory();
jq.setJs(drv);
drv.get("http://google.com");
jq.query("[name=q]").val("SeleniumJQuery").parents("form:first").submit();
String results = jq.queryUntil("#resultStats:contains(results)").text();
System.out.println(results.split(" ")[1] + " results found!");
} finally {
drv.close();
}
Problem
I would like to use Selenium to click on the tab of a web where the tab was created dynamically using JQuery. There is one problem, since it was created dynamically and the tab got no ID tied to it (only class-ID provided), so I am running out of clue to click on it using Selenium. After googling for 2 weeks, I found out that it could be done using JQuery by injecting JQuery into Selenium and repackaging it so that it support JQuery API. But the problem now is I don't know how to trigger JQuery script in Selenium? Is there any resources out there or guideline on setting up JQuery in Selenium? How am I going to execute JQuery in Selenium?