Domanda

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

È stato utile?

Soluzione

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);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top