Alternative for time.sleep

Sir, suppose i have high speed net connection. then writing time.sleep function will slow down the process and where and when to write this function as we can;t decide which page of the site will take unusual time to load, so we have to write sleep function at every step which in turn will slow down the process by many fold

i tried writing code for automating posting update in facebook , but it gave error at different steps as the code in the next line got executed but the next page in the website hasn’t got loaded, by that time,.

Sir,please help

hey @naman_kr_301 ,
instead of sleep function go for WebDriverWait function available in selenium as it creates a sync between your code and webdriver…but the thiing it also needs a parameter that states about how much time it needs to wait , so if in that given time your page get loaded it will work perfectly else if it took time to get loaded it will behave the same as sleep function.

similarly you can also run an infinite while loop that checks whether a particular element is now available or not on the next page , if it is not , then continue the loop else perform you need to do.

I hope either of these two methods will be useful for you.
Thank You and Happy Learning :slightly_smiling_face:.