chris
chris

Reputation: 119

having issues while clicking on a dropdown window with edit or delete button inside the dropdown

compare 1 with 2 & 1 with 3, can click edit when I exclude await from expect or when I do await t.expect with await

1.

await t.expect(DetailsPage.commentsBody.find(`.dropdown-menu.show`).exists).ok(`comments drop down menu unavailable`)
       .click(DetailsPage.edit) //  ***----- doesn't clicks and throws error***  
       .expect(await DetailsPage.addCommentWindow.value).eql(comData.comment);

2.

await t.expect(DetailsPage.commentsBody.find(`.dropdown-menu.show`).exists).ok(`comments drop down menu unavailable`)
       .click(DetailsPage.edit)  // **----- does click and no error**
       .expect(DetailsPage.addCommentWindow.value).eql(comData.comment);

3.

await t.expect(DetailsPage.commentsBody.find(`.dropdown-menu.show`).exists).ok(`comments drop down menu unavailable`)
       .click(DetailsPage.edit);  // **----- does click and no error**

await t.expect(await DetailsPage.addCommentWindow.value).eql(comData.comment);

Upvotes: 1

Views: 160

Answers (1)

Alexey Lindberg
Alexey Lindberg

Reputation: 766

Option 2 is the right one. You should never use await in expect. TestCafe awaits selector promises and does it at the right moment of the time and during the specified timeout. Option 1 doesn't work because you forced the DetailsPage.addCommentWindow.value evaluation before DetailsPage.edit is clicked.

Upvotes: 3

Related Questions