java - NetSuite 自动显示列表后无法单击下拉列表选项
问题描述
我试图简单地单击输入单词 Advance 后显示的下拉列表。但是我不断收到错误消息。线程“主”org.openqa.selenium.NoSuchElementException 中的异常:没有这样的元素:无法找到元素:
public void supplier (WebDriver driver)
{
Actions action = new Actions(driver);
WebElement supplierLink = driver.findElement(By.id("_searchstring"));
supplierLink.sendKeys("Advance");
//*[@id="/app/accounting/transactions/transactionlist.nl?Transaction_TYPE=Custom108"]
//WebDriverWait wait = new WebDriverWait(driver, 5);
//wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//app/accounting/transactions/transactionlist.nl?Transaction_TYPE=Custom108")));
WebElement clickadvance = driver.findElement(By.id("/app/accounting/transactions/transactionlist.nl?Transaction_TYPE=Custom108"));
action.moveToElement(clickadvance).perform();
}
解决方案
请在您的代码中添加等待条件,这将起作用,
WebDriverWait wait = new WebDriverWait(driver, 20);
By optionXpath = By.id("/app/accounting/transactions/transactionlist.nl?Transaction_TYPE=Custom108");
wait.until(ExpectedConditions.elementToBeClickable(optionXpath));
driver.findElement(optionXpath).click();
如果不是您的 xpath 错误,请相应地更改 xpath。
推荐阅读
- python - python 在运行 jupyter notebook 时崩溃
- html - 如何在我的列中显示这些数据?
- swift - 了解 UIViewRepresentable
- android - 多个视图与多个片段
- unicode - U+0085 NEXT LINE (NEL) 是否已弃用?
- r - 为观察的子集创建一个随机二元变量,将 1 分配给特定比例的行
- python-3.x - TypeError:使用运算符包时无法解压不可迭代的 NoneType 对象
- java - WeldContainer 和 SeContainer
- java - 如何在使用 java aws sdk 创建 aws ec2 时提供实例的名称
- arrays - CUDA中多维数组的结构