After years of utilizing Selenium, SpecFlow, NUnit, and other testing tools, I have recently delved into Playwright with TS. My goal is to interact with the AzureDevOps API to mark tests as automated only if they contain a specific tag in the test title (e.g. @123456).
test('shows error on invalid login details, @loginerror @123456', async () => {
await loginPage.login(loginDetails_workingUsers[0].username, 'invalidPwd')
await expect(loginPage.usernameInput).toHaveAttribute('class', /error$/)
await expect(loginPage.passwordInput).toHaveAttribute('class', /error$/);
await expect(loginPage.errorMsg).toHaveText('Epic sadface: Username and password do not match any user in this service')
})
I am looking for a way to call an API whenever a certain @tag appears in a test title, without having to include this logic in every individual test method.
In my past experience with SpecFlow, I accessed ScenarioContext in [AfterScenario/BeforeScenario], while in other frameworks, I used custom attribute [AssociatedAutomation(123456)]. However, in Playwright, I can only seem to access the test title via testInfo within a test method.
The ideal solution would be to access testInfo in a test.beforeEach but outside of the test classes.
Any guidance or support on how to achieve this would be greatly appreciated!
I have attempted to access testInfo.title within a test method or in test.beforeEach within a test class, but it did not yield the desired outcome.