Select an element by the text it contains with Selenium Webdriver

前端 未结 2 932
情深已故
情深已故 2021-01-19 07:09

I\'ve jjust started off with Selenium Webdriver and I\'ve hit an issuee straight away involving the buttons I\'m trying to select/click all have no IDs and share the same cl

2条回答
  •  佛祖请我去吃肉
    2021-01-19 07:33

    You can find the link by the visible text.

    IWebElement XyzLink= _browser.FindElement(By.LinkText("xyz"));

    Also you can locate the link by partial link text as follows,

    IWebElement XyzPartialLink= _browser.FindElement(By.PartialLinkText("XYZ"));

    For example this will locate a link element which contains 'XYZ' in its text.

提交回复
热议问题