我是靠谱客的博主 拼搏皮带,这篇文章主要介绍selenium点击元素位置_Python Selenium纯粹基于元素的位置单击元素off,现在分享给大家,希望可以做个参考。

我的目标是:

元素.位置给出元素在浏览器中左上角的位置。我有一个网站,在这个网站上,即使这可能不是一个好的硒实践,我希望能够完全根据它的位置点击这个元素,因为它从来没有改变过,也可能永远不会改变。

假设元素.位置给出{'x':253,'y':584},这是我迄今为止没有运气尝试过的代码from selenium import webdriver

from selenium.webdriver.common.action_chains import ActionChains

driver.maximize_window()

url = "https://learn.letskodeit.com/p/practice"

driver.get(url)

open_window_elem = driver.find_element_by_id("openwindow")

# from wherever the mouse is, I move to the top left corner of the broswer

action = ActionChains(driver)

action.move_by_offset(-1000, -1000)

action.click()

action.perform()

y_coordinate = open_window_elem.location["y"]

x_coordinate = open_window_elem.location["x"]

action = ActionChains(driver)

action.move_by_offset(x_coordinate, y_coordinate)

action.click()

action.perform()

运行此代码时不会发生任何事情。我只想打开一扇新窗户。

有人能帮忙吗?在

最后

以上就是拼搏皮带最近收集整理的关于selenium点击元素位置_Python Selenium纯粹基于元素的位置单击元素off的全部内容,更多相关selenium点击元素位置_Python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(102)

评论列表共有 0 条评论

立即
投稿
返回
顶部