This is the best solution. The back() and forward() methods aren’t guaranteed to work.
driver.execute_script("window.history.go(-1)")
The JavaScript passed in accesses the pages DOM to navigate to the previous URL. I hope that this solves your problem.