Skip to content

How to Insert "Script" element in the page? #3478

Answered by mdmintz
blevoh asked this question in Q&A

You must be logged in to vote

Would be similar to how a button is added, as in #1429 (comment):

from seleniumbase import SB

with SB() as sb:
    script_to_add_button = """function injectButton() {
       var new_button=document.createElement('button');
       document.getElementsByTagName('body')[0].appendChild(new_button);
       new_button.style="width: 200px; height: 120px";
    }
    injectButton();"""
    sb.execute_script(script_to_add_button)
    sb.sleep(3)

Replies: 2 comments 3 replies

You must be logged in to vote
2 replies
@blevoh

@mdmintz

Answer selected by mdmintz

You must be logged in to vote
1 reply
@mdmintz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants