Thanks Jarmo for the help. This worked. I just had to wait for it.
ie.li(:id => "some_ID").when_present.a.click

On Aug 30, 2:42 am, Jarmo <[email protected]> wrote:
> Yes, but why are you trying to click on a link inside of the button?
> Should't you just click on the button itself? And isn't it already present
> at this stage, e.g. shouldn't ie.button(:src, /btn_continue.png/).click just
> work?
>
> Jarmo
>
> On Tue, Aug 30, 2011 at 1:03 AM, M <[email protected]> wrote:
> > For some reason I was able to click on all the link in the li's fine but
> > when clicking on the button image the
> > ie.button(:src, /btn_continue.png/).when_present.a.click
> > doen't work. Not sure why. I thought that when_present.a.click will ensure
> > that the element is present before clicking on it
>
> > On Mon, Aug 29, 2011 at 11:26 AM, Jarmo <[email protected]> wrote:
>
> >> In great essence it doesn't make a difference, but i prefer Watir::Browser
> >> all the time.
>
> >> Jarmo
>
> >> On Mon, Aug 29, 2011 at 9:23 PM, M <[email protected]> wrote:
>
> >>> Thanks Jarmo,
>
> >>> This worked for me
> >>> ie.li(:id => "industry_Technology_&_Internet").when_present.a.click
> >>> I was doing this before, I didn't add the "a" between present and click
>
> >>> ie.li(:id => "industry_Technology_&_Internet").when_present.click
>
> >>> I really appreciate your help. Sorry for the Novice questions, I am new
> >>> to Watir, But I really like it and I'll update my posts so that everyone 
> >>> who
> >>> is having the same problem knows
>
> >>> Thanks
>
> >>> On Mon, Aug 29, 2011 at 11:08 AM, M <[email protected]> wrote:
>
> >>>> Does it make a difference if I use
>
> >>>> #ie=Watir::IE.new
>
> >>>> instead of
>
> >>>> #ie=Watir::Browser.new
>
> >>>> On Mon, Aug 29, 2011 at 10:55 AM, Jarmo <[email protected]> wrote:
>
> >>>>> I used jQuery to fill these radios at one point:
> >>>>> $("input[type=radio]").attr("checked", "checked") :)
>
> >>>>> But the problem was in the end that you clicked on the "li", but you
> >>>>> had to click on the link inside of the li. This code works for me:
>
> >>>>> require "watir"
> >>>>> b = Watir::Browser.attach :url, //
> >>>>> b.link(:id => "launchIndustry").click
> >>>>> b.li(:id => "industry_Basic_Materials").when_present.a.click
>
> >>>>> Jarmo
>
> >>>>> On Mon, Aug 29, 2011 at 8:51 PM, M <[email protected]> wrote:
>
> >>>>>> Sorry for the long registration...  :) , I normally just tab and enter
> >>>>>> to fill the personality radios...sorry
> >>>>>> all the ul and li are dynamically generated by the server (jquery). so
> >>>>>> they will not be there until the user clicks on the first link, and 
> >>>>>> then the
> >>>>>> next list will appear and the user will choose from it and so on. I'll 
> >>>>>> try
> >>>>>> to add the timing issue and see what happens.
>
> >>>>>> I'll keep you posted.
>
> >>>>>> Thanks
>
> >>>>>> On Mon, Aug 29, 2011 at 10:42 AM, Jarmo <[email protected]> wrote:
>
> >>>>>>> The registration process was too tedious :(
>
> >>>>>>> By looking at you html then indeed, the ul is empty. As long as it's
> >>>>>>> empty then you can't find the li :) Are you sure that the li should be
> >>>>>>> there? Maybe it's a timing issue. Try something like this:
> >>>>>>> # do something to trigger the popup
> >>>>>>> wait_until {div(:id => "industry").ul.lis.size > 0}
>
> >>>>>>> What happens? Can you see that the list is filled and does it still
> >>>>>>> timeout? Anyway, i suspect it is a timing issue - just find out some 
> >>>>>>> nice
> >>>>>>> way to say to Watir that "wait as long as this condition is met 
> >>>>>>> meaning that
> >>>>>>> the list is loaded properly". As long as the ul is empty and there 
> >>>>>>> should be
> >>>>>>> li-s in there, Watir can't find the li's. Also, remember that Watir 
> >>>>>>> does
> >>>>>>> most of the things a lot faster than you can do manually and having
> >>>>>>> JavaScript in the game means that there could be some race conditions.
>
> >>>>>>> Good luck!
>
> >>>>>>> Jarmo
>
> >>>>>>> On Mon, Aug 29, 2011 at 7:46 PM, M <[email protected]> wrote:
>
> >>>>>>>> I am attaching the page.html.
> >>>>>>>> I replaced the click_no_wait with click. ie.wait_until
> >>>>>>>> {container.present?} means that I am waiting for the view of the 
> >>>>>>>> screenshot
> >>>>>>>> to be visible.
> >>>>>>>> Also if you want to see a real example, you can go to:
> >>>>>>>>http://qa.jobsync.com/
> >>>>>>>> and sign up for a new account. During the registration process
> >>>>>>>> you'll have to go through that page. "Experience section"
>
> >>>>>>>> Thanks for the help
>
> >>>>>>>> On Mon, Aug 29, 2011 at 9:27 AM, Jarmo <[email protected]> wrote:
>
> >>>>>>>>> I'm not sure that #click_no_wait is needed. Send me the actual html
> >>>>>>>>> code instead. Do it somehow like this:
> >>>>>>>>> ie.link(:id, "launchIndustry").click_no_wait # this bottom is to
> >>>>>>>>> launch the form - attached
> >>>>>>>>> container = ie.div(:id, "industry")
> >>>>>>>>> ie.wait_until {container.present?} # does this mean that the view
> >>>>>>>>> on the screenshot is visible now?
> >>>>>>>>> File.open("page.html", "w") {|f| f.puts ie.html}
>
> >>>>>>>>> Now, send us the "page.html" :)
>
> >>>>>>>>> Jarmo
>
> >>>>>>>>> On Mon, Aug 29, 2011 at 7:18 PM, M <[email protected]> wrote:
>
> >>>>>>>>>> Thanks Jarmo,
>
> >>>>>>>>>> I tried to use your solutions with no luck - i still can't locate
> >>>>>>>>>> the elements. Here is my code and the HTML code, I also attached a 
> >>>>>>>>>> screen
> >>>>>>>>>> shot of the page so you know the type of pop up that I am dealing 
> >>>>>>>>>> with. any
> >>>>>>>>>> help is appreciated
>
> >>>>>>>>>> ie.link(:id, "launchIndustry").click_no_wait # this bottom is to
> >>>>>>>>>> launch the form - attached
> >>>>>>>>>> container = ie.div(:id, "industry")
> >>>>>>>>>> ie.wait_until {container.present?}
> >>>>>>>>>> ie.li(:id => "industry_Technology_&_Internet").when_present.click
> >>>>>>>>>> ie.li(:id =>
> >>>>>>>>>> "supersector_Technology_&_Internet").when_present.click
> >>>>>>>>>> ie.li(:id =>
> >>>>>>>>>> "sector_Software_&_Computer_Services").when_present.click
> >>>>>>>>>> ie.li(:id =>
> >>>>>>>>>> "subsector_Computer_&_IT_Services").when_present.click
> >>>>>>>>>> ie.button(:src, /btn_continueHover.png/).click
> >>>>>>>>>> puts 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX DONE page1
> >>>>>>>>>> X1XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
> >>>>>>>>>> ie.li(:id => "busiArea_IT_/_Engineering").when_present.click
> >>>>>>>>>> ie.li(:id =>
> >>>>>>>>>> "funcArea_Information_Technology").when_present.click
> >>>>>>>>>> ie.li(:id =>
> >>>>>>>>>> "specFunction_Software_Engineering").when_present.click
> >>>>>>>>>> ie.button(:src, /btn_continueHover.png/).click
> >>>>>>>>>> puts 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX DONE page2
> >>>>>>>>>> X1XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
>
> >>>>>>>>>> HTML Code: Notice that the UL and IL are empty.
>
> >>>>>>>>>> <div id="overlay" class="hidden">
>
> >>>>>>>>>>        <div id="industry" class="modal hidden">
>
> >>>>>>>>>>                <form action="#" method="post" class="active" 
> >>>>>>>>>> id="industryModalForm">
>
> >>>>>>>>>>                        <div class="page1 clearfix">
> >>>>>>>>>>                        <h2 style="background: 
> >>>>>>>>>> url(/static/images/blue_gradient.png) repeat-x;font-size: 
> >>>>>>>>>> 1.5em;margin-bottom: 0;padding-top: 9px;padding-bottom: 0px;"><a 
> >>>>>>>>>> href="#" class="industryModalClose" style="float: 
> >>>>>>>>>> right;padding-right: 10px;"><a href="#" class="industryModalClose" 
> >>>>>>>>>> style="float: right;padding-right: 10px;"><img 
> >>>>>>>>>> src="/static/images/icon_modal_close.png" alt="close"/></a>Select 
> >>>>>>>>>> Industry<span>Page 1 of 2</span></h2>
>
> >>>>>>>>>>                                <p class="heading">Please specify 
> >>>>>>>>>> the industry and sector for <strong class="company"></strong> by 
> >>>>>>>>>> making a selection in <em>all four boxes</em>. A company's sector 
> >>>>>>>>>> is determined by its source of revenue or where it generates most 
> >>>>>>>>>> of its revenue.</p>
>
> >>>>>>>>>>                                <dl class="first" id="primary_list" 
> >>>>>>>>>> style="padding-left: 15px;">
>
> >>>>>>>>>>                                        <dt>Primary Industry</dt>
> >>>>>>>>>>                                        <dd>
> >>>>>>>>>>                                                <ul>
> >>>>>>>>>>                                                </ul>
>
> >>>>>>>>>>                                        </dd>
> >>>>>>>>>>                                </dl>
> >>>>>>>>>>                                <dl id="supersector_list">
>
> >>>>>>>>>>                                        <dt>Supersector</dt>
> >>>>>>>>>>                                        <dd>
> >>>>>>>>>>                                                <ul>
>
> >>>>>>>>>>                                                </ul>
> >>>>>>>>>>                                        </dd>
> >>>>>>>>>>                                </dl>
> >>>>>>>>>>                                <dl id="sector_list">
>
> >>>>>>>>>>                                        <dt>Sector</dt>
>
> >>>>>>>>>>                                        <dd>
> >>>>>>>>>>                                                <ul>
>
> >>>>>>>>>>                                                </ul>
> >>>>>>>>>>                                        </dd>
> >>>>>>>>>>                                </dl>
> >>>>>>>>>>                                <dl id="subsector_list">
>
> >>>>>>>>>>                                        <dt>Subsector</dt>
> >>>>>>>>>>                                        <dd>
>
> >>>>>>>>>>                                                <ul>
>
> >>>>>>>>>>                                                </ul>
> >>>>>>>>>>                                        </dd>
> >>>>>>>>>>                                </dl>
> >>>>>>>>>>                                <div class="buttons" style="margin: 
> >>>>>>>>>> 0px 0px 10px;padding-left: 20px;width: 100%;">
>
> >>>>>>>>>>                                        <input type="image" 
> >>>>>>>>>> src="/static/images/btn_continueDisabled.png" alt="Continue" 
> >>>>>>>>>> height="39" width="113" disabled>
>
> >>>>>>>>>>                                        <a href="#" class="goback" 
> >>>>>>>>>> style="left: 170px;top: -8px;">Cancel</a>
>
> >>>>>>>>>>                                </div>
>
> >>>>>>>>>>                        </div>
> >>>>>>>>>>                        <div
>
> ...
>
> read more »

-- 
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]

Reply via email to