【发布时间】:2021-07-06 20:09:59
【问题描述】:
我正在尝试在selenium中获取光标的当前坐标,主要是因为我想将它移动到一个元素,但是,非常重要,我不期待直接将它与动作链一起移动到元素,我希望它做一个平滑的轨迹,但要做到这一点,我需要了解:
- 能否获取当前光标位置来计算轨迹?
或者!!
- 有没有办法将“不知何故”生成的光标移动到元素的轨迹中?
注意:我不想要这个解决方案
webdriver.ActionChains(self.driver).move_to_element(element).click(
element).perform()
我需要更类似于以下内容的东西:
def element_coordinates(e):
location = e.location
print(location)
return location
e = WebDriverWait(self.driver, 5).until(
EC.element_to_be_clickable((By.XPATH, '//div[contains(@label, "element")]')))
coordinates = element_coordinates(e)
为我提供特定元素的以下输出。以下是我想要的光标输出类型:
>>> {'y': 20, 'x': -65}
【问题讨论】:
标签: python python-3.x selenium selenium-webdriver