Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Locator.WaitFor for detached and hidden states #852

Merged
merged 5 commits into from
Apr 25, 2023

Commits on Apr 25, 2023

  1. Fix injected script wait for hidden state selector

    This commit fixes the condition to wait for a 'hidden' state for a JS
    element. Now, when the condition is met (the element is no longer
    visible), waitForSelector function returns the element, as this is
    still a valid element in the DOM, instead of returning undefined.
    
    This will make the call made from the wrapper function
    'waitForPredicateFunction':
        return predicateFn(...args) || continuePolling;
    evaluate to true and return the JS element instead of hanging on an
    infinite loop.
    ka3de committed Apr 25, 2023
    Configuration menu
    Copy the full SHA
    47398d1 View commit details
    Browse the repository at this point in the history
  2. Add Frame.waitFor method

    This will allow waiting for a selector for which we do not expect an
    ElementHandle as return. This is useful for example when waiting for
    'detached' events.
    ka3de committed Apr 25, 2023
    Configuration menu
    Copy the full SHA
    fe1852d View commit details
    Browse the repository at this point in the history
  3. Fix wait for detached selector

    This commit fixes waiting for a selector to be in 'detached' state.
    Fixes the injected_script wait for selector condition for 'detached'
    state, that was returning 'undefined' which eventually caused an
    infinite loop from the calling polling function
    'waitForPredicateFunction' due to the call:
        return predicateFn(...args) || continuePolling;
    As 'undefined' returned from the predicate function resulted in
    returning 'continuePolling' from this condition.
    
    Also modifies the Locator.waitFor method in order to call the
    Frame.waitFor method, instead of Frame.waitForSelector, as in this case,
    we do not need to retrieve the associated ElementHandle for the
    selector.
    ka3de committed Apr 25, 2023
    Configuration menu
    Copy the full SHA
    9e36fdc View commit details
    Browse the repository at this point in the history
  4. Refactor locator WaitFor test

    Rename the current test case for WaitFor method in the locator test in
    order to specify that the state that it's waiting for by default is the
    'visible' state. This is also done in order to be coherent when adding
    more test cases for the other supported states.
    ka3de committed Apr 25, 2023
    Configuration menu
    Copy the full SHA
    8d0b0a9 View commit details
    Browse the repository at this point in the history
  5. Add state test cases for locator WaitFor test

    Adds test cases for each supported state by locator WaitFor method.
    ka3de committed Apr 25, 2023
    Configuration menu
    Copy the full SHA
    01a3aa2 View commit details
    Browse the repository at this point in the history