Skip to content

help with using WaitUntil when passing $$ selected page object elements to a separate function #12001

Answered by christian-bromann
troyyer asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @troyyer , thanks for providing the example, it made things very clear. As you already have mentioned above when fetching elements through WebdriverIO, you will obtain an element reference which doesn't update unless you refetch it. In your function you pass in an element reference (of an empty element array) and continue to ask for the length which always remains 0. A workaround would be:

async waitUntilArrayNotEmpty(webElementArray, timeout = 15000, timeoutMsg = '') {
  await browser.waitUntil(
    async () => (await $$(webElementArray.selector)).length >= 1,
    { timeout, timeoutMsg }
  );
};

The selector property enables you to make the same request again and get an updated value…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@christian-bromann
Comment options

Comment options

You must be logged in to vote
3 replies
@christian-bromann
Comment options

Answer selected by troyyer
@troyyer
Comment options

@christian-bromann
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants