admin管理员组文章数量:1381492
This is my HTML structure:
<div id="divImporte">
<p class="btn01">
<input type="button" name="Enviar Tasas" value="Enviar Tasas">
</p>
</div>
And this is the ways how i try to select the input:
first way:
const buttonTasas = await page.$$("input[type='button'][value='Enviar Tasas']");
second way:
const buttonTasas = await page.waitForSelector("input[type='button'][value='Enviar Tasas']");
and then click it:
if (buttonTasas && buttonTasas.length > 0) {
await buttonTasas[0].click();
}
i got this error:
"Error: Node is either not clickable or not an HTMLElement"
How can i solve? thanks
This is my HTML structure:
<div id="divImporte">
<p class="btn01">
<input type="button" name="Enviar Tasas" value="Enviar Tasas">
</p>
</div>
And this is the ways how i try to select the input:
first way:
const buttonTasas = await page.$$("input[type='button'][value='Enviar Tasas']");
second way:
const buttonTasas = await page.waitForSelector("input[type='button'][value='Enviar Tasas']");
and then click it:
if (buttonTasas && buttonTasas.length > 0) {
await buttonTasas[0].click();
}
i got this error:
"Error: Node is either not clickable or not an HTMLElement"
How can i solve? thanks
Share Improve this question asked Jan 28, 2022 at 11:07 JagcwebJagcweb 1121 silver badge9 bronze badges 2-
1
Be careful as your "1st way" returns an array whereas
2nd way
doesn't, otherwise this looks correct. try adding{visible: true}
as a 2nd parameter ofwaitForSelector
to be sure it waits for the element to be visible, and try adding some small delay before clicking the element withawait page.waitForTimeout(1000)
just to make sure the element is loaded – lezhumain Commented Jan 28, 2022 at 11:59 -
Hi @lezhumain i tried to use timeout and {visible: true} as second param but i got the same error. When i use node.warn into buttonTasas i got this:
JSHandle@node
– Jagcweb Commented Jan 28, 2022 at 12:12
2 Answers
Reset to default 6Sometimes puppeteer
just fails to click for some reason, so after double checking that buttonTasas
is not null and trying to add some delay just before calling the click()
method, you can try the following workaround to call the click function directly in the page:
With page.evaluate
(https://pptr.dev/api/puppeteer.page.evaluate):
page.evaluate((btnSelector) => {
// this executes in the page
document.querySelector(btnSelector).click();
}, "input[type='button'][value='Enviar Tasas']");
or maybe can you use the element directly:
page.evaluate((btn) => {
// this executes in the page
btn.click();
}, buttonTasas);
With page.$eval
(https://pptr.dev/api/puppeteer.page._eval):
await page.$eval(
'input[type='button'][value='Enviar Tasas']',
(el) => {
el.click()
}
);
UI tools for browsers usually have issues with white spaces. Try to search an element using an expression without any spaces or new lines. You can find a word inside a string using *=
in CSS expressions:
await page.$$("input[type='button'][value*='Enviar']");
or
await page.$$("input[type='button'][value*='Enviar'][value*='Tasas']");
本文标签:
版权声明:本文标题:javascript - "Error: Node is either not clickable or not an HTMLElement" Puppeteer when i tried to get input b 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744000879a2573833.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论