Python selenium browser driver.back()

前端 未结 1 745
闹比i
闹比i 2021-02-01 03:42

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 Pyt

1条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 03:46

    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.

    0 讨论(0)
提交回复
热议问题