【问题标题】:How to edit the html code of a browser element with selenium in python如何在python中使用硒编辑浏览器元素的html代码
【发布时间】:2021-07-26 23:47:30
【问题描述】:

我正在尝试编辑浏览器元素的 html 代码,但我找不到在 selenium 中执行此操作的单一方法。如果有人知道如何编辑它。欢迎分享!

【问题讨论】:

  • 为什么要这么做?您始终可以在selenium 中使用javascript

标签: python html selenium


【解决方案1】:

你可以使用execute_script来做到这一点

element = driver.find_element_by_xpath("element xpath")

driver.execute_script("arguments[0].setAttribute('attribute','value')",element)

【讨论】:

    猜你喜欢
    • 2010-11-14
    • 2013-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多