【问题标题】:I have the location in the HTML page. How to get the id or any other attributes of the element at that position我在 HTML 页面中有位置。如何获取该位置元素的 id 或任何其他属性
【发布时间】:2019-03-26 13:15:55
【问题描述】:

我在网页中有一个对象的位置。 在 selenium 中,我们可以获取元素的位置,如下面的代码所示。 我想知道如何在 python 中进行反向操作。

str = driver.find_elements_by_tag_name("input")

for i in str:

    print(i.location)

【问题讨论】:

标签: html python-3.x selenium-webdriver


【解决方案1】:

使用 Java 脚本我得到了这个。

driver = webdriver.Chrome()
driver.execute_script('el = document.elementFromPoint(1285, 19); return el')
ele.wrapped_element.get_attribute("class")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多