Re: [wtr-general] I need to retrieve multiple span class=discussion-title
No worries, here is what I got when I ran the code: ree-1.8.7-2010.02 :024 section_headers = $browser.div(:class,mod simple your-subscriptions).div(:class,bd).ul(:class,items).lis = #Watir::LICollection:0x1044bf000 @parent=#Watir::UList:0x1044bf0f0 located=false selector={:class=items, :tag_name=ul}, @selector={:tag_name=li} ree-1.8.7-2010.02 :025 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :026 puts hdr = sec_hdr.h2.text ree-1.8.7-2010.02 :027? end Watir::Exception::UnknownObjectException: unable to locate element, using {:tag_name=h2} from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:248:in `assert_exists' from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:55:in `text' from (irb):26 from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/element_collection.rb:21:in `each' from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/element_collection.rb:21:in `each' from (irb):25 from /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:406 If I do it this way: ree-1.8.7-2010.02 :034 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :035 puts hdr = sec_hdr.text ree-1.8.7-2010.02 :036? end I get this output which at a level to high Association CDK Sandbox provides you with all updates from the community that you subscribe to in a single email, delivered weekly or daily. You can customize the content of your digest and how often you want to receive it. To stop receiving the digest, just set the frequency of updates to never. * Digest Options Frequency of digest: Weekly Daily Never Format of digest: HTML Format (images) Text Only * Community Features Guided Discussions * Member Discussion Topics Select the topics you're interested in to receive activity updates in those areas. Engineering UX QA I have starred those headers I need. On Sun, Nov 6, 2011 at 9:45 PM, Michael mmcwill...@gmail.com wrote: 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 h2Digest Options/h2 div class=line form div class=unit size2of5 div class=line lastUnit size3of5 label class=wide-label for=digest_setting_email_formatFormat 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 h2Community 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=109Guided Discussions/label /div /li li class=item member-discussions h2Member Discussion Topics/h2 pSelect 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=107Engineering/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
Re: [wtr-general] I need to retrieve multiple span class=discussion-title
That appears to be because your first LI doesn't have a H2 inside of it. When you put one LI after another, the browser will automatically close the first before the second opens. ul class=items li class=item subscriptions-description li class=item digest-options h2Digest Options/h2 Fix your HTML syntax and you should be good to go. Michael On 2011-Nov-07, at 6:08 AM, Joe Fleck wrote: No worries, here is what I got when I ran the code: ree-1.8.7-2010.02 :024 section_headers = $browser.div(:class,mod simple your-subscriptions).div(:class,bd).ul(:class,items).lis = #Watir::LICollection:0x1044bf000 @parent=#Watir::UList:0x1044bf0f0 located=false selector={:class=items, :tag_name=ul}, @selector={:tag_name=li} ree-1.8.7-2010.02 :025 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :026 puts hdr = sec_hdr.h2.text ree-1.8.7-2010.02 :027? end Watir::Exception::UnknownObjectException: unable to locate element, using {:tag_name=h2} from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:248:in `assert_exists' from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:55:in `text' from (irb):26 from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/element_collection.rb:21:in `each' from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/element_collection.rb:21:in `each' from (irb):25 from /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:406 If I do it this way: ree-1.8.7-2010.02 :034 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :035 puts hdr = sec_hdr.text ree-1.8.7-2010.02 :036? end I get this output which at a level to high Association CDK Sandbox provides you with all updates from the community that you subscribe to in a single email, delivered weekly or daily. You can customize the content of your digest and how often you want to receive it. To stop receiving the digest, just set the frequency of updates to never. * Digest Options Frequency of digest: Weekly Daily Never Format of digest: HTML Format (images) Text Only * Community Features Guided Discussions * Member Discussion Topics Select the topics you're interested in to receive activity updates in those areas. Engineering UX QA I have starred those headers I need. On Sun, Nov 6, 2011 at 9:45 PM, Michael mmcwill...@gmail.com wrote: 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 h2Digest Options/h2 div class=line form div class=unit size2of5 div class=line lastUnit size3of5 label class=wide-label for=digest_setting_email_formatFormat 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 h2Community 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=109Guided Discussions/label /div /li li class=item member-discussions h2Member Discussion Topics/h2 pSelect the topics you're interested in to receive activity updates in those areas./p div class=line form div
Re: [wtr-general] I need to retrieve multiple span class=discussion-title
So, I won't be able to retrieve those headers because the first one has a p in it. Why is it when I try to get the li class name it returns? ree-1.8.7-2010.02 :041 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :042 puts hdr = sec_hdr.class ree-1.8.7-2010.02 :043? end Watir::LI Watir::LI Watir::LI Watir::LI On Mon, Nov 7, 2011 at 8:40 AM, Michael mmcwill...@gmail.com wrote: That appears to be because your first LI doesn't have a H2 inside of it. When you put one LI after another, the browser will automatically close the first before the second opens. ul class=items li class=item subscriptions-description li class=item digest-options h2Digest Options/h2 Fix your HTML syntax and you should be good to go. Michael On 2011-Nov-07, at 6:08 AM, Joe Fleck wrote: No worries, here is what I got when I ran the code: ree-1.8.7-2010.02 :024 section_headers = $browser.div(:class,mod simple your-subscriptions).div(:class,bd).ul(:class,items).lis = #Watir::LICollection:0x1044bf000 @parent=#Watir::UList:0x1044bf0f0 located=false selector={:class=items, :tag_name=ul}, @selector={:tag_name=li} ree-1.8.7-2010.02 :025 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :026 puts hdr = sec_hdr.h2.text ree-1.8.7-2010.02 :027? end Watir::Exception::UnknownObjectException: unable to locate element, using {:tag_name=h2} from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:248:in `assert_exists' from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:55:in `text' from (irb):26 from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/element_collection.rb:21:in `each' from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/element_collection.rb:21:in `each' from (irb):25 from /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:406 If I do it this way: ree-1.8.7-2010.02 :034 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :035 puts hdr = sec_hdr.text ree-1.8.7-2010.02 :036? end I get this output which at a level to high Association CDK Sandbox provides you with all updates from the community that you subscribe to in a single email, delivered weekly or daily. You can customize the content of your digest and how often you want to receive it. To stop receiving the digest, just set the frequency of updates to never. * Digest Options Frequency of digest: Weekly Daily Never Format of digest: HTML Format (images) Text Only * Community Features Guided Discussions * Member Discussion Topics Select the topics you're interested in to receive activity updates in those areas. Engineering UX QA I have starred those headers I need. On Sun, Nov 6, 2011 at 9:45 PM, Michael mmcwill...@gmail.com wrote: 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 h2Digest Options/h2 div class=line form div class=unit size2of5 div class=line lastUnit size3of5 label class=wide-label for=digest_setting_email_formatFormat 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 h2Community 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
Re: [wtr-general] I need to retrieve multiple span class=discussion-title
Okay, I just the answer that works in getting the class name. .attribute_value('*class*') Here is my code: section_headers.each do|sec_hdr| puts hdr = sec_hdr.attribute_value('class') if hdr == 'item digest-options' puts hdr_1 = $browser.li(:class,'item digest-options').h2.text end end item subscriptions-description item digest-options * header = Digest Options item community-features item member-discussions ree-1.8.7-2010.02 :050 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :051 puts hdr = sec_hdr.attribute_value('class') ree-1.8.7-2010.02 :052? end item subscriptions-description item digest-options item community-features item member-discussions On Mon, Nov 7, 2011 at 9:07 AM, Joe Fleck joeflec...@gmail.com wrote: So, I won't be able to retrieve those headers because the first one has a p in it. Why is it when I try to get the li class name it returns? ree-1.8.7-2010.02 :041 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :042 puts hdr = sec_hdr.class ree-1.8.7-2010.02 :043? end Watir::LI Watir::LI Watir::LI Watir::LI On Mon, Nov 7, 2011 at 8:40 AM, Michael mmcwill...@gmail.com wrote: That appears to be because your first LI doesn't have a H2 inside of it. When you put one LI after another, the browser will automatically close the first before the second opens. ul class=items li class=item subscriptions-description li class=item digest-options h2Digest Options/h2 Fix your HTML syntax and you should be good to go. Michael On 2011-Nov-07, at 6:08 AM, Joe Fleck wrote: No worries, here is what I got when I ran the code: ree-1.8.7-2010.02 :024 section_headers = $browser.div(:class,mod simple your-subscriptions).div(:class,bd).ul(:class,items).lis = #Watir::LICollection:0x1044bf000 @parent=#Watir::UList:0x1044bf0f0 located=false selector={:class=items, :tag_name=ul}, @selector={:tag_name=li} ree-1.8.7-2010.02 :025 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :026 puts hdr = sec_hdr.h2.text ree-1.8.7-2010.02 :027? end Watir::Exception::UnknownObjectException: unable to locate element, using {:tag_name=h2} from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:248:in `assert_exists' from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/elements/element.rb:55:in `text' from (irb):26 from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/element_collection.rb:21:in `each' from /Users/josephfleck/.rvm/gems/ree-1.8.7-2010.02/gems/watir-webdriver-0.3.4/lib/watir-webdriver/element_collection.rb:21:in `each' from (irb):25 from /Users/josephfleck/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:406 If I do it this way: ree-1.8.7-2010.02 :034 section_headers.each do|sec_hdr| ree-1.8.7-2010.02 :035 puts hdr = sec_hdr.text ree-1.8.7-2010.02 :036? end I get this output which at a level to high Association CDK Sandbox provides you with all updates from the community that you subscribe to in a single email, delivered weekly or daily. You can customize the content of your digest and how often you want to receive it. To stop receiving the digest, just set the frequency of updates to never. * Digest Options Frequency of digest: Weekly Daily Never Format of digest: HTML Format (images) Text Only * Community Features Guided Discussions * Member Discussion Topics Select the topics you're interested in to receive activity updates in those areas. Engineering UX QA I have starred those headers I need. On Sun, Nov 6, 2011 at 9:45 PM, Michael mmcwill...@gmail.com wrote: 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
Re: [wtr-general] I need to retrieve multiple span class=discussion-title
On Mon, Nov 7, 2011 at 3:41 PM, Joe Fleck joeflec...@gmail.com wrote: Okay, I just the answer that works in getting the class name. .attribute_value('*class*') .class_name would work as well. -- 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
Re: [wtr-general] I need to retrieve multiple span class=discussion-title
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 h2Digest Options/h2 div class=line form div class=unit size2of5 div class=line lastUnit size3of5 label class=wide-label for=digest_setting_email_formatFormat 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 h2Community 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=109Guided Discussions/label /div /li li class=item member-discussions h2Member Discussion Topics/h2 pSelect 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=107Engineering/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=108UX/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=110QA/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
Re: [wtr-general] I need to retrieve multiple span class=discussion-title
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 h2Digest Options/h2 div class=line form div class=unit size2of5 div class=line lastUnit size3of5 label class=wide-label for=digest_setting_email_formatFormat 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 h2Community 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=109Guided Discussions/label /div /li li class=item member-discussions h2Member Discussion Topics/h2 pSelect 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=107Engineering/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=108UX/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=110QA/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
[wtr-general] I need to retrieve multiple span class=discussion-title
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 Test Image Thu Oct 20 15:23:56 -0400 2011 subject_lines = $browser.div(:id,'discussion- board').span(:class,'discussion-title').links subject_lines.each do|link| puts title_name = link.text end Test Image Thu Oct 20 15:23:56 -0400 2011 subject_lines = $browser.div(:id,'discussion-board').links subject_lines.each do|link| puts title_name = link.text end Add * Test Image Thu Oct 20 15:23:56 -0400 2011 Matthew James Berman, MD Budget Management Government Relations Grants/Funding Read more 0 comments Add a comment * Check out this document Thu Oct 20 15:23:20 -0400 2011 Matthew James Berman, MD Budget Management Government Relations Read more DataFile.xls 0 comments Add a comment - in the above the * line is the only line I want for each listed on the page. subject_lines = $browser.div(:class,'discussion-meta-wrap').links subject_lines.each do|link| puts title_name = link.text end * Test Image Thu Oct 20 15:23:56 -0400 2011 Matthew James Berman, MD Budget Management Government Relations Grants/Funding HTML code: div id=community_resources_list_2161 class= dl id=theme-resource-list class=discussions-block list-page dt class=discussion-meta image-attachment div class=profile-pic a class=person-inline-profile title=NAPH Member Community href=http://0.0.0.0:3000/profiles/2/show_other_person? default_link=summary /div div class=discussion-meta-wrap span class=discussion-title a class=theme href=http://0.0.0.0:3000/channels/naph-member- community/navigational_categories/discussions/pages/topic/ categorized_resource/ImageAttachment/38Test Image Thu Oct 20 15:23:56 -0400 2011/a /span span class=dtposted span class=related-topics /div /dt dd class=discussion image-attachment div class=discussion-wrap div class=image-details a href=/channels/naph-member-community/image_attachments/38? theme_id=91 img class=image_thumbnail width=84 height=63 src=/attachments/ 38_thumbnail.jpg?1319138639 /a /div div class=discussion-body /div ul class=action-links /dd dt class=discussion-meta file-attachment div class=profile-pic div class=discussion-meta-wrap span class=discussion-title a class=theme href=http://0.0.0.0:3000/channels/naph-member- community/navigational_categories/discussions/pages/topic/ categorized_resource/FileAttachment/37Check out this document Thu Oct 20 15:23:20 -0400 2011/a /span span class=dtposted span class=related-topics /div /dt dd class=discussion file-attachment dt id=link_resource_34 class=discussion-meta link-resource I would appreciate any help on this. Thank you, Joe -- 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