I am new to watir, and Need to know how to capture a value displayed on browser and pass the same as parameter to next step. here is how the html looks like.
Text – xxxx yyyy zzzz aaaa
The text displayed is a card number. I need to capture the card number dipslayed and pass it as parameter to next step in my test
If this cardnumber is contained in an HTML element like a div/span/table cell, then use that to locate the bit of text you need.
For example if your HTML was like this:
Then you could use code like this:
You can also use regular expressions or other string manipulation to separate the number from other text on the page.
“Your credit card number is: 1234 5678 9012 3456.”
for an example of a regular expression to find the card number, see @Dave McNulla’s answer below.