Finding webelement with xpath starting with

前端 未结 3 1826
醉梦人生
醉梦人生 2021-02-02 13:54

I\'m trying to locate a link using Selenium Webdriver. I don\'t wanna locate it by link text, only the actual link which is typed in . This can be done by using Selenium\'s find

3条回答
  •  無奈伤痛
    2021-02-02 14:26

    You can use the start-with in xpath to locate an attribute value that starts with a certain text.

    For example, assume you have the following link on the page:

    link text
    

    Then you can use the following xpath to find links that have an href that starts with 'mylink':

    //a[starts-with(@href, "mylink")]
    

提交回复
热议问题