Issue
I want to change the CSS element style using Python Selenium while doing automation to change the theme color of the page. For example, the page element is as follows:
<div style="background: #e7e7e7">
<div style="border-bottom: #e7e7e7; border-top: #e7e7e7">
I want to change the color from #e7e7e7
to #318c89
, which means I need to find all e7e7e7
in the HTML script and replace all with #318c89
but I have no idea how should I do that.
Thanks in advance.
Solution
Try this:
script = "document.body.innerHTML = document.body.innerHTML.replaceAll('#e7e7e7', '#318c89')"
driver.execute_script(script)
Answered By - Pedro Maia
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.