当我填写源文本框然后尝试在搜索特定项目的基础上选择选项时,我无法选择该项目。这是我的代码
driver.get("http://bus.easemytrip.com/");
WebElement src=driver.findElement(By.id("txtSrcCity"));
src.click();
src.sendKeys("agra");
driver.findElement(By.xpath("//li[text()='Agra']")).click();
<div class="bus-from">
<label>From :</label>
<input id="txtSrcCity" class="select-txtn-bus ng-untouched ng-not-empty ng-dirty ng-valid-parse ng-valid ng-valid-required" type="text" placeholder="Source City" name="txtSrcCity" ng-model="search.source" autocomplete="off" ng-change="OnSourceEdit()" required=""/>
<div class="drop" ng-show="sourceDiv">
<ul>
<!-- ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Agra 1 Day Package</li>
<!-- end ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Agra</li>
<!-- end ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Agra 1 Day Tour</li>
<!-- end ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Agra Fort</li>
<!-- end ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Jaipur Agra Mathura Tour</li>
<!-- end ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Jaipur Ajmer Agra Tour</li>
<!-- end ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Agra Cantt Railway Station</li>
<!-- end ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Agra I.s.b.t</li>
<!-- end ngRepeat: src in sourceCity -->
<li class="ng-binding ng-scope" ng-click="SetSource(src.id,src.name)" ng-repeat="src in sourceCity">Agrahar</li>
<!-- end ngRepeat: src in sourceCity -->
</ul>
</div>
</div>
答案 0 :(得分:1)
显示下拉列表需要一些时间。您可以driver.get("http://bus.easemytrip.com/");
WebElement src=driver.findElement(By.id("txtSrcCity"));
src.click();
src.sendKeys("agra");
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement option = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[text()='Agra']")));
option.click();
与Expected Conditions一起使用以等待其显示
LEFT JOIN
答案 1 :(得分:0)
我认为您无法找到包含代码的项目:
Option Explicit
Sub CopyTable()
'Select the defined Table1 from classeur1 workbook and copy it to classeur2 starting at cell D1
Workbooks("classeur1").Worksheets("Sheet1").Range("Table1[#All]").Copy _
Workbooks("classeur2").Worksheets("Sheet1").Range("D1")
End Sub
因为您正在搜索其文本EQUALS'Agra'的列表项以及您发送到文本框的键是'agra'。将'agra'发送到文本框后,结果选项列表可能为空。