selenium定位元素坐标不准确,总是在元素的正上方

📅 发布时间:2026/7/5 21:07:26 👁️ 浏览次数:
selenium定位元素坐标不准确,总是在元素的正上方
网上其他解决方案1、修改电脑显示设置为100%2、缩放截取到的页面图片即将截图的size缩放为宽和高都除以缩放比例后的大小3、将图片location和size属性值都乘以缩放比例。设置好显示配置之后使用location得到的元素位置还是在实际元素的上方解决方法panel_height browser.execute_script(return window.outerHeight - window.innerHeight) # 获取浏览器边框的大小 location img_label.location size img_label.size top, bottom, left, right location[y] panel_height, location[y] panel_height size[height], location[x], location[x] size[width]转自selenium定位元素坐标不准确总是在元素的正上方_java的robot和 selenium的 位置坐标体系不一致-CSDN博客