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

后端 未结 3 511
轻奢々
轻奢々 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.

提交回复
热议问题