Handling Dropdowns | Advanced Playwright TypeScript Tutorial | Part VII | LambdaTest
Dive into the world of Playwright with TypeScript in this detailed tutorial by Vignesh Srinivasan, a seasoned expert in automation testing. In this session, you’ll learn how to handle various types of dropdowns with ease. From static dropdowns (single and multi-select) to dynamic dropdowns (searchable and non-searchable), this video breaks down every concept step-by-step.
Discover how to identify dropdown types using DOM attributes, write efficient locators, and implement robust assertions to verify your test cases. Whether it’s selecting options by value, label, or index for static dropdowns, or handling dynamic dropdowns with custom logic, this tutorial has got you covered.
By the end of this session, you’ll have the skills to tackle dropdown automation challenges like a pro. Perfect for testers and developers looking to level up their Playwright expertise!
00:00 - Introduction
01:09 - What is a Dropdown?
05:01 - Handling Single Static Dropdown
08:55 - Handling Multi Static Dropdown
12:19 - Handling Dynamic Searchable Dropdown
17:16 - Handling Dynamic Non-Searchable Dropdown
22:17 - Code Execution & Review
29:06 - Closing Words
Introduction to Dropdowns
Dropdowns allow users to select from multiple options. The video categorizes dropdowns into:
Static Dropdowns: Defined using the <select> tag, with fixed values.
Dynamic Dropdowns: Values change dynamically based on user input or API responses.
Static dropdowns are further divided into single and multi-select, while dynamic dropdowns include searchable and non-searchable variants.
Static Dropdowns
a. Single Static Dropdown
Recognizable by the <select> tag.
Options are fixed and can be selected using the selectOption() method in Playwright.
Values can be selected by:
Value: Matches the value attribute of the <option> tag. Label: Matches the display text. Index: Matches the position of the option.
b. Multi-Static Dropdown
Similar to single static dropdowns but allows selection of multiple values.
Uses an array to pass multiple values to the selectOption() method.
Assertions ensure values are selected in the correct order.
Dynamic Dropdowns
a. Searchable Dynamic Dropdown
Includes a search bar where users can type to filter options.
Requires custom handling, as Playwright does not have a built-in method like selectOption() for dynamic dropdowns.
Steps involve:
Typing into the search bar.
Selecting the desired option dynamically.
b. Non-Searchable Dynamic Dropdown
Does not have a search bar.
Options are identified and selected using locators such as click() and custom logic.
Practical Demonstrations
The video includes practical examples:
Writing scripts to handle all dropdown types.
Navigating locators, writing assertions, and integrating tests with LambdaTest.
Handling dynamic dropdowns by combining locators and interaction methods.
Key Takeaways
Static dropdowns are straightforward to automate using the selectOption() method.
Dynamic dropdowns require additional steps, such as locating elements dynamically and handling filtered results.
Assertions verify that dropdown interactions behave as expected.
This tutorial is part of a series designed to help testers and developers automate UI interactions efficiently using Playwright with TypeScript.
Playwright End To End Testing Tutorial: A Complete Guide
Playwright Tutorial: Getting Started With Playwright Framework
Vignesh Srinivasan
Vignesh is a Senior Automation Engineer with over 8 years of experience in web, mobile, API automation, and performance testing. He is skilled in programming languages like Java, JavaScript, Kotlin, Python, and Scala. Vignesh focuses on sharing practical knowledge to help others build the skills and confidence needed confidence needed to excel in test automation.
Handling Dropdowns | Advanced Playwright TypeScript Tutorial | Part VII
Advanced Playwright TypeScript TutorialHandling Alerts | Advanced Playwright TypeScript Tutorial | Part VIII
Advanced Playwright TypeScript TutorialHandling UI Elements: TextBox, Button, & Checkbox | Advanced Playwright TypeScript Tutorial | Part VI
Advanced Playwright TypeScript TutorialUnderstanding Playwright Assertions | Advanced Playwright TypeScript Tutorial | Part V
Advanced Playwright TypeScript TutorialAdvanced Playwright TypeScript Tutorial | Locator Strategies | Part IV
Advanced Playwright TypeScript TutorialAdvanced Playwright TypeScript Tutorial | Trace Viewer & Debugging | Part III | LambdaTest
Advanced Playwright TypeScript Tutorial