Interacting with a web user interface
Common web user interface interactions include selecting items from dropdown lists, clicking elements like buttons and icons, filling in and submitting forms, and validating that elements contain specific text or are visible to the visitor.
Selecting dropdown items and clicking elements
The eShopOnWeb home page shows a shopping cart with a numeric badge showing the number of items in the cart, and it allows the visitor to filter the products by selecting from two dropdown lists and clicking an image. Let’s automate this:
- In
eShopWebUITests.cs
, statically import theAssertions
class so that we can use itsExpect
method, as shown in the following code:using static Microsoft.Playwright.Assertions; // To use Expect.
- In
eShopWebUITests.cs
, add a test to check that the shopping cart is empty and is visible to the visitor, as shown in the following code:[Fact] public async void HomePage_CartEmptyAndVisible...