我想按附件图像单击href链接,并且我尝试了以下代码,但似乎无法正常工作。请帮助我。
.....
driver.findElement(By.xpath(“ // a [@ href ='Careers']”)))。click();
............
以下是Div标签的HTML内容... ..............
<div class="logo">
<img src="/ui/healthcare/assets/images/core/ascension_logo_white.svg" alt="Ascension">
</div>
<ul class="list-group">
<li>
<h4>Get Involved</h4>
<ul class="link-list">
<li><a href="/Careers">Careers</a></li>
<li><a href="/Events">Classes and Events</a></li>
........................
答案 0 :(得分:1)
在xpath下尝试此
driver.get("https://healthcare.ascension.org/");
JavascriptExecutor js = ((JavascriptExecutor) driver);
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();",driver.findElement(By.xpath("//a[@href='/Careers']")));