It seems to me that you're trying to locate "li" inside wrong container. Of
course i can't see the whole html code, but at first you're checking that
the container exists like this:
ie.div.dl(:id, "container_dl").exists?
And then you're doing like this:
ie.div.li(:id, "firstLink").exists?
I'm not sure that the problem is in this line, but what if you'd try to do
something like this instead:
container = ie.div.dl(:id, "container_dl")
ie.wait_until {container.exists?} # or maybe use #present? instead of
#exists? to make sure that the container is also visible if it should be...
container.li(:id, "firstLink").when_present.click
If that line fails then try to access that li directly, since "id" attribute
*should* be unique within the page anyway:
ie.li(:id, "firstLink").when_present.click
If that fails too then you have frames on the page or the li doesn't have
that id... use something like this for debugging:
puts ie.div(id, "industry").ul.html
Sorry, can't help any more if you don't provide the whole html code and your
Watir code too.
Jarmo
On Sat, Aug 27, 2011 at 6:10 PM, M <[email protected]> wrote:
> Sorry to email you about this issue, I asked the question in Watir
> discussion group but with no help or replies at all.
>
> how do I select li link with id from a jquery dynamic list. Can this be
> done in watir??
> Using Watir 2.0, Ruby 1.8.7:
>
> require "rubygems"
> require "watir"
> require "firewatir"
> ie=Watir::IE.new
>
> I have a dynamic Div that contains
> <div id="industry" class="modal">
> <dl id="SomeID" class="first">
> <dt>someText</dt>
> <dd>
> <ul>
> <li id="someID1">
> <a href="#" class="selected">someText</a>
> <li id="someID2">
> <a href="#">SomeText</a>
>
> This list is in a modal "jquery pop up form". So I want to click on
> any <li>. and after I click on the link, another set of <li>'s will
> appear, that I need to select from as well. So my problem is how to
> select the li even though they are not in the page, because they are
> dynamically generated by the server based on the user click. Also do I
> need to wait for it to load. I am a Watir newbie so please the more
> detail the better.
>
> Here is my current code:
>
> #this will launch the jquery form successfully
> ie.link(:id, "launchIndustry").click_no_wait
>
> #this is the <dl> that contain all the <li>'s
> ie.wait_until {ie.div.dl(:id, "container_dl").exists? }
> puts ie.div.dl(:id, 'container_dl').exists? # good up to here
>
> ie.wait_until {ie.div.li(:id, "firstLink").exists? }
> ie.div(:id => "industry").li(:id => "firstLink").click
>
> The error that I get is:
>
> timed out after 60 seconds, which means that the script can't the
> first li element. Please help, because I have to select these options
> before I can move forward as it's a required field.
>
> Any help is appreciated.
>
> Thanks
>
>
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]