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.

Keyboard shortcuts

Keyboard shortcuts

in this lesson we'll learn about how can we simulate key events that is keyboard key presses while being inside of an element and the best way to do that is using a form field so let's go ahead and select this text area so I can just go ahead and say text area badge get by label. And the label is example, text area. Now using the text area, we can just fill in some content using the fill command and providing it the data we want, let's say a simple word, hit enter, you can see that gets entered. Now the thing is if we were to do it manually that is if I want to do it using our mouse and keyboard what I would do is just go to the input field and select it and then in my keyboard I will type W O R D like this. So if I want to simulate key process using our keyboard then we can make use of the elements press method like this so if i want to press a w key we will start with key like this and then the name of the character that would be w hit enter you can see w is entered and then if i…

Contents