On Wednesday, May 9, 2012 12:36:55 PM UTC-7, Raghu k wrote:
>
> Thanks. I see that <dd> has a href for viewing the profile. How do i 
> write the code to say that click on the href located  ONLY within the 
> <dd> tags 
>
>  <dd> 
>  <span> 
>  <a href="/profile/view? 
> id=14036482&authType=OUT_OF_NETWORK&authToken=NSVl&locale=en_US&srchid=832d65d5-76a1-4b19-9332-1ff6e94de2fe-0&srchindex=2&srchtotal=570965&goback=
>  
>
> %2Efps_PBCK_doctor_*1_*1_*1_*1_*1_*1_*2_*1_Y_*1_*1_*1_false_1_R_*1_*51_*1_*51_true_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2_*2&pvs=ps&trk=pp_shared_conn_link"
>  
>
> name="vcard-1" class="toggle-shared-connections trk-shared-conn-link 
> trk-no-external" title="View your shared connections"> <strong>1</ 
> strong> shared connection</a> 
>
>
>
>  <span class="separator">&#183;</span> 
>  <a title="View similar people" class="similar trk-similar" href="/ 
> search/fpsearch? 
> viewType=sim&sId=14036482&trk=psearch_similar">Similar</a> 
>
>
>
>  </span> 
>  </dd> 


>
Well this is helpful and there are a number of ways you could click that 
link.  I would not focus on it being within the <dd> tag as that tag has no 
easy way to identify it.   Instead look at things like the name and class 
which could be unique to links of that sort

browser.links(:name => 'v-card-1').each do |link|
  link.click
end

or 

browser.links(:class => 'toggle-shared-connections').each do |link|
  link.click
end

Possibly that may not work after the first link, so you might have to do 
something like

browser.links(:class => 'toggle-shared-connections').each do |link|
  browser.goto(link.href)
end

>
> On May 1, 9:21 pm, Chuck van der Linden <[email protected]> wrote: 
> > On Monday, April 30, 2012 9:38:14 PM UTC-7, Raghu k wrote: 
> > 
> > > In the HTML, there are lot of aref. I want to pick the aref that 
> > > resemebles like <a href="/profile/view? 
> > > 
> id=22891337&authType=OUT_OF_NETWORK&authToken=ORDn&locale=en_US&srchid=6e3c­80af-
>  
>
> > 
> > > fbc3-4c2c-a48a-314e65440c91-0&srchindex=3&srchtotal=290438&goback= 
> > 
> > > How do i pick the particulare aref from the code? 
> > 
> > aref?  what is an "aref"?  I know of no such animal in the HTML 
> standards. 
> > Are you referring to anchor tags? (aka Links) which take the form of 
> > <A>{bunchof stuff}</>  or <A {bunchofstuff) />  and contain an href 
> > attribute? 
> > 
> > You have only shown us part of the HTML for the A tag, and nothing that 
> > surrounds it, so  that makes it very hard to answer your question. 
> > Normally you can use some attribute of the A tag, and ID or Name or 
> Class, 
> > or the text or image that is shown to the user.  Unfortunately your 
> sample 
> > shows none of these things, but I also do not see the closing > so I've 
> no 
> > idea if you have actually included the entire content of the tag. 
>  Another 
> > option is the value for the href itself or a part of it (if that is 
> unique 
> > on the page). 
> > 
> > The first question to ask yourself is 'if I was interacting manually, 
> how 
> > would I know which link I wanted to click.  The answer to that will 
> often 
> > lead you to a good means to identify the link you want.  This may end up 
> > being some other nearby object, such as perhaps another cell on the same 
> > row of a table. 
> > 
> > Since we cannot read your mind, and nor do I have the psychic power of 
> > remote viewing to see your website or screen, we need more information 
> in 
> > order to assist you.  Without a larger sample of HTML, and if you can an 
> > answer to 'how you would know which one to click when testing 
> manually?', 
> > it's hard to give you an exact sample of code that might do what you 
> want. 
> > 
> > 
> > 
> > > On Apr 24, 2:53 am, Chuck van der Linden <[email protected]> wrote: 
> > > > I don't have html for your site, but if there is some predictable 
> > > container 
> > > > such as a div with an id like 'results'  then you could do something 
> > > like 
> > > > this  (also presumes the only links inside the results are to actual 
> > > > results, and not things like upvotes etc.. in that case you may need 
> to 
> > > be 
> > > > more stringent in identifying the link to be clicked, for guidence 
> there 
> > > we 
> > > > would HAVE to see sampleHTML. ) 
> > 
> > > >  do your search 
> > > >  10.times do |i| 
> > > >     browser.div(:id => 'results).link(:index => i).click 
> > > >      (whatever you need to do with the resulting page if anything) 
> > > >    browser.back 
> > > >   end 
> > 
> > > > If you need to do more than the first page of results, then wrap 
> that 
> > > loop 
> > > > in something that clicks the 'next page' link as many times as you 
> need 
> > > to. 
> > 
> > > > Note: unless you work for the company that makes the site, please be 
> > > sure 
> > > > to check their terms of service, many of them forbid automated 
> access, 
> > > > especially link scraping etc) without prior written permission, or 
> > > restrict 
> > > > such access to authorized users of their API and demand it be done 
> via 
> > > the 
> > > > api. 
> > 
> > > > On Monday, April 23, 2012 6:51:57 AM UTC-7, Željko Filipin wrote: 
> > 
> > > > > On Sat, Apr 21, 2012 at 10:42 PM, Raghu k <[email protected]> 
> > > wrote: 
> > > > > > Something like ths would help .. Please help me with a quick 
> code... 
> > 
> > > > > Is there a problem with the code you have posted? 
> > 
> > > > > Željko 
> > > > > -- 
> > > > > watir.com/book - author- Hide quoted text - 
> > 
> > > > - Show quoted text -- 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]

Reply via email to