I have difficulty to simulate the mouse click/key stroke to choose how many lists per page after page.goto()
. Here is the HTML source code for the per page
option:
<label class="control-label pull-right" style="margin-right: 10px; font-weight: 100;">
<small>Show</small>
<select class="input-sm grid-per-pager" name="per-page">
<option value="https://www.mysite-com/admin/order?per_page=10" >10</option>
<option value="https://www.mysite-com/admin/order?per_page=20" selected>20</option>
<option value="https://www.mysite-com/admin/order?per_page=30" >30</option>
<option value="https://www.mysite-com/admin/order?per_page=50" >50</option>
<option value="https://www.mysited-com/admin/order?per_page=100" >100</option>
</select>
<small>Piece</small>
</label>
The default is 20
listings per page, and I would like to change it to 100
listings per page which requires mouse click the box and hit down arrow key twice to choose 100
. Here is some code for the purpose:
await page.mouse.click("label.control-label .grid-per-pager");
await page.keyboard.press("ArrowDown");
await page.keyboard.press("ArrowDown");
It gave me a few errors. What is missing here?
The best method to use in this case is page.select()
.
This method accepts the selector for the select
element as the first parameter and the value
of the option
you would like to select as the second parameter:
await page.select('select[name="per-page"]', 'https://www.mysited-com/admin/order?per_page=100');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.