A second looks at your code made me think you should be using ul (singular 
because you only have one), and append lis on the end to get all the li's 
contained within the ul.

> My Code:section_headers = $browser.div(:class,"bd").ul(:class,"items").lis


Sorry about the first response, please disregard it.

Michael

On 2011-Nov-06, at 7:40 PM, Michael wrote:

> You probably intended to use uls which will return a list of ul's instead of 
> ul which only returns the first matching ul.
> 
> Try:
>> My Code:section_headers = $browser.div(:class,"bd").uls(:class,"items")
> 
> 
> Michael
> 
> On 2011-Nov-06, at 7:09 PM, Joe Fleck wrote:
> 
>> Hi Chuck,
>> 
>> I am still having a bit of trouble with getting a group of h2 from a page.
>> 
>> My Code:section_headers = $browser.div(:class,"bd").ul(:class,"items")
>> section_headers.each do|sec_hdr|
>> puts hdr = sec_hdr.h2.text
>> end
>> 
>> I get the following error message.
>> NoMethodError: undefined method `each' for #<Watir::UList:0x10aa117f0>
>>      from 
>> /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:295:in
>>  `method_missing'
>>      from (irb):10
>>      from 
>> /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/deprecate.rb:58
>> 
>> 
>> The HTML Code:
>> <div class="mod simple your-subscriptions">
>> <div class="inner">
>> <div class="hd">
>> <div class="bd">
>> <ul class="items">
>> <li class="item subscriptions-description">
>> <li class="item digest-options">
>> <h2>Digest Options</h2>
>> <div class="line form">
>> <div class="unit size2of5">
>> <div class="line lastUnit size3of5">
>> <label class="wide-label" for="digest_setting_email_format">Format of 
>> digest:</label>
>> <select id="digest_setting_email_format" name="digest_setting[email_format]" 
>> data-method="put" data-href="/digest_settings/488" data-command="change">
>> </div>
>> </div>
>> </li>
>> <li class="item community-features">
>> <h2>Community Features</h2>
>> <div class="line form">
>> <input id="109" class="unit content-feed-subscribe checkbox mrm" 
>> type="checkbox" value="content-feed-109" name="content_feed_Guided 
>> Discussions" 
>> data-subscription-url="/content_feeds/109/subscribe?channel_id=57" 
>> data-content-feed-id="109">
>> <label class="unit label-for-checkbox" for="109">Guided Discussions</label>
>> </div>
>> </li>
>> <li class="item member-discussions">
>> <h2>Member Discussion Topics</h2>
>> <p>Select the topics you're interested in to receive activity updates in 
>> those areas.</p>
>> <div class="line form">
>> <div class="unit size1of2">
>> <div class="line checkbox-row">
>> <input id="107" class="unit content-feed-subscribe checkbox mrm" 
>> type="checkbox" value="content-feed-" name="content_feed_Engineering" 
>> data-subscription-url="/content_feeds/107/subscribe?channel_id=57" 
>> data-content-feed-id="107">
>> <label class="unit label-for-checkbox" for="107">Engineering</label>
>> </div>
>> <div class="line checkbox-row">
>> <input id="108" class="unit content-feed-subscribe checkbox mrm" 
>> type="checkbox" value="content-feed-" name="content_feed_UX" 
>> data-subscription-url="/content_feeds/108/subscribe?channel_id=57" 
>> data-content-feed-id="108">
>> <label class="unit label-for-checkbox" for="108">UX</label>
>> </div>
>> </div>
>> <div class="unit size1of2 lastUnit">
>> <div class="line checkbox-row">
>> <input id="110" class="unit content-feed-subscribe checkbox mrm" 
>> type="checkbox" value="content-feed-" name="content_feed_QA" 
>> data-subscription-url="/content_feeds/110/subscribe?channel_id=57" 
>> data-content-feed-id="110">
>> <label class="unit label-for-checkbox" for="110">QA</label>
>> </div>
>> </div>
>> </div>
>> </li>
>> </ul>
>> 
>> I just want the h2 header.
>> 
>> On Fri, Oct 21, 2011 at 5:07 PM, Chuck van der Linden <sqa...@gmail.com> 
>> wrote:
>> 
>> 
>> On Oct 21, 10:41 am, Joe Fl <joeflec...@gmail.com> 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.
>> 
>> watir-general@googlegroups.com
>> http://groups.google.com/group/watir-general
>> watir-general+unsubscr...@googlegroups.com
>> 
>> 
>> -- 
>> Before posting, please read http://watir.com/support. In short: search 
>> before you ask, be nice.
>>  
>> watir-general@googlegroups.com
>> http://groups.google.com/group/watir-general
>> watir-general+unsubscr...@googlegroups.com
> 
> 
> -- 
> Before posting, please read http://watir.com/support. In short: search before 
> you ask, be nice.
>  
> watir-general@googlegroups.com
> http://groups.google.com/group/watir-general
> watir-general+unsubscr...@googlegroups.com

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

Reply via email to