Can you use Regex inside xpath?

677 views
Skip to first unread message

kepp...@networkoptix.com

unread,
Feb 21, 2018, 2:01:25 PM2/21/18
to robotframework-users
I've done a fair amount of searching but I can't seem to find anything that works.  In order to target accurately I want to use regex.  What I've seen in my searching are test(string,'regex') and matches(string,'regex').  I can't seem to get these to work in the browser let alone in Robot.  Am I just missing something? Here is the example of my html and xpath:

<span ng-if="passwordInput.password.$error.minlength &amp;&amp;
                  !passwordInput.password.$error.pattern" class="ng-binding ng-scope">Password must contain at least 8 characters</span>

//span[matches(@ng-if, '(passwordInput.password.\$error.minlength &&\n)( )+(!passwordInput.password.\$error.pattern)')]


Tatu Aalto

unread,
Feb 21, 2018, 2:14:08 PM2/21/18
to kepp...@networkoptix.com, robotframework-users
Ugh

The new versions of xpath supports regex, but I haven't found a browser which would support that new xpath version. Usually I have been able to workaround the problem, by using xpath contains [1] or relying xpath axes [2].

-Tatu
Send from my mobile


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

kepp...@networkoptix.com

unread,
Feb 21, 2018, 2:21:59 PM2/21/18
to robotframework-users
Ah I see.  I'll just have to deal with it then.


On Wednesday, February 21, 2018 at 11:14:08 AM UTC-8, Tatu Aalto wrote:
Ugh

The new versions of xpath supports regex, but I haven't found a browser which would support that new xpath version. Usually I have been able to workaround the problem, by using xpath contains [1] or relying xpath axes [2].

-Tatu
Send from my mobile

On 21 Feb 2018 21:01, <kepp...@networkoptix.com> wrote:
I've done a fair amount of searching but I can't seem to find anything that works.  In order to target accurately I want to use regex.  What I've seen in my searching are test(string,'regex') and matches(string,'regex').  I can't seem to get these to work in the browser let alone in Robot.  Am I just missing something? Here is the example of my html and xpath:

<span ng-if="passwordInput.password.$error.minlength &amp;&amp;
                  !passwordInput.password.$error.pattern" class="ng-binding ng-scope">Password must contain at least 8 characters</span>

//span[matches(@ng-if, '(passwordInput.password.\$error.minlength &&\n)( )+(!passwordInput.password.\$error.pattern)')]


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages