Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hasclass doesn't work with testcafe CSS selectors

I am using testcafe version - 1.6.1

I am trying to apply an assertion to see if an element is clickable or not (expect to not be clickable).

I've found the elements class name and a dynamic sibling class which appears to not be clickable in the browser element.

I've attached two snapshots below of the actual UI element and its DOM:

  • The element in the UI I want to detect

  • chrome dev-tools Elements

for some unknown reason, the hasclass function keeps failing because the required class cannot be found.

.expect()buttonEssentialplan30Mb.hasClass('.c-form-plan-box--disabled')).ok()

like image 858
teslaTanch Avatar asked Sep 18 '25 00:09

teslaTanch


1 Answers

The correct code for your scenario is

await t.expect(buttonEssentialplan30Mb.hasClass('c-form-plan-box--disabled')).ok()
like image 96
mlosev Avatar answered Sep 20 '25 14:09

mlosev