Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access the sub text having no attributes using Watir

In following html

<p>
<strong>Name:</strong>
12121
</p>

How can I access the "12121" text using Watir?

like image 917
Feroz Avatar asked Dec 07 '25 21:12

Feroz


1 Answers

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"

like image 97
user3791 Avatar answered Dec 10 '25 13:12

user3791



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!