Can we using regular expression in xpath value?
15,917
You could have theoretically used matches()
, but it is a part of xpath 2.0, which webdriver doesn't support, see a detailed explanation here:
Apply a starts-with()
check instead:
//*[starts-with(@id, "ngdialog")]
Author by
RayM
Updated on June 07, 2022Comments
-
RayM almost 2 years
Can we using regular expression in xpath value? I am using xpath value to identify an element on web for automation.
I have following :xpath value.
:xpath,'//*[@id="ngdialog4"]/div[2]/div[2]/table/tbody/tr/td[1]/input'
But, the last digit 4
ngdialog4
is not constant and it keeps on changing each time i open pop-up... can i use some regular expression to match any digit? -
Arran over 9 yearsIf the browser has an XPath engine, WebDriver will use it. If the browser's XPath engine doesn't support it, WebDriver won't. If the browser doesn't have an XPath engine (typically IE), then WebDriver places it's own library to use. So saying "It doesn't support XPath 2" is not correct at all.