Fetching contributors…
Cannot retrieve contributors at this time
302 lines (223 sloc) 10.4 KB


Browser (also called Driver) is the main entry point in each <step>, it's your direct connection to the browser running the test.

import { step } from "@flood/element"
export default () => {
  step("Start", async browser => {
    await browser.visit("")


Browser.authenticate([, username, password])

  • username <undefined | string> (Optional)
  • password <undefined | string> (Optional)
  • returns: <Promise<void>>

Sets the HTTP Authentication details to use if the page is presented with an authentication prompt.

Call without any args to disable authentication.


Removes focus from the specified DOM element.


Clears the selected value of an input or select control.


Clear browser cache.


Clear browser cookies.[, options])

Sends a click event to the element located at selector. If the element is currently outside the viewport it will first scroll to that element.


step("Start", async browser => {

In this example we're constructing a <Locatable> using the By.partialLinkText() Locator, which will match the first <a> tag which contains the text "Start".

Browser.doubleClick(locatable[, options])

Sends a double-click event to the element located by the supplied Locator or selector. If the element is currently outside the viewport it will first scroll to that element.


Configure Browser to emulate a given device

Browser.evaluate(fn, args)


Uses the provided locator to find the first element it matches, returning an ElementHandle. If no element is found throws an error.


Uses the provided locator to find all elements matching the locator condition, returning an array of ElementHandles


Makes the element located by the first argument the receiver of future input.


Highlight an element. Useful in concert with takeScreenshot to tweak your locators.


Uses the provided locator to find the first element it matches, returning an ElementHandle.[, options])

  • keyCode <string>
  • options <undefined | {"text":"undefined | string","delay":"undefined | number"}> (Optional)
  • returns: <Promise<void>>

Presses a key on the keyboard specified by key code. For example, <[Key.ALT]>

Browser.selectByIndex(locatable, index)

Selects an option within a <select> tag by its index in the list.

Browser.selectByText(locatable, text)

Selects an option within a <select> tag by matching its visible text.

Browser.selectByValue(locatable, values)

Selects an option within a <select> tag using the value of the <option> element.


  • keys <string[]>
  • returns: <Promise<void>>


  • userAgent <string>
  • returns: <Promise<void>>

Set Browser to send a custom User Agent (UA) string


Switch the focus of the browser to another frame, tab, or window.

Browser.takeScreenshot([, options])

Takes a screenshot of the whole page and saves it to the flood/results folder with a random sequential name. You can download the archive of your test results at the end of the test to retrieve these screenshots.


Browser.type(locatable, text[, options])

  • locatable <NullableLocatable>
  • text <string>
  • options <undefined | {"delay":"number"}> (Optional)
  • returns: <Promise<void>>

Types a string into an <input> control, key press by key press. Use this to fill inputs as though it was typed by the user.


step("Step 1", async browser => {
  await browser.type(By.css("#email"), "")

Browser.visit(url[, options])

  • url <string> url to visit

  • options <NavigationOptions> (Optional) puppeteer navigation options

  • returns: <Promise<void>>

Instructs the browser to navigate to a specific page. This is typically used as the entrypoint to your test, as the first instruction it is also responsible for creating a new Browser tab for this page to load into.


step("Start", async browser => {
  await browser.visit("")


Creates a waiter which will pause the test until a condition is met or a timeout is reached. This can be used for validation or control flow.

Check out <Until> for a rich set of wait <Condition>s.


step("Start", async browser => {
  await browser.wait(Until.elementIsVisible(By.css('h1.title')))

You can use either a numeric value in seconds to wait for a specific time, or a <Condition>, for more flexible conditions.



Driver is an alias to Browser. Please use Browser when possible.


Locatable represents anything able to be located, either a string selector or a <Locator>. <Locator>s are generally created using <By> methods.

[Locator] | [ElementHandle] | string


NullableLocatable represents a <Locatable> which could also be null.

Note that most Element location API methods accept a NullableLocatable but will throw an <Error> if its actually <null>.

[Locatable] | null



  • height <number> The height.
  • width <number> The width.
  • x <number> The x-coordinate of top-left corner.
  • y <number> The y-coordinate of top-left corner.



  • button <MouseButtons> (Optional) defaults to left
  • clickCount <number> (Optional) defaults to 1
  • delay <number> (Optional) Time to wait between mousedown and mouseup in milliseconds.
    Defaults to 0.


The navigation options.


  • timeout <number> (Optional) Maximum navigation time in milliseconds, pass 0 to disable timeout.
  • waitUntil <LoadEvent | LoadEvent[]> (Optional) When to consider navigation succeeded.


Defines the screenshot options.


  • clip <BoundingBox> (Optional) An object which specifies clipping region of the page.
  • fullPage <boolean> (Optional) When true, takes a screenshot of the full scrollable page.
  • omitBackground <boolean> (Optional) Hides default white background and allows capturing screenshots with transparency.
  • path <string> (Optional) The file path to save the image to. The screenshot type will be inferred from file extension.
    If path is a relative path, then it is resolved relative to current working directory.
    If no path is provided, the image won't be saved to the disk.
  • quality <number> (Optional) The quality of the image, between 0-100. Not applicable to png images.
  • type <"jpeg" | "png"> (Optional) The screenshot type.


"load" | "domcontentloaded" | "networkidle0" | "networkidle2"