selenium webdriver to find the anchor tag and click that

南楼画角 提交于 2019-11-30 12:13:39

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);

You can use ExpectedConditions:

wait.until(visibilityOfElementLocated(By.linkText("About"))).click();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!