【发布时间】:2018-04-25 17:30:09
【问题描述】:
我正在尝试使用 Puppeteer 访问可点击的输入收音机,以推进我的应用程序调查。下面是选择器和 xpath 标签。
选择器:
#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
我无法让 xpath 或选择器正常工作。我也尝试过使用下面但没有运气。使用选择器查看错误:
>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];
有人有什么想法吗?
【问题讨论】:
标签: javascript jquery html css puppeteer