From the course: Playwright Essential Training: Abstractions, Fixtures, and Complex Scenarios

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Working with challenging elements in Playwright

Working with challenging elements in Playwright

- [Instructor] When automating web applications with poor accessibility, you'll find yourself having to get creative in order to find certain elements you want to interact with. In this example, we're going to look at the menu page, which includes a table with three rows. So, on our test site, let's go ahead and click Menu. We'll walk through three different ways that you can build locators in order to find a specific add-to-cart button, which matches a specific bagel type. As we inspect these different rows, you can notice there's not a lot of things that are unique in this table. So, let's go ahead and write some code. Our specific flow will be to test the add-to-cart functionality for the sesame bagel type. When I click Add to Cart, I'm going to validate that we're going to add sesame bagel to cart, and we'll validate this message as well. All right, so let's get into the code. We're going to create a new test in the bagel shop directory. The new file is going to be called…

Contents