From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Assertions checkbox

Assertions checkbox

In this lesson, we'll learn how to expect a checkbox or a radio button to be checked that is selected. So for the test, we'll use bootswatch.com and here we have checkboxes, one which is unchecked by default and the other one which is checked by default. We can select the same using its label because it is an input field with a label and the role is type of checkbox. So let's go ahead and just locate the same. So checked checkbox and I can go ahead and just use page get by label locator and the label is checked checkbox. can go ahead and select the default checkbox as well. So default checkbox and here it says default checkbox as the label. Now by default this should be expected to be checked and this should be expected to be unchecked. So we can go ahead and just use expect the checked checkbox to be checked using this method and similarly we can make sure that the default checkbox comes unchecked using expect the default checkbox not to be checked like this now i can go ahead and…

Contents