Chrome的F12和CDP结果不同

时间:2020-04-29 12:46:11

标签: javascript google-chrome-devtools puppeteer puppeteer-sharp chrome-remote-debugging

页面https://www.bbc.co.uk/iplayer/live/bbcone

我可以在Chrome的F12控制台中查询元素“ div.p_playerControls”:

document.querySelector('div.p_playerControls')
    ==> div class=​"p_playerControls" style=​"display:​ block;​ clip:​ rect(1px, 1px, 1px, 1px)​;​"

...但是不能通过远程接口:

result1 = await Runtime.evaluate({expression:"document.querySelector('div.p_playerControls')"})
result2 = await Runtime.evaluate({expression:"document.querySelector('.player__container')"})
console.log(result1.result.className)
console.log(result2.result.className)

输出:

Debugger attached.
undefined
HTMLDivElement

我做错了吗?.. :)谢谢!

please see this screenshot

1 个答案:

答案 0 :(得分:0)

问题已解决(来自不同框架的元素)。这里的详细信息https://github.com/hardkoded/puppeteer-sharp/issues/1465