I receive an error when I use [VerifyExists]
on a CheckBox
element, although when I use the XPath
that is generated via the framework i can find the element.
Error message:
Message: OpenQA.Selenium.NoSuchElementException : Unable to locate element: By.XPath: .//*[normalize-space(@id) = 'active-checker']/descendant-or-self::input[@type='checkbox']
Implementation:
[VerifyExists]
[FindById("isCommentRequred-checker")]
public CheckBox<_> RequestsWorklogCommentCheckBox { get; private set; }
Manual search for element:
I guess that it is because actual <input type="checkbox">
is invisible (or has opacity: 0
) on the page. Atata by default for most controls filters elements by visibility during control element search and leaves only visible elements.
Try to set Visibility = Visibility.Any
:
[FindById("isCommentRequred-checker", Visibility = Visibility.Any)]
Often checkboxes and radio buttons are made invisible and other element renders it and receives clicks. Just inspect HTML and then try to click it with Atata or with pure WebDriver. If it throws exception, you will probably need to implement custom control for it to click for example span.control-label
element.
Here is example of control for Kendo UI CheckBox: https://github.com/atata-framework/atata-kendoui/blob/master/src/Atata.KendoUI/KendoCheckBox%601.cs