Question

So I have some HTML surrounding a field like this :

<div class="form-row style="display: none; ">
    <label class="fld-lbl" for="Blah">Blah</label>
    <div class="fld">
        <select id="Make" name="Make"></select>
    </div>
</div>

I want to select the 'Make' element, and work out if the parent div 'form-row' is visible or not. I'm really struggling with WatIn to work out how this is possible.

I am trying something like this :

_make = _browser.Page.Make; //this is set with some other methods, but it is basically the 'Select' element mentioned above.

var makeVisible = _browser.Div(div =>
{
    var ancestor = _make.BaseElement.Ancestor(Find.ByClass("form-row"));
    return ancestor != null && string.Equals(ancestor.Style.Display, "none");
});

This doesn't seem to work, but i can take the select element and traverse up the DOM using parent.parent.parent. But that is a bit naff, and doesn't allow the HTML to change.

Can anyone help?

Cheers

Was it helpful?

Solution

You can use JavaScript

string displayValue = _browser.Eval("$('#Make').closest('div.form-row').css('display');");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top