Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

I have created a little screen scraper and everything seems to be working great, the information is being pulled and saved in a DB. The only problem I am having is sometimes Python doesn't use the driver.back() so it then tries to get the information on the wrong page and crashes. I have tried adding time.sleep(5) but sometimes it still isn't working. I am trying to optimize it to take as little time as possible. So making it sleep for 30 seconds doesn't seem to be a good solution.

1 Answer

0 votes
by (62.9k points)

This is the best solution. The back() and forward() methods aren't guaranteed to work.


The JavaScript passed here gives access to the pages’ Dom to navigate to the previous URL.  I hope this resolves the issue.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium training!

Browse Categories