我们如何使用SeleniumWebDriver处理支持Javascript的下拉列表?

我们如何使用SeleniumWebDriver处理支持Javascript的下拉列表?,javascript,selenium-webdriver,Javascript,Selenium Webdriver,在使用JavaScript单击文本框后,下拉列表被启用,我无法从下拉列表中找到元素并选择它。 我尝试过使用JavaScript executor,它单击下拉列表中的元素,但文本框不显示它 提前感谢。我认为您应该添加与上面提到的下拉列表相关的html代码。如果我理解正确,从下拉列表中选择一个元素时,文本框应根据所选内容启用。下面是适用于我的代码 driver.findElement(By.xpath("dropdown button xpath-expression")).click();

在使用JavaScript单击文本框后,下拉列表被启用,我无法从下拉列表中找到元素并选择它。 我尝试过使用JavaScript executor,它单击下拉列表中的元素,但文本框不显示它


提前感谢。

我认为您应该添加与上面提到的下拉列表相关的html代码。如果我理解正确,从下拉列表中选择一个元素时,文本框应根据所选内容启用。下面是适用于我的代码

driver.findElement(By.xpath("dropdown button xpath-expression")).click();
    WebElement othersOp = driver.findElement(By.xpath("dropdown element xpath expression"));
    Actions action = new Actions(driver);
    action.moveToElement(othersOp).click().build().perform();
    Thread.sleep(1000);
    Boolean textBox = driver.findElement(By.id("Textbox id")).isDisplayed();
    driver.findElement(By.xpath(".//*[@id='Textboxid']")).sendKeys("Testing");
    System.out.println("Textbox is displayed? "+textBox);