当前位置: 代码迷 >> java >> 模态的前两个字段未发送密钥
  详细解决方案

模态的前两个字段未发送密钥

热度:11   发布时间:2023-07-31 11:44:49.0

好的,因此自动化过程为:

  1. 单击添加地址按钮。 出现模态但未完成加载
  2. 使用wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xPath)))等待所有字段和按钮加载。
  3. 发送钥匙
  4. 选择保存收件人按钮

但是,在某些情况下,前两个密钥没有发送。 我尝试等待模式,但键发送的可能性较小。 我使用了错误的wait.until参数吗? 我在等待错误的元素吗? 我假设现在正在发生某些比赛情况

public static class WebDriverExtensions
{
    /// <summary>
    /// Try finding the element for timeoutInSeconds until throwing "no matching element"
    /// </summary>
    public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds)
    {
        if (timeoutInSeconds <= 0) return driver.FindElement(@by);

        var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds));
        return wait.Until(drv => drv.FindElement(@by));
    }
}

那你可以叫这个

driver.FindElements(By.xpath(xPath),5).SendKeys(fieldOneString);

其中xPath用于fieldOne

  相关解决方案