getLocationAbsUrl VS getCurrentUrlgetLocationAbsUrl、VS、getCurrentUrl

由网友(在绝望中死去)分享简介:在量角器,全球可用的浏览器对象有两种方法:In protractor, globally available browser object has two methods:getLocationAbsUrl()从AngularJS返回当前绝对URL。Returns the current absolute url...

在量角器,全球可用的浏览器对象有两种方法:

In protractor, globally available browser object has two methods:

getLocationAbsUrl()

从AngularJS返回当前绝对URL。

Returns the current absolute url from AngularJS. getCurrentUrl()

调度命令检索当前页面的URL。

Schedules a command to retrieve the URL of the current page.

这是不是很清楚,明显的是什么两者之间的区别。为了这一刻,我已经使用 getCurrentUrl()

It is not quite clear and obvious what is the difference between the two. To this very moment, I've been using getCurrentUrl() only.

我们什么时候应该使用 getLocationAbsUrl()?它涵盖使用情况?

When should we use getLocationAbsUrl()? Which use-cases does it cover?

我不记得在其他硒语言绑定类似于 getLocationAbsUrl()东西。它看起来pretty多少量角器特定-

I cannot recall anything similar to getLocationAbsUrl() in other selenium language bindings. It looks pretty much protractor-specific.

推荐答案

的GitHub源getCurrentUrl

webdriver.WebDriver.prototype.getCurrentUrl = function() {
  return this.schedule(
      new webdriver.Command(webdriver.CommandName.GET_CURRENT_URL),
      'WebDriver.getCurrentUrl()');
};

使用时间表() - > 命令()包装解决从一个承诺 WebDriver.getCurrentUrl()

Uses the schedule() -> command() wrappers to resolve a promise from WebDriver.getCurrentUrl()

的GitHub源Protractor.getLocationAbsUrl

functions.getLocationAbsUrl = function(selector) {
  var el = document.querySelector(selector);
  if (angular.getTestability) {
    return angular.getTestability(el).
        getLocation();
  }
  return angular.element(el).injector().get('$location').absUrl();
};

只要周围的包装 $ location.absUrl()与等待在 AngularJS 库加载

当前URL VS绝对网址

给定应用,网址:

http://www.example.com/home/index.html#/Home

的当前网址的解析为更多的URI的

Current URL resolves to more of a URI

/home/index.html#/Home

的绝对URL 的解析为

http://www.example.com/home/index.html#/Home

当你想使用绝对网址::您要使用的全域网址,而不是本地导航(URI),你希望的绝对URL 的。

When do you want to use absolute URL: You want to use the Full Domain URL, rather than the local navigation (URI), you want the Absolute URL.

js event.target可以获取元素但是currentTarget为null这是为什么

如果您的应用程序,使针对的当前URL通话的,你的测试应该叫 getCurrentUrl()

If your application makes calls for the Current URL, your tests should call getCurrentUrl().

如果您code,使请求的绝对URL 的,你的测试应该叫 getLocationAbsUrl()

If your code makes requests for Absolute URL, your tests should call getLocationAbsUrl().

阅读全文

相关推荐

最新文章