2

Trying to use driver.navigate().to('https://example.com')

Error:

AttributeError: 'WebDriver' object has no attribute 'navigate'

Surely it does - it's mentioned all over this site.

I don't want to use get() because I want cookies to persist for the session.

User
  • 23,729
  • 38
  • 124
  • 207
  • there would be no difference regarding cookies. – pcalkins Dec 11 '20 at 22:17
  • @pcalkins there are several answers on here explaining there is a difference – User Dec 11 '20 at 22:17
  • They're mixing up a single-page application which does not allow for bookmarking (bad practice really... they should be using hashes...) with Selenium functionality. – pcalkins Dec 11 '20 at 22:18
  • there's many many sites who are using a single-page architecture which don't allow for using a "back" button, or for bookmarking a specific page. This is because they aren't updating the URL for a DOM change. They can avoid that by using a "#" in the url (which is processed like a bookmark so page doesn't change) and triggering hashchange event handlers using values after the hash as name/value pairs. Regardless this has nothing to do with Selenium or whether you use .get() or .navigate() – pcalkins Dec 11 '20 at 22:27
  • There does seem to be a difference in the spec, but not sure I understand it much: https://www.w3.org/TR/webdriver/#navigate-to None of this should affect cookies though. It's worth noting that some servers will do routing which can make different paths the same page load, but would trigger different DOM updates. ("/" becomes effectively the same as "#") – pcalkins Dec 11 '20 at 23:02
  • That answer which you tagged is wrong ! – PDHide Dec 12 '20 at 01:00
  • It doesn't have anything to do with cookies , it has access to history that's it – PDHide Dec 12 '20 at 01:01

1 Answers1

2
driver.navigate().to('https://example.com')

is Java , in python only get is there

it uses same browser session and cookies ,

you can use page loading strategies if ypu dont want to wait for page load

Also the answer you tagged is wrong ,

https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/WebDriver.html#navigate()

navigate WebDriver.Navigation navigate() An abstraction allowing the driver to access the browser's history and to navigate to a given URL. Returns: A WebDriver.Navigation that allows the selection of what to do next

The only use of navigate is to go-to history for navigating back and forward it doesn't have anything to do with cookies or session

PDHide
  • 18,113
  • 2
  • 31
  • 46