Closed lalalatutu closed 3 years ago
如果 JS 有那就会有 至于默认 cdp 上的话, 搜索关键词 scroll 时候有几个相关的 https://chromedevtools.github.io/devtools-protocol/
具体还是看 case, 对 Chrome 浏览器自动化来说, 能 JS 的就走原生 JS, 其次考虑 cdp 里支持的情况, 多数情况还是用 JS 的 Element.scrollIntoView() - Web APIs | MDN 比较常见
Input.dispatchMouseEvent有个mouseWheel,实际使用却无法滚动,不知道什么原因。
那个我没有用过也不确定你是怎么用的, 用途是什么啊, 我平时滚动都走 JS 了 你这随便说几句我也不知道怎么复现出来...
await current_tab.send('Input.dispatchMouseEvent',
type="mouseWheel",
timeout=2,
deltaY=int(round(50)))
这样写的,没看到页面有滚动,本意是让滚动条向下滚动50px。
我找个页面试试哈
await current_tab.send('Input.dispatchMouseEvent', type="mouseWheel", timeout=2, deltaY=int(round(50)))
这样写的,没看到页面有滚动,本意是让滚动条向下滚动50px。
这个滚动条是整个页面的滚动条
看了下返回值是报错了 {'id': 1, 'error': {'code': -32602, 'message': 'Invalid parameters', 'data': 'Failed to deserialize params.x - BINDINGS: mandatory field missing at position 40'}} 这个报错没搜到什么意思...
为啥不用 JS 做滚动啊 await tab.js(r'''window.scrollTo( 0, 1000 )''')
看明白报错了... 忘了放 x y 参数了
print(await tab.send('Input.dispatchMouseEvent',
type="mouseWheel",
timeout=2,
x=0,
y=0,
deltaX=0,
deltaY=100))
啊啊啊,明白了,原来还可以这样print结果,受教了。非常感谢。
怪我不喜欢写文档... 祝使用愉快
开源不易,怪我没多看看源码。
怪我不喜欢写文档... 祝使用愉快
如题