【问题标题】:how to wait till a button is getting clicked in selenium webdriver c#?如何等到在 selenium webdriver c# 中单击按钮?
【发布时间】:2013-10-19 13:25:51
【问题描述】:

在火狐浏览器中,要求是等到元素(按钮)被点击。 我们如何实现它?

wait.Until(ExpectedConditions.ElementExists(By.Id("")) 在这里不工作。

【问题讨论】:

  • “被点击”是什么意思?
  • 您必须编写自己的 ExpectedCondition。我可以帮你。单击按钮时的效果是什么?按钮会消失吗?

标签: c# selenium webdriver automated-tests selenium-firefoxdriver


【解决方案1】:

您始终可以等待单击按钮后出现的元素的可见性..

new WebDriverWait(driver,60).until(ExpectedConditions.visibilityOfElementLocated(By.id("id_of_the_new_element")));

【讨论】:

    【解决方案2】:

    我不知道按钮触发了什么,但您可以尝试以下操作:

    var buttonIsClicked = false;
    
    while (!buttonIsClicked)
    {
        // check something that can tell you if your button action was performed
        if (conditionsMet) buttonIsClicked = true;    
    }
    

    【讨论】:

      【解决方案3】:
      By element= By.xpath("//body/div[3]/div[1]/div/a/span");
      WebDriverWait wait=new WebDriverWait(driver, 60);
      WebElement var = wait.until(ExpectedConditions.visibilityOfElementLocated(element));
      if(var.isDisplayed())
      {
          var.click();
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-03
        • 2012-08-23
        • 2016-01-30
        • 2020-01-24
        • 2019-12-14
        • 1970-01-01
        相关资源
        最近更新 更多