Testcafe: How do I wait for an element that exists in a page for API Call

Created on 30 Jul 2018  路  5Comments  路  Source: DevExpress/testcafe

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

How do I wait for an element that exists in a page for API Call

What is the expected behavior?

My Testcase failed if the element is not present at that time

How would you reproduce the current behavior (if this is a bug)?

Click a button, It goes to the next page, I wanna click a button there. But that button would be shown after five minutes(API call).

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

  const activityBtn = Selector('#getstartedHBtn');
  test('TestReport', async t => {
  await t
 .click(".btn.deploy.right") 
  const activityBtnElement1 = await activityBtn.with({ visibilityCheck: true })()
 .click(activityBtn)
    });

Specify your

Auto-locked question

Most helpful comment

@raja1313 : testcafe snippets might help you to handle your business case correctly

All 5 comments

Hi @raja1313, I guess you should specify the timeout option for the Selector of the button.

Hi @AndreyBelym, The time varies for every run of test cases.
For Example: In my case, The button only displayed when the status got 200. Here I wanna wait for the button to be visible and then click, But testcafe doesn't wait for too much of time, How can I handle for this situations?

Thanks in advance!

@raja1313 : testcafe snippets might help you to handle your business case correctly

@raja1313

Please specify the timeout option for the Selector of your button.

const button = Selector('you button selector', { timeout: 60000});

await t.click(button);

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

Was this page helpful?
0 / 5 - 0 ratings