TestStack / TestStack.Seleno

Seleno helps you write automated UI tests in the right way by implementing Page Objects and Page Components and by reading from and writing to web pages using strongly typed view models.
http://teststack.github.com/TestStack.Seleno/
MIT License
180 stars 60 forks source link

TickCheckbox not working #196

Open ismailmayat opened 9 years ago

ismailmayat commented 9 years ago

I have 2 forms that I am testing using TestStack.Seleno. Both forms have a checkbox that is mandatory. The first form has (including the checkbox) 5 fields. I can use TestStack.Seleno to create a passing test with valid data. I set the checkbox like this:

Input.TickCheckbox(f=>f.Accept,form.Accept);
On my other form which has 10 or so fields, when I try to set the checkbox to be ticked (using the same code) nothing happens. However when I try

    var acceptCheckBox = Find.Element(By.Name("Accept"),new TimeSpan(0,0,0,50));
    if (form.Accept)
    {
        acceptCheckBox.Click();
    }

I get error "Element is not currently visible and so may not be interacted with" Element is clearly visible and is not injected in using javascript.

I am using latest version of TestStack.Seleno from github.

I have managed to figure out what the issue is and have a work around, however I cannot explain why it works on the other form. The mandatory Accept field has html generated by mvc that looks like

So you have the checkbox and hidden field both with id Accept, I suspect in code seleno is picking up the hidden field and setting value, so I updated my code todo

           var acceptCheckBox = Find.Element(By.CssSelector("#Accept.check-box"));
        acceptCheckBox.Click();

Now everything works.