首页 > 解决方案 > 从向下滚动菜单中选择。写至少 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.

标签: javaseleniumselenium-webdriverautomation

解决方案


尝试这个:

// 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();

推荐阅读