I don\'t know why following query doesn\'t work:
//a/@href[@class=\'specified_string\']
Try it the other way round:
//a[@class='specified_string']/@href
After all, class is an attribute of the <a> element, not an attribute of the href attribute.
An attribute cannot have attributes. Only elements can have attributes.
The original XPath expression:
//a/@href[@class='specified_string']
selects any href attribute of any a element, such that the href attribute has an attribute class whose value is 'specified_string'.
What you want is:
//a[@class='specified_string']/@href
that is: the href attribute of any a element that has class atribute with value 'specified_string'.
You basically say that you are looking for an attribute named href, whose attribute (this is the error) class should be equal to specified_string.
But you need to find the attribute href of an element a, whose attribute class is specified_string.
(ndim's answer overlapped mine)
There is not class attribute present in anchor tag I have href only. It is identified using //*[@href='value'] but //*a[@href='value'] is not working