【发布时间】:2020-09-22 04:58:22
【问题描述】:
使用以下代码:
elem = driver.find_element_by_xpath('/html/body/canvas')
from selenium.webdriver.common.action_chains import ActionChains
actions = ActionChains(driver)
actions.move_to_element_with_offset(elem, 185, -35).click().perform()
我无法导航到画布元素的所需部分并收到此错误:
MoveTargetOutOfBoundsException: move target out of bounds
(Session info: chrome=85.0.4183.102)
我的移动目标绝对在视口内,无需滚动即可使其可点击。我正在使用 chromedriver,并使用画布的左上角作为move_to_element_with_offset() 的像素坐标的起点。有什么想法可以解决这个问题吗?我对在 python 中单击画布上指定点的任何解决方案感兴趣,不需要使用相同的方法。
【问题讨论】:
-
根据您的 chromedriver 版本,它可能在 75 版之后位于左上角或居中。
标签: python selenium selenium-webdriver html5-canvas selenium-chromedriver