Playwright Integration improvement and integration with playwright test #2722
Replies: 5 comments 15 replies
-
thanks for the feedback @Romarionijim! we're going to address most of the items over time. You're right in that some glue code needs to be written to hook up existing Playwright code to Artillery for load testing. Most of the time the amount of work that needs to be done is fairly small/straightforward. It will reduce over time. TypeScript support is marked as experimental, but it works for most existing test suites. Have you tried it with your code?
The YAML part is Artillery-specific and that won't go away because ultimately running a load test is different and requires a different configuration from running an end-to-end test. Even when we provide a JavaScript/TypeScript interface instead of the YAML-based one, you'll still have to provide the same configuration.
We'll improve the docs around this. The recommended way is to set success conditions with the This is one area where load testing is very different from end-to-end testing. The definition of a successful load test is very application/test specific. It's not as binary as pass/fail for other types of tests. The |
Beta Was this translation helpful? Give feedback.
-
@hassy Thank you for the response. regarding point 1: the thing is that it is still an overhead and a code duplication, for example here is a login class that performs a login flow: import { LumaMainPage } from "../LumaMainPage";
import { ClientSideValiationErrorOptionalParamsInterface } from "../../helpers/optionalParamsInterfaces/OptionalParams";
export class LoginPage extends LumaMainPage {
private emailFieldLocator = '[name="login[username]"]';
private passwordFieldLocator = '[name="login[password]"]';
public async login(email: string = process.env.EMAIL as string, password: string = process.env.PASSWORD as string,
options?: ClientSideValiationErrorOptionalParamsInterface & { negativeTest?: boolean, expectedErrorCount?: number }) {
const emailField = this.page.locator(this.emailFieldLocator);
const passwordField = this.page.locator(this.passwordFieldLocator);
const loggedInState = await this.getLoggedInState();
if (loggedInState === 'not-logged-in') {
await this.clickSignIn();
await this.fillText(emailField, email);
await this.fillText(passwordField, password);
const signInButton = this.page.getByRole('button', { name: 'Sign In' });
await this.clickElement(signInButton);
await this.page.waitForTimeout(2500);
}
if (options?.negativeTest && options.expectedErrorCount !== undefined) {
await this.handleClientSideValidationErrors(options.expectedErrorCount, [emailField, passwordField], options)
}
}
} in order for me to use it in Artillery yml, I need to create login-flow.js file: export async function login() {
const emailField = this.page.locator(this.emailFieldLocator);
const passwordField = this.page.locator(this.passwordFieldLocator);
const loggedInState = await this.getLoggedInState();
if (loggedInState === 'not-logged-in') {
await this.clickSignIn();
await this.fillText(emailField, email);
await this.fillText(passwordField, password);
const signInButton = this.page.getByRole('button', { name: 'Sign In' });
await this.clickElement(signInButton);
await this.page.waitForTimeout(2500);
} and then call this login function from this js file I could also just create an object of the login page inside the async function in the js file but it is still a sort of duplication since I have the same exact functionality in 2 different files. As for TS - I still have not tried it but I'm a little doubt in it since it is marked as experimental because if my whole codebase is in TS and some may not work, then I need to convert to JS and make these adjustments. |
Beta Was this translation helpful? Give feedback.
-
Hi @Romarionijim, You don't need to convert it to a Javascript file, you should just try out the Typescript support. There's an example here of reusing Typescript code: https://github.com/artilleryio/artillery/tree/main/examples/browser-playwright-reuse-typescript . The general idea is that you abstract anything you need into reusable code that can be used by both your Functional and Load Tests, which sounds very similar to what you want anyway. I understand it's marked as Experimental, but there are currently no open issues we are aware of that users have hit with Typescript support. |
Beta Was this translation helpful? Give feedback.
-
@bernardobridge I understand, I will try it with TS for sure but My issue is not with the programming language, My issue is the code duplication and having to create another abstraction which seems a bit redundant IMO because I'm already abstracting the code and logic in my page objects, in case of artillery your aiming to achieve the same exact flow in the "abstracted function" while you already have it abstracted, so why not use the function directly from the page object inside the yml file? similar to end to end. |
Beta Was this translation helpful? Give feedback.
-
@bernardobridge @hassy and If I have a backend framework using playwright as well (it also supports api testing) and my framework is written in OOP style, similar to POM but for the backend, in this case, can I leverage playwright as well? for example, I have this ApiClient class the serves as a BaseClass for Api, here is some of the code, can I create a processer from these functions and use the playwright engine or do I need to recreate the backend from the other suggested engines such as HTTP engine? code example: ` constructor(public request: APIRequestContext) { public async paginateRequest(method: RequestMethod, url: string, pagintionType: PaginationType, options: ApiOptionalParams) {
} |
Beta Was this translation helpful? Give feedback.
-
Hello, First of all, kudos for making an integration with playwright, I've been diving into automation performance/load testing, I currently use Playwright with TS and I'm researching a tool that I can perform load testing while integrating Playwright and leverage existing framework, I have gone through the documentation and articles and I came across issues that I would love for them to be added in order to consider implementing artillery at my workplace.
While the first two suggestions are more important and critical for me (leverage existing POM framework and 100% support for TS and playwright test) - I would very much appreciate if you could address these issues and make these improvements, I think these improvements will very much help to decide to choose artillery over any other performance tool that has integration with playwright.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions