1
  • When I search with input a -- the page displays me a link with linktest html.
  • When I search with input b -- the page displays me a link with linktest xml.
  • When I search with input c -- the page displays me a link with linktest pdf.

I have different linktests for different inputs

on locating the link element, the xpath shows

//*[contains(text(),'html')]
//*[contains(text(),'xml')]
//*[contains(text(),'pdf')]

I need generic xpath. Tried by.tagName("a") any other way other than preceeding and following logic.

1 Answer 1

1

You can use logical expressions in xpath, like and or or. So to match an element with text: pdf, html or xml you could use a following exception:

//a[contains(text(),'html') or contains(text(),'xml') or contains(text(),'pdf')]
2
  • I have 48 such types,may be in future some more may be added.
    – zaki uddin
    Commented Dec 21, 2018 at 7:18
  • @zaki Based on the question I though that there are only those 3 you have mentionded. In case of 48 it would be good from you to share the HTML source as of the links to see if we have other possibilities for a generic expression. Commented Dec 21, 2018 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.