To use regex in Xpath locators.To get all the links elements with attribute href that match:
You need to use the regex matches() function, like this:xpath=//div[matches(@id,'che.*boxes')]
this will click the div with 'id=checkboxes', or 'id=cheANYTHINGHEREboxes')
If you have trouble with your particular browser (as I did with FF3), try using Selenium's allowNativeXpath("false") to switch over to the JavaScript Xpath interpreter. It'll be slower,http://[^/]*\d+com
Usesel.get_attribute( '//a[regx:match(@href,
return a list of the name attribute of
"http://[^/]*\d+.com")]/@name' )
which will
all the links that match the regex.
Be aware, that the matches function is not supported by all
native browser implementations of Xpath
(most conspicuously, using this in FF3 will throw an error: invalid xpath[2]).
but it does seem to work with more Xpath functions, including 'matches' and 'ends-with'.
matches(str1,str2) is a xpath2.0 function which is not supported in browser like chrome. Do you have a solution for this problem ?
ReplyDeletematches(str1,str2) is a xpath2.0 function which is not supported in browser like chrome. Do you have a solution for this problem ?
ReplyDelete
ReplyDeleteIt is really a great work and the way in which u r sharing the knowledge is excellent.
Thanks for helping me to understand basic concepts. As a beginner in software testing your post help me a lot.Thanks for your informative article. software testing Training in chennai | Best software testing Training institute in velachery
asas
ReplyDelete