0

我正在为 Pega Web 应用程序编写自动化脚本。我有按钮点击功能,但实际上当我运行脚本时按钮没有被点击。当我检查日志时,它显示操作已执行,但实际上并没有点击按钮。

我尝试了以下操作,但没有任何效果,

WebDriverWait wait = new WebDriverWait(driver, 80);
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(),'Submit')]")));

driver.findElement(By.xpath("//button[contains(text(),'Submit')]")).click();

然后我尝试了下面的代码,

WebDriverWait wait = new WebDriverWait(driver, 80);
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(),'Submit')]")));

WebElement button=driver.findElement(By.xpath("//button[contains(text(),'Submit')]"));

button.sendKeys(Keys.RETURN);

我也尝试过javascript,

JavascriptExecutor jse = (JavascriptExecutor) driver;
    jse.executeScript("arguments[0].click();", button);
4

1 回答 1

0

我多次遇到类似的问题,我使用 -

while(driver.findElements(By.xpath("//button[contains(text(),'Submit')]")).size()!=0)
{
    driver.findElement(By.xpath("//button[contains(text(),'Submit')]")).click();
}

这只是一个临时修复,我只是在互联网上的某个地方找到的。我认为这是驱动程序本身的一些问题。

- - 编辑 - -

在单击按钮之前,您能否使用以下 javascript 命令确定页面是否已完全加载(Ajax) -

jQuery.active ==0 && document.readyState == "complete"
于 2020-08-20T12:23:13.117 回答