Skip to content

Latest commit

 

History

History

wait-for-navigation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

waitForNavigation(tab)

Waits for a page load to complete

Example

import {
  openBrowser, openTab, findElement, clickElement, waitForNavigation
} from 'puppet-strings'

async function run() {
  const browser = await openBrowser('google-chrome')
  const tab = await openTab(browser, 'https://npmjs.com')

  const lodashLink = await findElement(tab, 'a', 'lodash')
  clickElement(lodashLink)

  await waitForNavigation(tab)
}

run()

Parameters

Returns

  • promise (Promise)

Details

For actions that cause a separate page to be loaded, like

  • Clicking on a link
  • Submitting a native form
  • Being redirected by application code

it is currently necessary to waitForNavigation before performing further actions.

waitForNavigation waits until the page is fully loaded and has not made a network request for 500ms. Note that WebSocket connections are ignored.

openTab will always wait for the page to finish loading. So, when opening a new tab, it's unnecessary to also waitForNavigation.