ExpectedCondition method attributeContains for C#

不羁岁月 提交于 2019-12-11 07:10:11

问题


I was trying to use "attributeContains" method but I don't have it avaible when using C#. https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/ExpectedConditions.html#attributeContains-org.openqa.selenium.WebElement-java.lang.String-java.lang.String-

Any workaround?


回答1:


You can always create your custom Expected Condition:

public void AttributeContains(By locator, String attribute, String value, int secondsToWait = 30)
{
   new WebDriverWait(driver, new TimeSpan(0, 0, secondsToWait))
      .Until(d => d.FindElement(locator).GetAttribute(attribute) == value);
}

Forgive my rusty C# skills in case there are syntax errors.



来源:https://stackoverflow.com/questions/41048105/expectedcondition-method-attributecontains-for-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!