No prob -- also thought you might be interested in
this. If you want to calculate and/or display the totals for elements,
this is what I use:
puts "#{$ie.links.length} urls"
puts "#{$ie.images.length} images"
puts "#{$ie.buttons.length} buttons"
puts "#{$ie.text_fields.length} text fields"
puts "#{$ie.ps.length} paragraphs"
puts "#{$ie.spans.length} spans"
puts "#{$ie.divs.length} divs"
puts "#{$ie.radios.length} radio menus"
puts "#{$ie.select_lists.length} list menus"
puts "#{$ie.checkboxes.length} checkboxes"
puts "#{$ie.images.length} images"
puts "#{$ie.buttons.length} buttons"
puts "#{$ie.text_fields.length} text fields"
puts "#{$ie.ps.length} paragraphs"
puts "#{$ie.spans.length} spans"
puts "#{$ie.divs.length} divs"
puts "#{$ie.radios.length} radio menus"
puts "#{$ie.select_lists.length} list menus"
puts "#{$ie.checkboxes.length} checkboxes"
From: sikander [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 09, 2006 2:29 AM
To: Adam Reed
Subject: RE: [Wtr-general] Is there any way to get all the scr's of images?
Thanks Adam,
Sikander
From: Adam Reed [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 08, 2006 7:10 PM
To: [email protected]
Cc: [EMAIL PROTECTED]
Subject: RE: [Wtr-general] Is there any way to get all the scr's of images?
I wrote a script a while back that yanks all the elements
on a page and puts them in a nicely formatted xml document. The only
things I've had to change when sending examples has been to use the 'puts"
command at the end rather than the xml inject, and remove the outer "XML.images
do" loops that make sure they get written in correctly. I think these
should help you figure out my logic since it can be used for all
elements. Examples:
Buttons:
ie.buttons.each do
|button|
buttons = {'name' => button.name, 'text' => button.value}
buttons.each do | it, button |
puts "#{it}:#{button}"
buttons = {'name' => button.name, 'text' => button.value}
buttons.each do | it, button |
puts "#{it}:#{button}"
end
Links:
ie.links.each do
|link|
next if link.innerText.empty? #they get this extra line in case they don't have text
urls = {'href' => link.href, 'name' => link.innerText}
urls.each do | item, url |
puts "#{item}:#{url}"
end
next if link.innerText.empty? #they get this extra line in case they don't have text
urls = {'href' => link.href, 'name' => link.innerText}
urls.each do | item, url |
puts "#{item}:#{url}"
end
Thanks,
Adam
From: sikander [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 08, 2006 7:25 AM
To: [email protected]
Cc: Adam Reed
Subject: RE: [Wtr-general] Is there any way to get all the scr's of images?
Thanks, the following code works very well for
images.
How about buttons, drop down list boxes, text boxes.
Thanks,
Sikander
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adam Reed
Sent: Monday, November 06, 2006 8:57 PM
To: [email protected]
Subject: Re: [Wtr-general] Is there any way to get all the scr's of images?
I'd use a simple ie-do loop:
ie = Watir::IE.new
ie.set_fast_speed
ie.goto "www.google.com"
ie.set_fast_speed
ie.goto "www.google.com"
ie.images.each do
|image|
images = {'path' => image.src}
images.each do | ite, image |
puts "#{ite}:#{image}"
end
end
images = {'path' => image.src}
images.each do | ite, image |
puts "#{ite}:#{image}"
end
end
This should output:
Put a
little "def Check_images" and add another "end" afterwards, and there's your
function.
Thanks,
Adam
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of sikander
Sent: Saturday, November 04, 2006 12:00 AM
To: [email protected]
Subject: [Wtr-general] Is there any way to get all the scr's of images?
Hi
All!
Is there any way to
get all buttons, text boxes, images etc., of a page to
display?
For Example i want
to see all id's or :src's of images of a web page.
In that case i may
write similar to following code to display all the images of the current page
one by one
check_Images=$ie.image(:src,
/*.jpg/)
pust check_Images.
Please help me in this
regard.
Regards,
Sikander
_______________________________________________ Wtr-general mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-general
