selenium模拟鼠标滚动

target = driver.find_element_by_id(“id_keypair”);

driver.execute_script(“arguments[0].scrollIntoView();”, target) #拖动到可见的元素去

这个方法可以模拟鼠标滚动到需要显示的元素位置,使用场景:浏览器窗口小,页面过大内容显示不全,元素可以定位但不可见。

或者

self._current_browser().execute_script(“arguments[0].focus();”, element)

https://blog.csdn.net/wuyepiaoxue789/article/details/88804450

猜你喜欢

转载自blog.csdn.net/Love_Polaris/article/details/108789570
今日推荐