Find an element by Xpath which contains text

后端 未结 2 1864
春和景丽
春和景丽 2020-12-31 21:55

This works fine if I search for a single string:

var element = Driver.FindElement(By.XPath(\"//a[contains(text(), \'About us\')]\"));

But c

相关标签:
2条回答
  • 2020-12-31 22:14

    Below satisfies your requirement:

    //a[contains(., 'About us') or contains(., 'about us')] 
    

    Refer:- https://sqa.stackexchange.com/questions/10342/how-to-find-element-using-contains-in-xpath for more details.

    0 讨论(0)
  • 2020-12-31 22:28

    say or between two calls of contains function

    //a[contains(text(), 'About us') or contains(text(), 'about us')]
    

    or use translate function to make xpath case insensitive

    //a[contains(translate(text(), 'ABOUTS', 'abouts'), 'about us')]
    
    0 讨论(0)
提交回复
热议问题