how to use regular expression in xpath selenium webdriver with examples

1,635 views
Skip to first unread message

Atmakur Subrahmanyam

unread,
Apr 12, 2017, 4:31:12 AM4/12/17
to webdriver
Hi,

how to use regular expression in xpath selenium webdriver with examples

praveen kumar cherukuri

unread,
Apr 12, 2017, 4:34:52 AM4/12/17
to webd...@googlegroups.com
A lot of examples can be given, if you have a specific scenario, it would be easy to give few examples.. 

On Wed, Apr 12, 2017 at 10:31 AM, Atmakur Subrahmanyam <atmakursub...@gmail.com> wrote:
Hi,

how to use regular expression in xpath selenium webdriver with examples

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

darrell grainger

unread,
Apr 12, 2017, 10:45:01 AM4/12/17
to webdriver
XPath does not support regular expression. XPath supports various functions like starts-with() or contains() but it does not support regular expression. If you want to use regular expression you would have a fetch a large collection of WebElement which match a pattern then you can use the regular expression features of your programming language to filter for the match you want. This isn't the most efficient way to do this however because you could end up transmitting hundreds or even thousands of WebElement over the wire then sorting them locally.

It is better to use a locator which will find the single element you are looking for. Then the browser will do all the work for you and only transmit one WebElement to your test code.

Darrell

Neeraj Bhatnagar

unread,
Apr 18, 2017, 6:12:41 PM4/18/17
to webdriver
I dont think if Xpath supports regular expression. You can create custom dynamic xpath based on your scenario to handle dynamic element.
Reply all
Reply to author
Forward
0 new messages