Skip to content

Feature: Giving BDD format use case(s) as a prompt to same auto() function #44

@pareshkrc

Description

@pareshkrc

Assume you have a story written by POs and BA and you want to use the use cases defined in the same story to automate and execute tests.

Format of the use case is in BDD format.

e.g.

GIVEN, I am on a [google.com](http://google.com/) page
WHEN, I search for a world called Auto-Playwright
THEN, check top 5 search results, and confirms that Auto-Playwright is present

or Can also have multiple use cases appended with AND as shown below -

GIVEN, I am on a [google.com](http://google.com/) page
WHEN, I search for a world called Auto-Playwright
THEN, check top 5 search result, and confirm that the "Auto-Playwright" is present
AND
GIVEN, I am on a [google.com](http://google.com/) page
WHEN, I search for a world called Playwright
THEN, check top search result, and confirm that "Playwright" is present

We did a workaround (something similar to below) to make it work, but do you think this is an ideal solution? It will be great if we have BDD support in Auto-Playwright itself.

test('Validate Google Search Result ', async ({ page }) => {
        let results: any = await autoBDD(storyContent, page, test, options)
        expect(results[2]).toBe(true)
})

And here how we are handling BDD format use case by giving additional instruction in the prompt.

let commonText = `
Please follow the below instruction and execute the below statements.
    Instructions:
        • GIVEN is a precondition that you need to validate if it's true.
        • If you find a WHEN statement, validate that condition and execute the statement and return result.
        • If you find a THEN statement, execute the statement and validate the condition and return a value.
        • While validating text comparison, follow below instructions:
            • Compare text with case insensitive
            • remove any trailing or leading spaces before comparison.
            • If you are comparing a substring, use the "contains" keyword.
            • Don't use exact match unless it is specified, use contains keyword.
    Statements:
    `

export async function autoBDD(storyContent, page, test, options) {
    let storyPrompts = storyContent.split('\n')
    let results = []
    for (let storyPrompt of storyPrompts) {
        results.push(await auto(`${commonText}${storyPrompt}`, { page, test }, options))
    }
    return results
}

I think this will be very useful in a long term.

What do you all think about adding a support for BDD format prompt?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions