selenium webdriver to find the anchor tag and click that

后端 未结 2 1977
悲哀的现实
悲哀的现实 2021-01-02 00:43

                      
相关标签:
2条回答
  • 2021-01-02 00:59

    You can use ExpectedConditions:

    wait.until(visibilityOfElementLocated(By.linkText("About"))).click();
    
    0 讨论(0)
  • 2021-01-02 01:06

    In my experience the Selenium API has many flaws in that way. They can mostly only be overcome by reformulating your selectors. For example you could try using a XPath selector to get your element:

    driver.findElement(By.xpath("//a[contains(.,'About')]")).click();
    

    Also, if you are trying to use the Internet Explorer it might help not to click the element, but instead to simulate pushing the Enter button. So assumung the Element is found, you could try this:

    driver.findElement(By.linkText("About")).sendKeys(Keys.ENTER);
    
    0 讨论(0)
提交回复
热议问题