好的,那么自动化的流程是:
- 单击“添加地址”按钮。模态框出现但未完成加载
- 使用 wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xPath)) 等待所有字段和按钮加载。
- 发送 key
- 选择“保存收件人”按钮
但是,在某些情况下,前两个 key 不会发送。我尝试过等待模式,但按键不太可能发送。 我使用了错误的 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
关于java - 模式中前两个字段的 key 未发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31481394/