Menu
Documentationbreadcrumb arrow Grafana k6breadcrumb arrow JavaScript APIbreadcrumb arrow k6/browserbreadcrumb arrow Framebreadcrumb arrow waitForLoadState(state[, options])
Open source

waitForLoadState(state[, options])

Caution

This method has known issues. For details, refer to #880.

This waits for the given load state to be reached. It will immediately unblock if that lifecycle event has already been received.

ParameterTypeDefaultDescription
statestringloadOptional load state to wait for. See Events for more details.
optionsobjectnull
options.timeoutnumber30000Maximum time in milliseconds. Pass 0 to disable the timeout. Default is overridden by the setDefaultTimeout option on BrowserContext or Page.

Events

Caution

networkidle is DISCOURAGED. Don’t use this method for testing especially with chatty websites where the event may never fire, rely on web assertions to assess readiness instead.

Events can be either:

  • 'domcontentloaded' - consider operation to be finished when the DOMContentLoaded event is fired.
  • 'load' - consider operation to be finished when the load event is fired.
  • 'networkidle' - Consider operation to be finished when there are no network connections for at least 500 ms.

Returns

TypeDescription
Promise<void>A Promise that fulfills when the load state is reached.