Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

getLocationAbsUrl for Angular 2 apps fails to execute 'querySelector' on 'Document' #3007

Open
cnishina opened this issue Mar 7, 2016 · 2 comments
Assignees

Comments

@cnishina
Copy link
Member

cnishina commented Mar 7, 2016

getLocationAbsUrl relies on a document query selector which does not work with Angular 2.

lib/clientsidescripts.js:

var el = document.querySelector(selector);
  if (angular.getTestability) {
    return angular.getTestability(el).
        getLocation();
  }

sample spec:

    var url = 'http://localhost:3000/';
    browser.get(url);
    expect(browser.getCurrentUrl()).toBe(url);
    expect(browser.getLocationAbsUrl()).toBe(url);  // <-- does not work

error output:

1) test suite should navigate to the baes url
  Message:
    Failed: invalid element state: Failed to execute 'querySelector' on 'Document': The provided selector is empty.
      (Session info: chrome=48.0.2564.116)
      (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.3 x86_64) (WARNING: The server did not provide any stacktrace information)
@juliemr
Copy link
Member

juliemr commented Apr 25, 2016

Historically, the only reason we have getLocationAbsUrl is kind of a workaround for IE. You should be able to use getCurrentUrl just fine in Angular2, and generally prefer that.

Changing this to a documentation issue.

@bbaia
Copy link

bbaia commented May 9, 2016

Ok about getLocationAbsUrl, but looks like he will get the same issue if he calls setLocation.
The error message says 'The provided selector is empty' because he is using useAllAngular2AppRoots() I suppose.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants