【发布时间】:2013-11-03 18:32:43
【问题描述】:
所以我开始使用这个很棒的功能:
[FindsBy(How = How.CssSelector, Using = "div.location:nth-child(1) > div:nth-child(3)")]
public IWebElement FirstLocationTile { get; set; }
但问题是它似乎在我的 WebDriverWait 代码中不起作用!
具体示例,我无法重复使用我的 FirstLocationTile。它坚持要有一个By。:
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(BaseTest.defaultSeleniumWait));
wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("div.location:nth-child(1) > div:nth-child(3)")));
有什么想法吗?
【问题讨论】:
-
我不使用 C#,但我知道许多 ExpectedConditions 只接受
By而不是WebElement。但是,在 Java 中,等到元素可见(不存在,可见)是您可以使用WebElement完成的操作 -
我试过 FindsBy 只是在每个网络元素上都有错误。 FindElement(By.Id/Xpath 工作。Examples of PageFactory in java。您的 PageFactory 初始化元素行在哪里?需要更多关于似乎不起作用的详细信息;异常、构建失败、测试失败。什么样的 wait?
-
您不能只使用 By 对象吗? public By FirstLocationTile => By.CssSelector("div.location:nth-child(1) > div:nth-child(3)"); wait.Until(ExpectedConditions.ElementIsVisible(FirstLocationTile));