2014-02-08 244 views
0

首先,我是一个e2e测试的noob。我所做的就是AngularJS:使用量角器测试e2e

  • 安装量角器nmp install protractor
  • 安装webdriver的经理
  • 运行webdriver-manager start从那里我angularjs应用程序位于该目录。它运行良好
  • 运行protractor tests/e2e/conf.js它也运行良好

然而,在几秒钟内,它说Timed out waiting for page to load

这里是我的文件:

测试/ 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!'); 
    }); 
}); 

我只是不明白的地方,以便量角器/ webdriver的知道跑哪方面来定义我的web应用程序laypout /位置。

回答

0

使用该设置量角器将尝试导航到“/”。您需要在配置文件中设置baseUrl属性,或者在browser.get()中放入绝对URL。如果您的所有测试都将在同一个域中,我建议您选择第一个选项。

+0

谢谢你的回答。但如何知道baseUrl? – Archer

+0

这是您要测试的网站的网址! – Dan

+0

我想测试我的网站的本地副本,我认为应该在量角器/ webdriver启动时自动启动。 – Archer

相关问题