量角器 browser.driver.getCurrentUrl 与 browser.getCurrentUrl [英] Protractor browser.driver.getCurrentUrl vs browser.getCurrentUrl

查看:23
本文介绍了量角器 browser.driver.getCurrentUrl 与 browser.getCurrentUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个 Angular 应用程序,并在量角器上进行测试时尝试获取当前 URL.用哪一个?

I'm running an Angular app and I'm trying to get the current URL when testing on protractor. Which one to use?

browser.driver.getCurrentUrl()browser.getCurrentUrl() ?

推荐答案

如果这是一个正在测试的 Angular 应用程序 - 使用 browser,否则 - browser.driver.

If this is an Angular application under test - use browser, otherwise - browser.driver.

相关github问题引用@jmr:

如果您需要与非 Angular 页面交互,您可以直接使用 browser.driver 访问包装好的 webdriver 实例.

If you need to interact with a non-Angular page, you may access the wrapped webdriver instance directly with browser.driver.

<小时>

不过,请注意,如果这是正在测试的 Angular 应用程序,两者都可以工作.甚至有人说如果同步时间比平时长,发现 browser.driver 更可靠:


Though, note that both are gonna work if this is Angular application under test. Some people even said that found browser.driver more reliable if it the sync time is longer than usual:

补充一点——我发现 browser.driver 在需要时间同步的 AngularJS 应用上效果更好.我都试过了,由于某种原因 browser.driver 更可靠.

Just to add to this - I find that browser.driver works better on AngularJS apps that take time to sync. I have tried both and for some reason browser.driver is more reliable.

不过,我个人使用过 browser.getCurrentUrl() 并且记不起任何问题.

Though, I've personally used browser.getCurrentUrl() and cannot recall any problems.

这篇关于量角器 browser.driver.getCurrentUrl 与 browser.getCurrentUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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