webdriver.get()和webdriver.navigate()之间的区别 [英] Difference between webdriver.get() and webdriver.navigate()

查看:134
本文介绍了webdriver.get()和webdriver.navigate()之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

get() navigate()方法有什么区别?
是否有任何此方法或其他方法等待加载页面内容?
我真正需要的是像selenium s 1.0 WaitForPageToLoad 但是使用via webdriver`。

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 seleniums 1.0WaitForPageToLoadbut for using viawebdriver`.

有什么建议吗?

推荐答案


导航



第一件事你想要用WebDriver导航到一个页面。通常的方法是调用 get

driver.get("http://www.google.com");

WebDriver将等到页面完全加载(即 onload 事件已触发),然后将控制权返回给您的测试或脚本。值得注意的是,如果您的页面在加载时使用了大量AJAX,那么WebDriver可能不知道它何时完全加载。如果您需要确保这些页面已满载,那么您可以使用等待

WebDriver will wait until the page has fully loaded (that is, the onload event has fired) before returning control to your test or script. It’s worth noting that if your page uses a lot of AJAX on load then WebDriver may not know when it has completely loaded. If you need to ensure such pages are fully loaded then you can use waits.

之前,我们介绍了使用 get 命令导航到页面( driver.get(http://www.example.com))正如您所见,WebDriver有许多较小的,以任务为中心的界面,导航是一项有用的任务。因为加载页面是一个基本要求,所以这样做的方法存在于主WebDriver接口上,但它只是一个同义词:

Earlier, we covered navigating to a page using the get command (driver.get("http://www.example.com")) As you’ve seen, WebDriver has a number of smaller, task-focused interfaces, and navigation is a useful task. Because loading a page is such a fundamental requirement, the method to do this lives on the main WebDriver interface, but it’s simply a synonym to:

driver.navigate().to("http://www.example.com");

重申: navigate()。to() get()做同样的事情。一个比另一个更容易输入!

To reiterate: navigate().to() and get() do exactly the same thing. One's just a lot easier to type than the other!

导航界面还暴露了向后移动的能力在浏览器的历史记录中转发:

The navigate interface also exposes the ability to move backwards and forwards in your browser’s history:

driver.navigate().forward();
driver.navigate().back();


(强调添加)

这篇关于webdriver.get()和webdriver.navigate()之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆