Selenium WebDriver can't find element by link text

前端 未结 5 1406
死守一世寂寞
死守一世寂寞 2021-01-04 09:44

I\'m trying to select an element that includes an anchor, but the text is buried in a paragraph inside of a div. Here\'s the HTML I\'m working with:



        
5条回答
  •  醉话见心
    2021-01-04 10:13

    The problem might be in the rest of the html, the part that you didn't post.

    With this example (I just closed the open tags):

    
    

    Smoke Sequential

    I was able to find the element without trouble with:

    driver.findElement(By.linkText("Smoke Sequential")).click();
    

    If there is more text inside the element, you could try a find by partial link text:

    driver.findElement(By.partialLinkText("Sequential")).click();
    

提交回复
热议问题