Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Atata: Unable to locate CheckBox elements

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:

enter image description here

like image 230
Dimitar Stoyanov Avatar asked Jan 29 '26 23:01

Dimitar Stoyanov


1 Answers

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

like image 125
Yevgeniy Shunevych Avatar answered Feb 01 '26 11:02

Yevgeniy Shunevych



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!