我尝试在下一页的“付款方式”中选择下拉值。
重定向到https://my.orderhive.com/orders >>点击“新订单”按钮
在此页面上,“付款方式”下拉列表。我想为该下拉列表选择“Check”值。
我试图选择使用链接文本,XPath,选择和操作。但是,他们都没有工作。
Actions a = new Actions(driver);
WebElement b = driver.findElement(By.xpath("//[@id=\"footerAction\"]/span"));
a.moveToElement(b).click().perform();
使用以下代码:
WebDriverWait wait =new WebDriverWait(driver,10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//label[normalize-space()='Payment Method']//following-sibling::div")));
driver.findElement(By.xpath("//label[normalize-space()='Payment Method']//following-sibling::div")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='PaymentMethod']//div[@id='footerAction']")));
List<WebElement>options= driver.findElements(By.xpath("//div[@id='PaymentMethod']//div[@id='footerAction']"));
for (WebElement option : options){
if (option.getText().equals("Cheque")){
option.click();
break;
}
}