:
var waitInnerScope = new DefaultWait<IWebElement>(divInsideWebDriver);
waitInnerScope.Timeout = TimeSpan.FromSeconds(timeout);
waitInnerScope.IgnoreExceptionTypes(typeof(NoSuchElementException));
その後wait.Until
を使用します。
var ok = waitInnerScope.Until(PresenceOfAllElementsLocatedBy(By.XPath("(//button[@id='btnOkDialog'])[" + buttonOccuranceNo + "]")));
EDIT:ExpectedConditions
がためFunc<IWebDriver, ...>
を実装する静的メソッドで構成されているのでWebDriverWait
での使用の場合は、IWebElement
という独自の方法を使用する必要があります。
public static Func<IWebElement, ReadOnlyCollection<IWebElement>> PresenceOfAllElementsLocatedBy(By locator)
{
return (element) =>
{
try
{
var elements = element.FindElements(locator);
return elements.Any() ? elements : null;
}
catch (StaleElementReferenceException)
{
return null;
}
};
}
それとも、そのような匿名メソッドのためのラムダ式を使用することができます。
waitInnerScope.Until<ReadOnlyCollection<IWebElement>>((element) =>
{
try
{
var elements = element.FindElements(By.XPath("(//button[@id='btnOkDialog'])[" + buttonOccuranceNo + "]"));
return elements.Any() ? elements : null;
}
catch (StaleElementReferenceException)
{
return null;
}
});
ExpectedConditionsはTYE機能を返すのFuncまたはブール値>で、すべてのメソッドが含まれています。その生成エラー。 Func またはbool>メソッドを返すクラスがありますか? –
rana
申し訳ありませんが、あなたが尋ねたことを理解することができません、明確にしようとしてください – Moshisho
私はあなたのsuggessionを試して、ExpectedConditionsクラスでエラーが発生しました。そのクラスの中に入ると、そのクラスで宣言されているすべてのメソッドが、Func)またはFunc の戻り値の型を持つことがわかりました。 –
rana