java - 从向下滚动菜单中选择。写至少 1 个字符,等待可见,然后按 enter 或单击
问题描述
我必须从使用 java 和 selenium 的向下滚动菜单中进行选择,但首先我必须至少写一个字母或整个单词。
java 首先我尝试了这个,但它不是下拉菜单。从 id 我得到这个信息:(s2id_autogen3)
Select select = new Select(driver.findElement(By.xpath(xpathLoc.STATUS_SELECT.getLocator())));
select.selectByVisibleText("OPEN");
但这不起作用。
我也尝试其他方式,如 webdriverwait waituntilvisible、clicable 等,但没有任何反应
现在我这样做:
WebElement input = driver.findElement(By.id("s2id_autogen3"));
input.sendKeys("OPEN"); // I SEND THE WORD I WANT, I TRIED click.();, i tried using keywords and enter but doesn't work.
解决方案
尝试这个:
// Enter first character
driver.findElement(By.xpath(“path”)).sendkeys(“first_latter”);
// Wait for the element to be visible if there is a loader visible after entering apply invisibility check for loader
WebDriverWait wait= new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOf(“element”));
// Click on the element
driver.findElement(By.xpath(“path”)).click();
推荐阅读
- python - 在 postgresql 或其他代码行的引号内列出必要的引号?
- rest - 即使用户在用户端点上列出,“租户 guid 的租户不存在”?
- android - 尝试使用 raycaster 而不是 OnMouseOver() 来显示 UI 文本而没有成功
- docker - 在 Windows 虚拟机中运行 Docker
- c# - Unity 中平滑相机缩放的问题
- java - 将有界通配符 (? extends) 与转换器列表一起使用会导致类型不匹配错误
- javascript - 如果另一个集合的对象被删除,更新一个集合的 Firestore 对象?
- java - JasperRunManager 无法访问同一安全约束中的内容
- angular - Visual Studio 代码调试不适用于 Angular 6 CLI
- typescript - 将两个有向(可能是循环)图合并为一个