All I can do is to show you some workaounds.
Alternative to the XPath2.0 matches()
function:
Alternative to Regexp, you can use XPath expression:
You can select a div element with id=“Donors_1233klf323sd_Ti” by the following xpath:
//div[starts-with(@id, "Donors_") and substring(@id, string-length(@id) - string-length('_Ti')+1)="_Ti"]
Alternative to the XPath2.0 ends-with()
function:
Write a Groovy code which creates a Test Object on the fly.
It will read an existing Test Object with xpath //button[@id=‘staticId1:dynamicId:staticId2’]/span
It will translate the xpath into another one like //button[starts-with(@id,'staticId1') and ends-with(@id,'staticId2')]/span
Then it will create a new Test Object using the generated xpath.
XPath2.0 ends-with() function is not available to us. But alternative (very verbose) xpath expression can do the same query
Let me work out for a…
In many cases (simple cases), the contains
function of XPath 1.0 is useful, can be an alternative to matches
function of XPath 2.0:
XPath in Selenium: Learn XPath definition, Types, Basic XPath, Contains, OR & AND, Starts-with Function, XPath Axes Methods, and more.
The following article describes how to live with XPath1.0, without regular expression and ends-with which were added at XPath 2.0
Just for your interest, I made a demo project where I verify if today’s date is displayed in a web page. I used XPath contains()
function. I did not need matches()
function at all.
I have made a GitHub project:
where I described my project just for your interest. I’m not reporting any problems of KS.
Problem to solve
There is a web page http://demoaut-mimic.kazurayam.com/ [demoaut-mimic]
A date string 2020/5/16 is displayed in the page. I want to verify the date is TODAY. The value displayed yesterday was different from today. Tomorrow, it will be different from today. The date value displayed in the page moves.
I do not want to edit my test script to cope with t…
paudet
May 19, 2020, 1:04pm
25
I will check it out thank you !
gva27
July 7, 2020, 1:35pm
27
Issue exist for mobile too
No parent
Selection method: Attributes
Simple regex to handle a popup in multi language:
(Not Now|Plus tard)
(Allow|Autoriser)
@duyluong ,
Please let us know if their is workaround for this issue.
The matches regex does not work for mobile too.
Locator :
/*[@class = ‘android.widget.TextView’ and (matches(text(), ‘\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b’) or matches(., ‘\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b’))]
@bttestmobil
Could you show us a screenshot of your application under test? Do you want to find elements that contain IP Address?
@kazurayam ,
Thanks for the quick response.
Yes the text attribute of element has dynamic IP address which needs to be validated.
Cheers,
Please have a look at the following new post
I have published a demo project on GitHub
GitHub - kazurayam/TestObjectThatMatchesIPAddress
Problem to solve
Let me suppose I have a web page with following HTML fragment:
<ul>
<li>abc</li>
<li>de.f.ghi.j</li>
<li>1.23.45.67</li>
<li>9.8.7.6.5.4.3.2.1</li>
<li>hij 2.3.4.5 klm</li>
<li> 6.7.8.9 </li>
<li>0123456789...</li>
</ul>
Some of <li> element contains String of IP Address-like format. When I say IP Address-like means a string in dot-deci…
1 Like