Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pareshkrc opened this issue Oct 24, 2024 · 0 comments

Comments

@pareshkrc
Copy link

pareshkrc commented Oct 24, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant