Answer the question
In order to leave comments, you need to log in
How to wait for response from xmlhttprequest request when executing JS script in Python Selenium?
It is necessary to send a request on the page and return a response (requests is not suitable). I do it through driver.execute_script(). The script looks like this: 'let xhr = new XMLHttpRequest();xhr.open("GET", URL);xhr.send();return xhr.response;'. No response is returned because the request does not have time to complete.
When adding 'xhr.onload = function () { return xhr.response;};' returns None.
Also, I tried to return the value already in the next execute_script, it also does not work.
Can you please tell me how this can be implemented?
Answer the question
In order to leave comments, you need to log in
In general, replace XMLHttpRequest with your own, which would call your callback on each successful request, something like this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question