How to Change a html line code with python(如何使用python更改html行代码)
问题描述
我想改变这一行:
到这里:
<button _ngcontent-c19="" class="blue-button">CONTINUE </button>
我所能做的就是将类名从 blue-button-disabled 更改为 blue-button,但我无法删除 disabled=""
all that I could do is change the class name from blue-button-disabled to blue-button, but I couldn't remove disabled=""
我使用这段代码来达到这个结果:
I used this code to achieve that result:
driver.execute_script("arguments[0].setAttribute('class','blue-button')", element)
推荐答案
要删除属性 disabled=""
可以使用以下代码行:
To remove the attribute disabled=""
you can use the following line of code:
driver.execute_script("arguments[0].removeAttribute('disabled')", element)
参考
您可以在以下位置找到一些相关的详细讨论:
Reference
You can find a couple of relevant detailed discussions in:
- 使用 JavascriptExecutor 的 Selenium Datepicker
- 有没有办法使用 selenium python 向元素添加具有值的新属性?
这篇关于如何使用python更改html行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用python更改html行代码


- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01