Difference between webdriver.get() and webdriver.navigate()

前端 未结 14 1465
悲哀的现实
悲哀的现实 2020-11-28 04:27

What is the difference between get() and navigate() methods? Does any of this or maybe another method waits for page content to load? What do I rea

14条回答
  •  难免孤独
    2020-11-28 04:54

    They both seems to navigate to the given webpage and quoting @matt answer:

    navigate().to() and get() do exactly the same thing.

    Single-Page Applications are an exception to this.

    The difference between these two methods comes not from their behavior, but from the behavior in the way the application works and how browser deal with it.

    navigate().to() navigates to the page by changing the URL like doing forward/backward navigation.

    Whereas, get() refreshes the page to changing the URL.

    So, in cases where application domain changes, both the method behaves similarly. That is, page is refreshed in both the cases. But, in single-page applications, while navigate().to() do not refreshes the page, get() do.

    Moreover, this is the reason browser history is getting lost when get() is used due to application being refreshed.

    Originally answered: https://stackoverflow.com/a/33868976/3619412

提交回复
热议问题