[Wtr-general] Locating HTML objects
Hi, I am trying to locate some objects on my HTML page. I have used the method show_all_objects, but on the command screen I am just getting a freeze on this: snip C:\Program Files\Watir\Watir_Testsruby addCustomer.rb ---Objects in page - snip Could anyone give me a link to the Watir recorder, or an alternative method to find objects please? Thanks Aidy --- This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. --- ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Locating HTML objects
Aidy, You can use the Internet Explorer developer toolbar to view objects and the DOM for a page: http://www.microsoft.com/downloads/details.aspx?FamilyID=e59c3964-672d-4511-bb3e-2d5e1db91038displaylang=en-CharleyOn 5/26/06, Adrian Rutter [EMAIL PROTECTED] wrote: Hi,I am trying to locate some objects on my HTML page. I have used the methodshow_all_objects, but on the command screen I am just getting a freeze onthis:snipC:\Program Files\Watir\Watir_Testsruby addCustomer.rb---Objects inpage -snipCould anyone give me a link to the Watir recorder, or an alternative methodto find objects please?ThanksAidy ---This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system.If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. ---___Wtr-general mailing list Wtr-general@rubyforge.orghttp://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Locating HTML objects
I do not know if this is related to your problem, but I had trouble with show_all_objects because I expected it to return a string, but it does not. To get a string instead (which you can print yourself, or put in an array . . .), you can add a new method to Watir: class Watir::IE def get_all_objects #puts "---Objects in page -" doc = ie.document s = "" props=["name" ,"id" , "value" , "alt" , "src"] doc.all.each do |n| begin s = s + n.invoke("type").to_s.ljust(16) rescue next end props.each do |prop| begin p = n.invoke(prop) s = s + " " + "#{prop}=#{p}".to_s.ljust(18) rescue # this object probably doesnt have this property end end s = s + "\n" end # s + "\n\n\n" s # Just return the string. end end Name it anything you want. This is just show_all_objects(), modified to return a string. You can also remove items from the "props" array if you are just looking for specific things like name or id. So you could have "get_all_ids()" or "get_all_names()" for example. Put this in a .rb file somewhere in your project. Your /lib directory is a good place. You could make a /lib.w_extensions.rb for example. Lonny Eachus = Subject: [Wtr-general] Locating HTML objects From: Adrian Rutter [EMAIL PROTECTED] Date: Fri, 26 May 2006 10:30:14 +0100 Hi, I am trying to locate some objects on my HTML page. I have used the method show_all_objects, but on the command screen I am just getting a freeze on this: snip C:\Program Files\Watir\Watir_Testsruby addCustomer.rb ---Objects in page - snip ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general