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 nbsp character

UI testing nbsp character

In this test, we have to handle the non-breaking space character. That is, for our test scenario, we are set to use XPath to find our button. And it also says that if we use this selector right here, it will fail. So let's go ahead and try that. So I go page, locator, and we'll go ahead and use the XPath. And now if I go ahead and just try to click it. And so that we don't have to wait for too long, I'll set the timeout as two seconds. Now if I go ahead and run the test, we will go ahead and fail the same. As you can see, this locator right here did not resolve to anything. Now why does this happen? we see the my button right here and also the same here as well so if we go ahead and take a look at its code it uses a nbsp character that stands for non-breaking space character what it does is make sure that when you shrink the size of the window the character there or the line here does not gets into a second line. So it stays in one line. So here to select the special character we have…

Contents