Difference between webdriver.get() and webdriver.n

2020-01-27 01:00发布

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 really need is something like Selenium 1.0's WaitForPageToLoad but for using via webdriver.

Any suggestions?

13条回答
叼着烟拽天下
2楼-- · 2020-01-27 01:23

Otherwise you prob want the get method:

Load a new web page in the current browser window. This is done using an
HTTP GET operation, and the method will block until the load is complete.

Navigate allows you to work with browser history as far as i understand it.

查看更多
放荡不羁爱自由
3楼-- · 2020-01-27 01:25

To get a better understanding on it, one must see the architecture of Selenium WebDriver.

Just visit https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol

and search for "Navigate to a new URL." text. You will see both methods GET and POST.

Hence the conclusion given below:

driver.get() method internally sends Get request to Selenium Server Standalone. Whereas driver.navigate() method sends Post request to Selenium Server Standalone.

Hope it helps

查看更多
淡お忘
4楼-- · 2020-01-27 01:27

navigate().to() and get() will work same when you use for the first time. When you use it more than once then using navigate().to() you can come to the previous page at any time whereas you can do the same using get().

Conclusion: navigate().to() holds the entire history of the current window and get() just reload the page and hold any history.

查看更多
你好瞎i
5楼-- · 2020-01-27 01:37

driver.get(url) and navigate.to(url) both are used to go to particular web page. The key difference is that driver.get(url): It does not maintain the browser history and cookies and wait till page fully loaded. driver.navigate.to(url):It is also used to go to particular web page.it maintain browser history and cookies and does not page fully loaded and have navigation between the pages back, forward and refresh.

查看更多
够拽才男人
6楼-- · 2020-01-27 01:41

driver.get() : It's used to go to the particular website , But it doesn't maintain the browser History and cookies so , we can't use forward and backward button , if we click on that , page will not get schedule

driver.navigate() : it's used to go to the particular website , but it maintains the browser history and cookies, so we can use forward and backward button to navigate between the pages during the coding of Testcase

查看更多
我想做一个坏孩纸
7楼-- · 2020-01-27 01:44

Both perform the same function but driver.get(); seems more popular. driver.navigate().to(); is best used when you are already in the middle of a script and you want to redirect from current URL to a new one. For the sake of differentiating your codes, you can use driver.get();to launch the first URL after opening a browser instance, albeit both will work either way.

查看更多
登录 后发表回答