There is similar question posted and I applied the same technics to a very similar case. But the solution did not work for me and I have no clue what is causing the error.
Here is html source code
of per select:
<label class="control-label pull-right" style="margin-right: 10px; font-weight: 100;">
<small>显示</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.mysite-com/admin/order?per_page=100" >100</option>
</select>
<small>条</small>
</label>
Since the select
here is not native HTML element but a bootstrap
one, I choose to use page.click
. The code should do 1) click the select
element and make the options available to choose and 2) choose 100 per page. Here is the code i have:
res = await Promise.all([
page.waitForNavigation({waitUntil: 'load', timeout: 60000}),
page.click('select[name="per-page"]'), //<=== causing error
]);
res = await Promise.all([
page.waitForNavigation({waitUntil: 'load', timeout: 60000}),
page.click('select[name="per-page"] > option:nth-child(5)'),
]);
The error is:
Error: No node found for selector: select[name="per-page"]
at assert (C:\d\code\js\wbot\node_modules\puppeteer\lib\helper.js:259:11)
at Frame.click (C:\d\code\js\wbot\node_modules\puppeteer\lib\FrameManager.js:704:5)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
Tried different selectors, such as
select.input-sm[name="per-page"]
select.input-sm.grid-per-pager
But none of them works. The selector seems right to me but it can not locate the element. Also tried page.select
and it did not work as well. What is I missing here?