Skip to content

snapshots: Does waitForSelector happen after the JS in execute()? #538

Answered by Robdel12
thecristen asked this question in Support
Discussion options

You must be logged in to vote

Hey @thecristen! We haven't documented this yet (it's quite new and we've been occupied with a couple networking bugs since #513). We pass a waitFor function to execute, so you can make sure the page state is what you'd expect before executing your JavaScript. For example:

module.exports = async () => {
  return [
    {
      name: 'example 1',
      url: 'https://percy.io',
      execute: {
        async beforeResize({ waitFor }) {
          await waitFor(() => !!document.querySelector('.hero-main-image'), 5000);
        }
      }
    }
  ];
};

Or using your code:

[{
  name: '...',
  url: '...',
  async execute({ waitFor }) {
      // open each of the collapsed results
      await waitFor((

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wwilsman
Comment options

Answer selected by Robdel12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #531 on September 01, 2021 17:18.