【问题标题】:Selenium WebDriver - Application becomes unresponsive after clicking on Save buttonSelenium WebDriver - 单击“保存”按钮后应用程序变得无响应
【发布时间】:2018-05-04 20:55:30
【问题描述】:

我正在自动化其中包含输入一些详细信息的场景之一,然后单击“保存”按钮。当我手动执行这些步骤时,处理和完成几乎不需要 5 到 8 秒。 但同样通过自动化脚本执行,它只是无限期地继续加载。

下面是保存按钮的html代码:

<button class="blueFilledButton ng-binding" ng-click="validateIdea(validateIdeaForm)" ng-disabled="userNotFound || PoupupButtonDisabled || incorrectValidDate" tabindex="0" aria-disabled="false">Save</button>

Selenium 代码:​​我尝试过以下点击方法:

案例 - 1:

driver.findElement(By.xpath("//button[text()='Save']")).click();

案例 - 2:

Actions builder = new Actions(driver);
builder.moveToElement(driver.findElement(By.xpath("//button[text()='Save']"))).click().perform();

在这两种情况下,它都会继续加载。

是不是点击保存按钮后调用了脚本,webdriver不兼容?

请帮忙。提前致谢。

【问题讨论】:

  • 添加页面html供参考
  • 您是否遇到任何错误?

标签: java selenium selenium-webdriver webdriver


【解决方案1】:

根据 HTML,您已将 &lt;button&gt; 与文本共享为 SaveAngular 元素,因此您必须诱导 WebDriverWait可点击的元素如下:

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='blueFilledButton ng-binding'][@ng-click=\"validateIdea(validateIdeaForm)\"]"))).click();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-02
    • 1970-01-01
    相关资源
    最近更新 更多