1. Case requirements

1) Open taobao home page

2) Focus the cursor to the search input box

3) Click the keyboard to enter the text

4) Click the search button

The specific code is as follows:

2. Code interpretation

Page. Focus (selector) : This method finds an element that matches a selector and gives it the focus. If there are more than one matching element, focus is given to the first element.

Page. Type (selector, text[, options]): Emits keyDown, KeyPress /input, and KeyUp events for each character entered

selector<[string]> Element selector to enter content. If there are more than one matching element, enter the first matching element.
text<[string]> Specifies the content to be entered
options <[Object]>
delay<[number]> Latency per character input, in milliseconds. The default is 0.

Click (selector[, options]) : This method finds an element that matches the selector selector, scrolls the element into view if needed, and then clicks on it via page.mouse. If the selector does not match any elements, this method will report an error.

selector<[string]> Selector for the element to click. If there are more than one matching element, click the first one.
options <[Object]>
button <[string]> left.rightOr,middleThe default isleft.
clickCount<[number]> Defaults to 1.
delay <[number]> mousedown 和 mouseupThe amount of time in milliseconds between. The default is 0