D
D
Dmitry Loginov2019-07-17 14:50:25
Python
Dmitry Loginov, 2019-07-17 14:50:25

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)};")

I would be very grateful for help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
1001001, 2019-07-17
@Gusik1984

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)

A
alekssamos, 2019-07-17
@alekssamos

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 question

Ask a Question

731 491 924 answers to any question