I always like to use the _javascript_ objects. So one way is to be able to get the _javascript_ underlying object from the div reference in WATIR. Then when you get that just call the getAttribute() method on that object and pull out the attribute that you would like. Another way would be to use the XML Xpath against the DOM to pull the data that you want. I am not too familiar with this but I know it can be done.

 

Sergio

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Carvalho
Sent: Thursday, February 09, 2006 1:14 PM
To: wtr-general@rubyforge.org
Subject: [Wtr-general] How do you find a specific string in an HTML page?

 

Hi there, I am trying to find a way to find a particular string in an HTML page and save it to a variable.  It seems simple enough, but I can't find the commands to help me do it yet.

Our Dot-Net app assigns Unique ID's to various objects within the system.  For example, if you create a new Customer in an Order-Taking system, the new Customer is assigned a unique ID (let's call it "customerID").  When I look at the HTML page, I see that UID in various places.  For example:
(a) within a "div" tag (within a custom attribute unrecognised by Watir)
(b) within an "a href" link (part of the URL - e.g. "http://www.../../ShowCustomer.aspx?mode=edit&customerID=1234asdf-5678hjlk")

I know that I can use the contains_text() to look for text on the page.  I can also use ie.frame("frameName").html.to_s to capture the contents of the frame.  So how can I tell Watir to find the "customerID=" phrase and then capture the next [fixed-number] set of characters into a string variable?

Thanks in advance.

Paul.

_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to