Answer the question
In order to leave comments, you need to log in
How to create a popup window with a button pinned to the bottom of the screen?
Friends, we need help.
We have a python script that, using Selenium, fills out a form on a third-party site. The task is this: when the algorithm reaches a certain block, it needs to pause and give the opportunity to fill it in by hand. Those. at this point, a "Continue" button should appear. Ideally, I want a popup and sticky window with a button. I'm not strong in JS, so far I have only been able to create the button itself, but I don't know where it appears.
self.driver.get('https://yandex.ru')
self.driver.execute_script("var value = true; var btn = document.createElement('button'); var textInBtn = document.createTextNode('ПРОДОЛЖИТЬ'); btn.appendChild(textInBtn); if(value){document.body.appendChild(btn)};")
Answer the question
In order to leave comments, you need to log in
Well, at least you're binding to the wrong element. You have a strange task) A
checkbox is more suitable here, you also need to bind it to an element here: var btn = document.getElementById('wd-_teaser');
def something:
driver = webdriver.Chrome()
driver.get('https://yandex.ru')
driver.execute_script(
"var btn = document.getElementById('wd-_teaser');"
"var checkbox = document.createElement('input');"
"var label = document.createElement('label');"
"label.appendChild(document.createTextNode('GOOD'));"
"checkbox.type = 'checkbox';"
"checkbox.id = 'randomID';"
"btn.appendChild(checkbox);"
"btn.appendChild(label);")
element = driver.find_element_by_id("randomID")
while not element.is_selected():
time.sleep(2)
Yes, write in the input () console and that's it.
Or check the page URL in a loop. If it's different from the old one, manually filled out the form and clicked the button, then continue.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question