Recently i had to spend my whole day searching for ways to find a elements' XPath (a ajax based button) by matching multiple text pattern within a single attribute value. I was using Selenium IDE to automate testing of Sun Portal Server GUI which is based on Ajax.
My Requirement : Uniquely Identify a ajax based button having the below XPath
My Problem : Attribute(@id) value has both constant and dynamic texts which makes it difficult to uniquely identify the element based on its value
If you look at my ajax button's xpath , there is a numeral "81533739" which is not constant and it changes everytime but the first part(ccd_ccd_) and the second part(_removeevent) of the @id value is constant . I want to uniquely identify @id attribute based on these constant text alone
Solution:The below xpath will uniquely identify my element using concat() and contains() XPath methods
//a[contains(@id,concat("ccd","_","ccd","_")) and contains(@id,"removeevent")]
Below are few links which i found helpful for this solution: