end-to-end

End to end

A complete example: load a form, fill it, submit it, and assert the result.

The fixture is a small HTML form. The button writes a greeting into a result node when clicked:

<form id="signup">
  <input id="username" type="text" value="">

  <button id="submit" type="button"
    onclick="document.getElementById('welcome').textContent = 'Welcome, ' + document.getElementById('username').value;">
    Sign up
  </button>

  <p id="welcome"></p>
</form>

The spec drives it through playwright-page and the matchers:

use BDD::Behave;
use BDD::Behave::Playwright;

describe 'signing up', {
  playwright-page(fixture => 'specs/fixtures/form.html');

  it 'greets the user after the form is submitted', {
    page.locator('#username').fill('Ada');
    page.locator('#submit').click;

    expect(page.locator('#welcome')).to.have-text('Welcome, Ada');
  }
}

playwright-page opens a fresh page on the fixture for the example. The page term (from use BDD::Behave::Playwright) returns that page. The action methods (fill, click) come from WWW::Playwright's Locator; have-text polls until the greeting appears, so there is no explicit wait.

BDD::Behave::Playwright v0.9.1

Browser lifecycle hooks and Playwright-aware matchers for BDD::Behave examples

Authors

  • Greg Donald

License

Artistic-2.0

Dependencies

BDD::Behave:auth<zef:gdonald>WWW::Playwright:auth<zef:gdonald>

Provides

  • BDD::Behave::Playwright
  • BDD::Behave::Playwright::Diagnostics
  • BDD::Behave::Playwright::Lifecycle
  • BDD::Behave::Playwright::Matchers
  • BDD::Behave::Playwright::Session

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.