Your XPath expression is a totally valid expression – it will find all @data-search-id
attributes and return true if one of them is 'images', otherwise false.
But you want to click an item, and obviously clicking a boolean value is rather difficult. Query for the item fulfilling the condition instead (thus, move the comparison into a predicate):
//html//*[@data-search-id='images']
Additionally, I'd remove the //html
. The HTML node must be the root node anyway, so /html
would have been fine (no reason for searching it in all subtree). As you're searching for an arbitrary descendent of it, and this will not be the root node (as <html/>
is), omitting it completely does not change the meaning of the XPath expression.
//*[@data-search-id='images']