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.
Select option
In this lesson, we'll learn about how to select options in and select input field like this. You can see we have different options which we can select. So let's go ahead and inspect the same. And you can see it is a select element with a label for the same. And we can use the get by label locator to locate it. So let's go ahead and create a select variable and then we can just use page get by label locator the locator is example select okay and now to actually select an option what we can do is use the select option method on the element and to this we can provide the option we want to select inside of strings. Let's say we want to select four. So I will go ahead and provide four here, hit enter, you can see four getting selected. And similarly, I can select any other option, like let's say two, I can select, let's say five, and any other option that's available here now if i do enter an option that is not inside of it let's say 10 you will see that it waits for the timeout to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.