У меня есть следующий код:
page.click('div.button-table div:contains(Who) div.square-button:nth-child(1)')
Когда кукловод запустит этот код, появится ошибка:
Brief
Failed to execute 'querySelector' on 'Document': 'div.button-table div:contains(Who) div.square-button:nth-child(1)' is not a valid selector.
Полный
Error: Evaluation failed: DOMException: Failed to execute 'querySelector' on 'Document': 'div.button-table div:contains(Who) div.square-button:nth-child(1)' is not a valid selector.
at __puppeteer_evaluation_script__:1:33
at ExecutionContext.evaluateHandle (node_modules/puppeteer/lib/ExecutionContext.js:124:13)
at <anonymous>
-- ASYNC --
at ExecutionContext.<anonymous> (node_modules/puppeteer/lib/helper.js:144:27)
at ElementHandle.$ (node_modules/puppeteer/lib/ExecutionContext.js:529:50)
at ElementHandle.<anonymous> (node_modules/puppeteer/lib/helper.js:145:23)
at Frame.$ (node_modules/puppeteer/lib/FrameManager.js:456:34)
at <anonymous>
-- ASYNC --
at Frame.<anonymous> (node_modules/puppeteer/lib/helper.js:144:27)
at Frame.click (node_modules/puppeteer/lib/FrameManager.js:735:31)
at Frame.<anonymous> (node_modules/puppeteer/lib/helper.js:145:23)
at Page.click (node_modules/puppeteer/lib/Page.js:973:29)
at Proxy.fillInAudience (libs/page/brand_create_quote_page.js:67:21)
at Proxy.<anonymous> (libs/logger.js:38:27)
at Context.it (ui/brand/create_quote_spec.js:53:16)
at <anonymous>
Но этот селектор может успешно работать в Devtools - $('div.button-table div:contains(Who) div.square-button:nth-child(1)').text()
Я также выясняю, если я уберу div:contains(Who)
, кукловод может запустить его без паники.
Есть идеи?
Спасибо!