D
D
Diolorca2022-02-17 09:00:49
Python
Diolorca, 2022-02-17 09:00:49

How to track popup div using selenium?

Hello!
There is a website (I can't show it). On it, when you perform a certain action (pressing a button, for example), something like a notification appears that displays the status of the operation and its completion.
I'm trying to automate some routine tasks (pressing buttons), and in general my script works, but due to the fact that the process can go faster or slower (namely, the status of this process is displayed by the div block), it is not always possible to hit the timings. As a result, errors occur.
The question is how to track this div block? According to the code inspector, this div block appears for the duration of the process notification and then disappears from the code. Tried to trace it with find_element_by... (class, div, text, etc.) but to no avail. selenium doesn't find this notification div.
Help advice.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nadim Zakirov, 2022-02-17
@zkrvndm

I don’t know how to do this in Python, but in JavaScript this can be done in as many as 3 ways:
1. Use setTinterval to check the page cyclically, say, every second
2. Use the DOMSubtreeModified event and check the page upon changes, although this event is obsolete , but it still works
3. Use a modern MutationObserver to detect the desired changes and instantly find the button as soon as it appears

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question