Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Objectify the Screenplay: A Story of Patterns

Objectify the Screenplay: A Story of Patterns

QA: Challenge Accepted 3.0 presentation

apetkova

March 18, 2017
Tweet

More Decks by apetkova

Other Decks in Technology

Transcript

  1. A STORY OF PATTERNS

    View full-size slide

  2. About Me
    Aneta Petkova
    Automation QA Lead,
    Honeywell Aerospace
    [email protected]
    linkedin.com/in/apetkova/

    View full-size slide

  3. Overview
    Journey #1: Back in time
    ••The PageObject pattern
    Journey #2: Into the now
    ••The Screenplay pattern
    Journey #3: Looking at tomorrow
    ••No spoilers yet

    View full-size slide

  4. Why should we care
    about patterns?

    View full-size slide

  5. The PageObject

    View full-size slide

  6. PageObject: concept
    Web
    Page
    Page
    class Test
    Separation: Keeping things tidy

    View full-size slide

  7. PageObject: structure
    WebDriver config

    View full-size slide

  8. PageObject: structure
    WebDriver config
    Page Object classes

    View full-size slide

  9. PageObject: structure
    WebDriver config
    Page Object classes
    Test classes

    View full-size slide

  10. PageObject
    Web Java
    private WebElement
    folderNameLabel;
    private WebElement
    downloadAllLink;
    private List
    files;
    public void sortByName();
    public void downloadAll();

    View full-size slide

  11. PageObject
    The test method
    @Test
    public void sortTest() {
    BrowseFolderPage page =
    new BrowseFolderPage();
    page.sortFilesByName();
    List actualFileNames = page.getFileNames();
    List expectedFileNames = new
    ArrayList(actualFileNames);
    expectedFileNames.sort();
    Assert.assertEquals(actualFileNames, expectedFileNames,
    "File names do not match");
    }

    View full-size slide

  12. PageObject
    The test method
    @Test
    public void sortTest() {
    BrowseFolderPage page = new BrowseFolderPage();
    page.sortFilesByName();
    List actualFileNames = page.getFileNames();
    List expectedFileNames = new
    ArrayList(actualFileNames);
    expectedFileNames.sort();
    Assert.assertEquals(actualFileNames, expectedFileNames,
    "File names do not match");
    }

    View full-size slide

  13. PageObject
    The test method
    @Test
    public void sortTest() {
    BrowseFolderPage page = new BrowseFolderPage();
    page.sortFilesByName();
    List actualFileNames =
    page.getFileNames();
    List expectedFileNames = new
    ArrayList(actualFileNames);
    expectedFileNames.sort();
    Assert.assertEquals(actualFileNames, expectedFileNames,
    "File names do not match");
    }

    View full-size slide

  14. PageObject
    The test method
    @Test
    public void sortTest() {
    BrowseFolderPage page = new BrowseFolderPage();
    page.sortFilesByName();
    List actualFileNames = page.getFileNames();
    List expectedFileNames =
    new ArrayList(actualFileNames);
    expectedFileNames.sort();
    Assert.assertEquals(actualFileNames, expectedFileNames,
    "File names do not match");
    }
    baby_corgi.jpg
    cartoon_corgi.png
    snow_corgi.jpg

    View full-size slide

  15. PageObject
    The test method
    @Test
    public void sortTest() {
    BrowseFolderPage page = new BrowseFolderPage();
    page.sortFilesByName();
    List actualFileNames = page.getFileNames();
    List expectedFileNames = new
    ArrayList(actualFileNames);
    expectedFileNames.sort();
    Assert.assertEquals(actualFileNames,
    expectedFileNames, "File names do not match");
    }

    View full-size slide

  16. The PageObject

    View full-size slide

  17. The Screenplay pattern
    System functionality
    before system
    properties
    Actions
    before objects

    View full-size slide

  18. Screenplay: concept
    Actor

    View full-size slide

  19. Screenplay: concept
    Actor
    Abilities
    has

    View full-size slide

  20. Screenplay: concept
    Actor
    Abilities
    has
    Actions
    Tasks
    enable
    made up of
    performs

    View full-size slide

  21. Screenplay: concept
    Actor
    Abilities Actions
    Tasks
    has
    enable
    made up of
    performs
    Questions
    Elements
    Screen
    asks about the state of
    on the
    interact with

    View full-size slide

  22. Screenplay: library
    “Automated Acceptance
    Testing with Style”
    - and great reporting!
    /Thucydides.info

    View full-size slide

  23. Screenplay: structure
    Page Objects

    View full-size slide

  24. Screenplay: structure
    Tasks
    Page Objects

    View full-size slide

  25. Screenplay: structure
    State checks
    Tasks
    Page Objects

    View full-size slide

  26. Screenplay: structure
    Features -> tests
    State checks
    Tasks
    Page Objects

    View full-size slide

  27. Screenplay
    The PageObject class
    public static Target FOLDER_NAME =
    the(“Folder name label”).locatedBy(“#locator”);
    public static Target DOWNLOAD_ALL =
    the(“Download All link”).locatedBy(“#locator”);
    public static Target FILES =
    the(“List of files”).locatedBy(“#locator”);

    View full-size slide

  28. Screenplay
    The test method
    @Test
    public void
    should_be_able_to_sort_his_files_by_name() {
    roland.wasAbleTo(StartWith.aPopulatedFolder());
    roland.attemptsTo(SortFilesInFolder.by("Name"));
    roland.should(seeThat(FileList.displayed(),
    is(FileList.orderedBy(system))));
    }

    View full-size slide

  29. Screenplay
    The test method
    @Test
    public void should_be_able_to_sort_his_files_by_name() {
    roland.wasAbleTo(StartWith.aPopulatedFolder())
    roland.attemptsTo(SortFilesInFolder.by("Name"));
    roland.should(seeThat(FileList.displayed(),
    is(FileList.orderedBy(system))));
    }

    View full-size slide

  30. Screenplay
    The test method
    @Test
    public void should_be_able_to_sort_his_files_by_name() {
    roland.wasAbleTo(StartWith.aPopulatedFolder());
    roland.attemptsTo(SortFilesInFolder
    .by("Name"));
    roland.should(seeThat(FileList.displayed(),
    is(FileList.orderedBy(system))));
    }

    View full-size slide

  31. Screenplay
    The test method
    @Test
    public void should_be_able_to_sort_his_files_by_name() {
    roland.wasAbleTo(StartWith.aPopulatedFolder());
    roland.attemptsTo(SortFilesInFolder.by("Name"));
    roland.should(seeThat(FileList.displayed(),
    is(FileList.orderedBy(system))));
    }

    View full-size slide

  32. Serenity report

    View full-size slide

  33. Serenity report

    View full-size slide

  34. The middle ground

    View full-size slide

  35. The middle ground
    ØFocus on users, not asserts

    View full-size slide

  36. The middle ground
    ØFocus on users, not asserts
    ØKeep tasks in separate classes

    View full-size slide

  37. The middle ground
    ØFocus on users, not asserts
    ØKeep tasks in separate classes
    ØConsider relaxed encapsulation

    View full-size slide

  38. Define your own
    journey!

    View full-size slide

  39. [email protected]
    linkedin.com/in/apetkova

    View full-size slide