我有这个HTML代码
<td ng-repeat="month in fourMonth track by month.month" ng-class="month.class" ng-bind="month.label" ng-click="yearView.setMonth(month)" class="ng-binding ng-scope">Feb</td>
我试图通过使用xpath代码
在selenium中选择String monthReq = "Feb";
WebElement ele = driver.findElement(By.xpath("//td[ng-bind='month.label' and contains(text(),'"+monthReq+"')]"));
但它没有给出这样的元素异常
Exception in thread "main" org.openqa.selenium.NoSuchElementException:Unable to locate element: //td[ng-bind='month.label' and contains(text(),'Feb')]
答案 0 :(得分:0)
我认为您的XPath中存在错误。 试试这个 -
//td[@ng-bind='month.label' and contains(text(),'"+monthReq+"')]
或
//td[contains[text(),'"+monthReq+"']]