views:

40

answers:

2

Hi,

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?

THanks @!

A: 

You'd trigger jquery the same way you'd trigger some java script you'd inject. Try this how-to: http://seleniumhq.org/docs/05_selenium_rc.html#learning-the-api

ascarb
A: 

Since you said that you didn't have an ID but a class:

(only class-ID provided)

...a better answer is likely to use the CSS locator strategy which is already baked-in to Selenium where you can select an element based on a css class or simply by using CSS selector logic (for at least css2 and css3)

So to select an element (div, span whatever) that has a specific class you can simply use this for the Selenium locator:

css=.class-ID

You can even use more complicated selectors that are similar to those available in JQuery such as:

css=#myDiv .class-ID

This will search for the element with a css style of class-ID within the element with an ID = myDiv.

Jay Stevens