Methods Parametrization | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Page Objects
Instructor: Artem Bondar
Lesson Summary
Lesson Overview: This lesson focuses on parametrizing page object methods to enhance their versatility and flexibility within a testing framework. Key Concepts: Parametrization: Increases the reusability of methods across different test scenarios. Descriptive Method Names: Use clear and descriptive names for methods to improve navigation and understanding. Implementation Steps: Create a new page object class: FormLayoutsPage.ts . Define a method to submit a form using a grid layout: async submitUsingGrid(email: string, password: string, optionText: string) { ... } Fill out the form fields using parameters for email , password , and optionText . Implement a second method for submitting an inline form: async submitInlineForm(name: string, email: string, rememberMe: boolean) { ... } Testing the Methods: Import the FormLayoutsPage in your test file. Create an instance of the page object and call the methods with appropriate parameters. Example of calling the grid submission method: await formLayoutsPage.submitUsingGrid('[email protected]', 'welcome1', 'option1'); Run tests with different parameters to validate functionality. Documentation and Annotations: Utilize comments and annotations to provide descriptions for methods and parameters, enhancing code readability and usability. Conclusion: By parametrizing methods, you can create flexible and reusable code that simplifies testing different scenarios while maintaining clarity through descriptive naming and documentation.