On Oct 21, 10:41 am, Joe Fl <[email protected]> wrote:
> Hi,
>
> I need to retrieve multiple discusion titles from a page. I just want
> the titles only and there can be 5 to 13 on a page with other links
> listed under them. I have tried the following and it will only return
> the first discussion title or all links:
>
> subject_lines =
> $browser.div(:class,'one_col_select').div(:id,'naph').div(:id,'discussion-
> board').span(:class,'discussion-title').links
>
> subject_lines.each do|link|
> puts title_name = link.text
> end
>
Your problem is that you are telling it to get all the links from
within a single span. I think what you need to do is get all the
spans which contain those links, and then pull the link text, OR if
the only links on the page are those of the class theme are the ones
you want, then just go for the links directly
If you can go after the links, then
subject_links = $browser.links(:class, 'theme')
subject_links.each do|link|
puts link.text
end
If the links are not unique enough on their own, then unless there are
other spans on the page with the discussion_title class that you don't
want, you need to do something more along these lines
subjects = $browser.spans(:class,'discussion-title')
subjects.each do|subject|
puts subject.link.text #presumes we want first link inside the
span
end
--
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]