javascript - hasclass doesn't work with testcafe CSS selectors - Stack Overflow

I am using testcafe version - 1.6.1I am trying to apply an assertion to see if an element is clickable

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()

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()

Share Improve this question edited Feb 4, 2020 at 9:15 teslaTanch asked Feb 3, 2020 at 10:47 teslaTanchteslaTanch 931 silver badge9 bronze badges 3
  • 6 I'm pretty certain that a method called hasClass would take a class name parameter, not a class selector. Try omitting the . prefix. – Bergi Commented Feb 3, 2020 at 10:49
  • tried added the ., same issue – teslaTanch Commented Feb 3, 2020 at 11:01
  • 3 And I kinda doubt that .expect()buttonEssentialplan30Mb is even valid syntax to begin with. Please provide a proper minimal reproducible example of what you are doing. – 04FS Commented Feb 3, 2020 at 12:07
Add a ment  | 

1 Answer 1

Reset to default 10

The correct code for your scenario is

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744310696a4567931.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信