这是我的 conf 文件:
// 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': 'phantomjs',
'phantomjs.binary.path': 'C:/Users/MY_USER_NAME/AppData/Roaming/npm/node_modules/phantomjs/phantomjs.exe'
},
// 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
}
};
这是我的 example_spec.js 文件
describe('angularjs homepage', function() {
it('should greet the named user', function() {
browser.get('http://www.angularjs.org');
element(by.model('yourName')).sendKeys('Julie');
var greeting = element(by.binding('yourName'));
expect(greeting.getText()).toEqual('Hello Julie!');
});
});
当我运行它时,我总是收到错误:
Error: Timed out waiting for page to load
Wait timed out after 10129ms
如果我切换到仅测试 chrome 它工作正常,但我似乎无法让 phantomjs 工作。我有最新版本的 phantomjs 和 Protractor ,全新安装。
最佳答案
原来有两件事发生了。
1) angularjs 站点只是不想工作
2) 如果没有这样的默认设置,您需要使用 phantomjs 设置浏览器分辨率:browser.driver.manage().window().setSize(1124, 850);
我在每个之前都运行过:
beforeEach(function(){
browser.driver.manage().window().setSize(1124, 850);
});
然后我开始进行通过的测试。
关于angularjs - 等待页面加载超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24166334/