简体   繁体   中英

AngularJS: e2e testing with protractor

First of all I'm a noob with e2e testing. What I've done is

  • installed protractor nmp install protractor
  • installed webdriver-manager
  • run webdriver-manager start from the directory where my angularjs app sits. it runs fine
  • run protractor tests/e2e/conf.js it also runs fine

However in few seconds it says Timed out waiting for page to load

Here are my files:

tests/e2e/conf.js:

// An example configuration file.
exports.config = {
    // The address of a running selenium server.
    seleniumAddress: 'http://localhost:4444/wd/hub',

    // Capabilities to be passed to the webdriver instance.
    capabilities: {
        'browserName': 'chrome'
    },

    // Spec patterns are relative to the current working directly when
    // protractor is called.
    specs: ['example_spec.js'],

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000
    }
};

tests/e2e/example_spec.js

var protr;

describe('addressBook homepage', function() {

    var ptor;

    beforeEach(function() {
        ptor = protractor.getInstance();
    });

    it('should greet the named user', function() {
        browser.get('/'); // <-- exception here

        element(by.model('yourName')).sendKeys('Julie');

        var greeting = element(by.binding('yourName'));

        expect(greeting.getText()).toEqual('Hello Julie!');
    });
});

I just can't understand where to define my webapp laypout/placement so protractor/webdriver knows which context to run.

With that setup protractor will be trying to navigate to "/". You need to either set the baseUrl property in the configuration file, or put an absolute url in the browser.get(). If all your tests are going to be on the same domain I'd recommend the first option.

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