0

I have not come across an answer to answers whether it is possible to check at a specific moment in your Python script if the driver is busy loading or not. Something like:

   print(driver == loading)

Is this even possible?

teller.py3
  • 822
  • 8
  • 22

1 Answers1

0

This question was asked a lot of times before.
Actually you are asking is it possible to validate the page loading was completed.
You can see here and on many similar questions here.
So, you can check page ready state. But it is not reliable enough.

def page_has_loaded(self):
    self.log.info("Checking if {} page is loaded.".format(self.driver.current_url))
    page_state = self.driver.execute_script('return document.readyState;')
    return page_state == 'complete'
Prophet
  • 32,350
  • 22
  • 54
  • 79
  • What other page states are there? Also, my question is actually slightly different. – teller.py3 Jul 06 '21 at 11:54
  • document.readyState can be: loading, interactive or complete. I see you asked slightly different question, but I'm not sure there are better approaches to get the answer. I will be happy to learn if there are such. – Prophet Jul 06 '21 at 11:59
  • Your suggestion did not solve my problem. After landing in a specific page and clicking on a specific element, a loading icon appears, indicating the driver is loading and going to another page. However, the document.readyState still appears to be "complete". – teller.py3 Jul 06 '21 at 23:20
  • Thank you for the response, it is very interesting. Please let me know if you finally got a solution for this question. – Prophet Jul 07 '21 at 06:37