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 verify text

UI testing verify text

For this test, we have to go ahead and locate an element when it contains the welcome text. Now it may look pretty easy because we just have it right here. We can give it to our get by text locator. But the problem is we already have this welcome text all over the place. That is in the info, in the scenario and in our actual playground. So first of all, we have to shorten our search with the playground parent. And you can see it is inside of our bg-primary. So first of all, we have to select our parent. And inside of that, we'll select an element which contains the welcome text. So let's go ahead and do that. First of all, we'll select the parent that is parent locator. use css selectors that is a divider with the bg hyphen primary that is this right here now we can go ahead and inside of this we can locate an element with the welcome text so we can use get by text and the text is welcome by default it will go ahead and just match anything that contains this text which means exact is…

Contents