我正在尝试在以下网站下拉列表中自动化:
在城市部分,我们有 bangalore 和 chennai,假设 bangalore 被自动选择,所以运行下面的代码失败:
WebElement element=driver.findElement(By.xpath("//select[@class='city-dropdown-search form-city hide select2-offscreen']"));
Select se=new Select(element);
se.selectByIndex(2);
它无法识别第二个城市,请帮助我在这里做错了什么。
html标签如下:
<select id="combobox2" class="city-dropdown-search form-city hide select2- offscreen" name="city" tabindex="-1">
<option value="Chennai">Chennai</option>
<option selected="" value="Bangalore">Bangalore</option>
</select>
xpath 是否有问题或我在这里缺少的其他东西