请看这个:
IWebDriver driver;
WebDriverWait WebDriverWait;
public IWebElement Button
{
return new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("bla bla")));
}
现在,如果我想搜索一些IWebElement
,而不是driver.FindElement
,我想使用另一个IWebElement
我可以执行以下操作:
IWebElement webElement..
IWebElement webElement e = webElement.FindElement(By.XPath("my selector"));
因此,在这种情况下,我想使用WebDriverWait
代替webElement.FindElement
。
有可能吗?
答案 0 :(得分:2)
WebDriverWait.Until()
返回IWebElement
,您可以将返回的值分配给变量或只是连接另一个方法
IWebElement element = new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("bla bla")));
element.FindElement((By.XPath("my selector"));
与
相同new WebDriverWait(driver, TimeSpan.FromSeconds(60)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("bla bla"))).FindElement(By.XPath("my selector"));