The big problem is that these days, the order of the links in the HTML can have nothing to do with where the link ends up being located on the page due to how things can be manipulated with CSS and Javascript. So just finding the order in the HTML is not really proof of how things would appear visually unless your page is fairly simple 'web1.0' in that respect..
Just be aware of that if your page is one that has a lot of CSS magic going on then you might need to be doing things like checking the specific class of the individual links or the containers (often divs) that wrap them since CSS is most often driven by the class name of objects. On Sep 2, 11:10 am, Rahul Sharma <[email protected]> wrote: > actual_links_order = [div_links[0].text,div_links[1].text,div_links[2]] > > On 2 Sep 2011, at 20:01, Litha K wrote: > > > > > > > I have done this as Brett suggested: > > > #---------------------- > > b = Watir::Browser.new > > b.goto 'http://your_site/your_page.html' > > div_links = b.div(:id, 'tools-nav').links > > div_links[0].text == 'Email' > > div_links[1].text == 'Sign Up' > > div_links[2].text == 'Sign In' > > #---------------------- > > > and it works!! > > > Was wondering whether I could do something like this: > > > expected_links_order = ['Email', 'Sign Up', 'Sign In'] > > Actual_links_order = not quite sure how to get the anchor objects into > > an array. > > > expected_links_order <=> Actual_links_order > > > Any thoughts on how to get Actual_links_order pls? > > > Thanks, > > Kay > > > On Sep 2, 6:59 pm, Litha K <[email protected]> wrote: > >> Nice one, thanks Brett. I will give it a go. > > >> Thanks, > >> Kay > > >> On Sep 2, 6:58 pm, brettsykes <[email protected]> wrote: > > >>> Ask Watir for the links collection inside the <div> and then compare > >>> it to an array with your values in it: > > >>> #---------------------- > >>> b = Watir::Browser.new > >>> b.goto 'http://your_site/your_page.html' > > >>> div_links = b.div(:id, 'tools-nav').links > >>> div_links.each { |x| puts x.text } > >>> #---------------------- > > >>> Brett > > >>> On Sep 2, 1:35 pm, Litha K <[email protected]> wrote: > > >>>> Hello all, > > >>>> I have got a test scenario where certain links should appear in a > >>>> particluar order on the page, i.e. > > >>>> 1. Email link appear before Sign Up > >>>> 2. Sign Up link appear before Sign In > >>>> 3. Sign In appears as the last link > > >>>> The HTML is as below: > > >>>> <div id="tools-nav"> > >>>> <ul> > >>>> <li id="email"><a href="https://localhost/email/" id="email-link" > >>>> name="email"><span id="email-text">Email</span></a></li> > >>>> <li id="signup"><a href="https://localhost/signup" name="signup" > >>>> id="login-sign-up">Sign Up</a></li> > >>>> <li id="signin"><a href="https://localhost/signin" name="signin" > >>>> id="login-sign-in">Sign In</a></li> > >>>> </ul> > >>>> </div> > > >>>> Please could someone advise how I could do this in watir-webdriver. > > >>>> Many thanks, > >>>> Kay > > > -- > > Before posting, please readhttp://watir.com/support. In short: search > > before you ask, be nice. > > > [email protected] > >http://groups.google.com/group/watir-general > > [email protected] > > Regards, > Rahul Sharma- Hide quoted text - > > - Show quoted text - -- 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]
