The community has a new login process
The community single sign-on system has been changed. Learn more about it HERE
Highlighted
Trusted Contributor.. manicmut Trusted Contributor..
Trusted Contributor..
60 views

TruClient: Using regular expression in Id method Javascript

All,

I am trying to use regular expression in the evalXpath, but it is not recognizing. Can you guys let me know whats wrong in the below format? or how to use regex here to capture any phone number.

'evalXPath("(//input[@type=\"text\" and @value=\"(650) 825-6805\"])[1]");
Try 1:
evalXPath("(//input[@type=\"text\" and @value=\"/(^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$\"])/)[1]");
Try 2:
evalXPath("(//input[@type=\"text\" and @value=\"(^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$\"]))[1]");
Try 3:
evalXPath("(//input[@type=\"text\" and @value=\"contains(^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}$\"]))[1]");

0 Likes
1 Reply
Outstanding Contributor.. JHF Remmelzwaal Outstanding Contributor..
Outstanding Contributor..

Re: TruClient: Using regular expression in Id method Javascript

I do not think that the = operator on an attribute works with an regular expression.

Checkout this discussion on finding attributes based on regular expressions in XPath. Note sure which version TruClient uses for XPath expressions.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.