1

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.

Any ideas?

Tim
  • 4,414
  • 4
  • 35
  • 49
Ismail
  • 923
  • 2
  • 12
  • 29

1 Answers1

0

So 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

<div>
        <input class="check-box" data-val="true" data-val-mustbetrue="The Accept our field is required" data-val-required="The Accept our field is required." id="Accept" name="Accept" type="checkbox" value="true"><input name="Accept" type="hidden" value="false">
        <label for="Accept">
            Accept our Please accept our <a href="/terms-conditions/" style="text-decoration:underline;" target="_blank">Terms and Conditions</a>
        </label>

        <span class="field-validation-valid" data-valmsg-for="Accept" data-valmsg-replace="true"></span>
    </div>

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.

Ismail

Ismail
  • 923
  • 2
  • 12
  • 29