In following html
<p>
<strong>Name:</strong>
12121
</p>
How can I access the "12121" text using Watir?
To get subtext 12121 use Regular expressions.
gsub performs a search-and-replace operation. It will search for all non-digit characters(/\D/) and replace with the given string.
In this case we are not giving any string to replace.
=browser.p.text.gsub(/\D/, "")
=> "12121"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With