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=6e3c80af-
>
>
> 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 -
--
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]