Select Element By Text in Selenium

后端 未结 4 884
眼角桃花
眼角桃花 2021-01-23 02:17

This may sound so simple but why there is no method to find element by its inner text without using xpath? for instance there is an element:

4条回答
  •  北海茫月
    2021-01-23 02:45

    It doesn't seem to be possible for every element, according to Selenium documentation. You can try to use

    By.linkText("link text")
    

    or

    By.partialLinkText("partial link text")
    

    But that works for anchor elements () only.

提交回复
热议问题