Running tests

requires to have a local prestashop running. google "prestashop docker" for a convenient way to do that.

Slides

image

image

image

  • show SUT
  • show test
  • run test
  • show report
  • start POM
    • it's ProductSlider, not Home because components!
  • refactor all to POM
    • "ich hab da mal was vorbreitet"
  • adapt the report, use test.step
    • introduce everywhere
  • create steps package, point out duplication in function names and test.step
  • describe screenplay
    • image
    • we'll do a minimalistic implementation
    • ignore abilities and questions
  • implement:
    • start with new Actor(name)
    • add actor attemptsTo for first step
    • add test.step
    • add actor has page
import {test} from "@playwright/test";

export class Actor {
    page;

    constructor(name) {
        this.name = name;
    }

    attemptsTo = async (...tasks) => {
        for (const task of tasks) {
            const transform = str => str.replace(/[A-Z]/g, letter => ` ${letter.toLowerCase()}`);
            let title = this.name + " attempts to " + (task.args !== undefined ?
                transform(task.constructor.name) + " " + JSON.stringify(task.args) :
                transform(task.constructor.name));
            await test.step(title, async () => await task.performAs(this))
        }
    }
}
  • add second step, call both in attemptsTo

  • add an ensure task

  • [ ]replace FIllPersonalData, introduce notepad, replace product name

  • replace all in order product

    • see. no POM needed
      • well, I lied, show locator object
  • this is what the script might look like when we use screenplay (result, main branch)

  • questions? and did you just add an assert in the steps

  • benefits:

    • easy modeling multiple actors, user and admin
    • nice reports
    • does also encompas other interfaces, write steps for API, DB, ....
  • drawbacks

    • tons of actions, findability, accidental duplication...
    • stacktrace indirection, another layer, error in attemptsTo
    • sharing state between steps, remember/recall is unusual and might get unwieldy

image https://hpmor.com/

image https://serenitydojo.teachable.com/ https://serenity-js.org/