admin管理员组文章数量:1336192
I'm trying to access a clickable input radio using Puppeteer to advance in my application's survey. Below are the selector and xpath tags.
Selector:
#survey-engine > span > div > div > div > div > div.col-xs-12.col-xl-offset-2.col-xl-8.col-lg-offset-1.col-lg-10 > div > div:nth-child(1) > input[type="radio"]
XPath:
//*[@id="survey-engine"]/span/div/div/div/div/div[2]/div/div[1]/input
I've been unable to get to the xpath or selector to work correctly. I've also tried using below but no luck. See error using selector:
>UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: No node found for selector: #survey-engine > span > div > div > div > div > div.col-xs-12.col-xl-offset-2.col-xl-8.col-lg-offset-1.col-lg-10 > div > div:nth-child(1) > input[type="radio"]
at Console.assert (console.js:194:23)
at Frame.click (/Users/erickloos/Desktop/phs-platform/node_modules/puppeteer/lib/FrameManager.js:597:13)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:48518) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:48518) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(await page.$x("//input[contains(text(), 'My Input's Text')]"))[0];
Does anyone have any ideas?
I'm trying to access a clickable input radio using Puppeteer to advance in my application's survey. Below are the selector and xpath tags.
Selector:
#survey-engine > span > div > div > div > div > div.col-xs-12.col-xl-offset-2.col-xl-8.col-lg-offset-1.col-lg-10 > div > div:nth-child(1) > input[type="radio"]
XPath:
//*[@id="survey-engine"]/span/div/div/div/div/div[2]/div/div[1]/input
I've been unable to get to the xpath or selector to work correctly. I've also tried using below but no luck. See error using selector:
>UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: No node found for selector: #survey-engine > span > div > div > div > div > div.col-xs-12.col-xl-offset-2.col-xl-8.col-lg-offset-1.col-lg-10 > div > div:nth-child(1) > input[type="radio"]
at Console.assert (console.js:194:23)
at Frame.click (/Users/erickloos/Desktop/phs-platform/node_modules/puppeteer/lib/FrameManager.js:597:13)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:48518) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:48518) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(await page.$x("//input[contains(text(), 'My Input's Text')]"))[0];
Does anyone have any ideas?
Share edited Jan 15, 2019 at 18:31 Douglas Newton 234 bronze badges asked Apr 25, 2018 at 17:30 hanglooshangloos 791 silver badge9 bronze badges2 Answers
Reset to default 5await page.evaluate(() => {
var test = document.querySelector('#survey-engine > span > div > div > div > div > div.col-xs-12.col-xl-offset-2.col-xl-8.col-lg-offset-1.col-lg-10 > div > div:nth-child(1) > input[type="radio"]')
test.click();
})
Can you not simply try (assuming jquery is on page)?
var input = await page.evaluate(() => {
return $('#survey-engine > span > div > ... > div:nth-child(1) > input[type="radio"]';
});
Note I removed some of the selectors from your question for brevity...
本文标签: javascriptPuppeteer Can39t click on inputtyperadioStack Overflow
版权声明:本文标题:javascript - Puppeteer: Can't click on input[type=radio] - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742401521a2467979.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论