【发布时间】:2015-04-07 10:05:34
【问题描述】:
我正在使用 python 包以某种指定的模式或只是随机运动来移动鼠标。
我尝试的第一件事是获取//html 元素的大小并使用它来设置鼠标移动的边界。但是,当我这样做时,MoveTargetOutOfBoundsException 会抬起头并显示一些“给定”坐标(这些坐标不在输入附近。
我使用的代码:
origin = driver.find_element_by_xpath('//html')
bounds = origin.size
print bounds
ActionChains(driver).move_to_element(origin).move_by_offset(bounds['width'] - 10, bounds['height'] - 10).perform()
所以我从每个边界中减去 10 来测试它并移动到那个位置(显然move_to_element_by_offset 方法是狡猾的)。
MoveTargetOutOfBoundsException: Message: Given coordinates (1919, 2766) are outside the document. Error: MoveTargetOutOfBoundsError: The target scroll location (17, 1798) is not on the page.
Stacktrace:
at FirefoxDriver.prototype.mouseMoveTo (file://...
实际给定的坐标是 (1903-10=1893, 969-10=989)。
有什么想法吗?
【问题讨论】:
-
尝试在 origin 中使用 body 而不是 html
-
试过了,没用。 (结果相同)