简体   繁体   中英

Protractor cannot find angular on window

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']
}

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('/');

Try to remove these lines:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM