selenium获取元素定位值
方法1
鼠标点击网页某个坐标
from selenium.webdriver.common.action_chains import ActionChains
driver.get(start_url)
onChains(driver).move_by_offset(971, 437).click().perform() # 鼠标左键点击
ActionChains(driver).move_by_offset(200, 100).context_click().perform() # 鼠标右键点击
方法2
在“Console”中输入 'document.getElementById('元素ID').getBoundingClientRect()'后,回车
注意:如果遇到“VM375:1 Uncaught TypeError: document.getElementsByClassName(...).getBoundingClientRect is not a function”这样的错误,可在获取元素时添加索引,即‘document.getElementById('元素ID')[0].getBoundingClientRect()’。该方法获取的坐标为当前页面大小的坐标!!!
https://www.dianjilingqu.com/537233.html
努力生活,融于自然