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 element state

Assertions element state

In this lesson we'll learn about how to expect the different element states of any element that is our locator. So here I have the linked element which we can expect to be visible, to be hidden or to be enabled. So the first thing is to just pass this to our expect like this and we can say something to be visible like this to expect the link element to be visible so now if i go ahead and run our test it will work just fine it finds the element to be visible and passes the test now if i go ahead and just say something that is not in our page so that we feel this expect statement so let's say we'll say something like get python which i'm sure it's not in the page so now if i run the test again in the verbose mode so that we see more output you can see the page opens up and it is waiting for the timeout to end you can see the timeout ended and we got a failure that is test failed and you can see the specific code where the error occurred that is in our expect statement you can see…

Contents