0
votes

I am trying to write a basic e2e test with protractor. Below is my test. I've added the console.log to see if I can access the URL, the output in the log shows the result of the call to browser.getLocationAbsUrl() is a promise that is 'pending' (Promise::105 {[[PromiseStatus]]: "pending"}). The error I get is Error while waiting for Protractor to sync with the page: "angular could not be found on the window"

describe "routes", () ->
  it "should automatically redirect to / when location hash/fragment is empty", () ->

    browser.navigate 'index.html'
    console.log browser.getLocationAbsUrl()
    expect(browser.getLocationAbsUrl()).toBe '/'

My config file is simple:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  baseUrl: 'http://localhost:8000',
  capabilities: {
    'browserName': 'chrome'
  },
  troubleshoot: true,
  specs: ['app/spec/e2e/**/*.coffee']
}
2
If this is really an angular application, on which tag the ng-app is defined?alecxe
on the html element. I tried adding rootElement: '#html' to index.html, but it didn't make a difference. I also added framework: 'jasmine2' to the config, all that did was give me a stack trace along with the error (the same error message). Previously stack trace was undefined. Also tried using browser.waitForAngular , still got nothing.Musical Shore
How about rootElement: 'html'?alecxe
What about using browser.get instead of browser.navigate?alecxe
Also, what if you use a full url http://localhost:8000/index.html?alecxe

2 Answers

0
votes

You cannot just console.log() different things in Protractor/Selenium, it is all promises. You should do the following instead (sorry I am not goodin in CoffeeScript):

browser.get('index.html');
browser.getLocationAbsUrl().then(function(url) {
  console.log(url);
});
expect(browser.getLocationAbsUrl()).toBe('/');
-1
votes

Try to remove these lines:

seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl: 'http://localhost:8000',