For scrapy/selenium is there a way to go back to a previous page?

后端 未结 3 510
轻奢々
轻奢々 2021-02-02 14:22

I essentially have a start_url that has my javascript search form and button, hence the need of selenium. I use selenium to select the appropriate items in my select box objects

相关标签:
3条回答
  • 2021-02-02 15:00

    The currently selected answer provides a link to an external site and that link is broken. The selenium docs talk about

    driver.forward()
    driver.back()
    

    but those will sometimes fail, even if you explicitly use some wait functions.

    I found a better solution. You can use the below command to navigate backwards.

    driver.execute_script("window.history.go(-1)")
    

    hope this helps someone else in the future.

    0 讨论(0)
  • 2021-02-02 15:05

    To move backwards and forwards in your browser’s history use

    driver.forward()
    driver.back()
    
    0 讨论(0)
  • 2021-02-02 15:14

    Here the advice is to use driver.back() : https://selenium-python.readthedocs.io/navigating.html#navigation-history-and-location

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