这是我要查找财务报告的HTML页面。我试过使用XPath,CSS选择器,但没有运气:
<div id='cssmenu'>
<ul>
<!-- ANALYSIS -->
<div style="margin:10px">ANALYSIS</div>
<li class='has-sub'><a href='javascript:void(0)'><div>Accruals</div></a>
<ul>
<li><a href='/financial/dailyAccrualMaintain.do?action=DAILY_MAINTAIN_OPEN&clear=true'><div>Daily</div></a></li>
<li class='last'><a href='/financial/accrual.do?action=list1&clear=true'><div>Monthly</div></a></li>
</ul>
</li>
<li><a href='/financial/financialReports.do?action=LIST_REPORTS&clear=true'><div>Financial Reports</div></a></li>
<li><a href='/financial/validationReports.do?action=LIST_REPORTS&clear=true'><div>Validation Reports</div></a></li>
<li><a href='/financial/financialCheck.do?action=OPEN&clear=true'><div>Financial Check</div></a></li>
</ul>
</div>
我使用CSS选择器定位元素的Java代码,并且还使用了waitl直到元素可见:
private final String finacialReportpath = "div#cssmenu li:nth-child(3)";
@FindBy(css = finacialReportpath)
private WebElement finacialReport;
public void clickfinacialReport() {
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(finacialReportpath)));
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(finacialReportpath)));
this.finacialReport.click();
}
一只萌萌小番薯
相关分类