I am passing in the checkbox ID, grabbing the element and then if the checkbox is not checked I want to check it. It wouldn't check the box though, so I was debugging and then it worked when I added a second one in, so I added 2 to make it work and cleaned up some clutter I had created with commented code and such, then I ran it again and it didn't check the checkbox on either click. The funny thing is that I am getting focus on the checkbox.
Could this be an issue when there are certain security measures in place for the code? Is there a workaround for this?
Not sure if it matters but I am using XUnit for the testing framework.
[Then(@"I check the '(.*)' checkbox")]
public void ThenICheckTheCheckbox(string checkBoxId)
{
var checkBox = Ie.FindElementById(checkBoxId);
var isChecked = checkBox.Selected;
if (!isChecked)
{
checkBox.Click();
checkBox.Click();
isChecked = checkBox.Selected;
}
Assert.True(isChecked, $"the checkbox with id of: {checkBoxId}, is not checked");
}
The HTML for the checkbox is this
<input class="check-box" data-val="true" data-val-required="The Is Active field is required."
id="IsActive" name="IsActive" type="checkbox" value="true">
IsActive
@user1519137 it has been over a year, I would have to find this code again.