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.

UI testing click action

UI testing click action

In this test, we'll go ahead and make sure a element changes upon a click action. That is, hey, if I go ahead and click this button, you can see it changes to the green color. So if I go ahead and inspect the same while doing it again, you can see it is a button with the class of button and button primary. If I go ahead and click it, you can see it gets the button and button-success class. So we have to expect the same when we click on it. Now we can go ahead and locate it either using its text or its ID. I'll go ahead and use its text because we have that. Now let's go ahead and write our test. First of all, we'll locate our button that is page get by role. rule is a button and the name is this right here again you can just use a part of this text but i will keep the whole now i can go ahead and click the button and after the click event we should expect this button to have this class right here that is button button hyphen success so we can simply go ahead and expect our button to…

Contents