Selenium webdriver Selenium等待文本框值更改

Selenium webdriver Selenium等待文本框值更改,selenium-webdriver,Selenium Webdriver,我遇到了一种情况,在选择组合框值textbox值更改时。我需要等待文本框更改为特定值。我已尝试等待。直到,请帮助我解决此问题。如果您已经知道该值,在组合框更改后,该值将反映在文本框中。然后您可以创建一个类似xPath的 //*[包含(text(),'Expectedvalue'] 然后创建一个方法来检查xPath是否可用 public boolean isElementPresent(String xPath)` { try { this.driver.fi

我遇到了一种情况,在选择组合框值textbox值更改时。我需要等待文本框更改为特定值。我已尝试等待。直到,请帮助我解决此问题。

如果您已经知道该值,在组合框更改后,该值将反映在文本框中。然后您可以创建一个类似xPath的

//*[包含(text(),'Expectedvalue']

然后创建一个方法来检查xPath是否可用

 public boolean isElementPresent(String xPath)` 
 { 
    try
    {
       this.driver.findElement(By.xpath(xPath);
       return true;
     } 
       catch()
      {
        return false;
      }
  }
然后可以使用while循环进行检查

`//Do the code for changing combo box value
  while(isElementPresent("//*[contains(text(),'Expectedvalue']")
 {//do the necessary actions}`

//假设组合框已编辑且文本框可见

while(! driver.findElement(By.xpath("textboxXpath")).getText().equalsIgnoreCase("expected value"))
{
   System.out.println("waiting for text to be loaded");
}
在此循环结束时,文本框必须加载预期值 注意事项: 这可能会导致无限执行。请限制执行

while(! driver.findElement(By.id("id_of_combo_box")).getAttribute("value").equals("Expected Value"))
{/*Loops till value is written*/}

在这里,我们循环直到组合框的值等于预期值。

使用Webdriver内置的等待逻辑-ExplicitWait。您是否尝试使用以下逻辑?
公共静态WebDriverWait WebDriverWait=null;WebDriverWait=new WebDriverWait(driver,480);WebDriverWait.until(ExpectedConditions.TextToBepresentElement(By.xpath(“textbox xpath”),“您正在等待的文本”);