문제

A link coded as:

<a id="ButtonNext" disabled="disabled" title="next page">>></a>

can be found via:

var hasNext = browser.Links.Where(d => d.Id == "ButtonNext">;

I need to add a way to detect the disabled="disabled" attribute so my branch knows if the .Click() method should be invoked.

thanks

도움이 되었습니까?

해결책

WatiN automatically resolve the disabled attribute to determine if the control is enable or not.

So you can use the Enabled property :

var disabledLink = browser.Link(
    l => l.Id == "ButtonNext"
        && !l.Enabled);

Note that if you want to get any attribute value of a control, you can use the GetAttributeValue(string attributeName) method.

For the disabled attribute, WatiN convert the value to a boolean. This code is equivalent to the previous one :

var disabledLinkTrue = browser.Link(
    l => l.Id == "ButtonNext"
        && l.GetAttributeValue("disabled") == Boolean.TrueString);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top