0

我遇到了一种情况,选择组合框值文本框值更改。我需要等到文本框更改为特定值。我试过等待。直到,请帮我解决这个问题。

4

3 回答 3

0

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

//*[包含(文本(),'预期值']

然后创建一个方法来检查 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}`
于 2013-10-08T04:28:28.190 回答
0

//假设组合框被编辑,文本框也是可见的

while(! driver.findElement(By.xpath("textboxXpath")).getText().equalsIgnoreCase("expected value"))
{
   System.out.println("waiting for text to be loaded");
}

在此循环结束时,文本框必须加载预期值 注意: 这可能会导致您无限执行。有限制地实施。

于 2013-10-08T10:31:37.867 回答
0
while(! driver.findElement(By.id("id_of_combo_box")).getAttribute("value").equals("Expected Value"))
{/*Loops till value is written*/}

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

于 2017-03-28T04:51:52.267 回答