[英]Protractor cannot find angular on window
I am trying to write a basic e2e test with protractor. 我正在尝试用量角器编写基本的e2e测试。 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"}
). 我添加了console.log来查看是否可以访问URL,日志中的输出显示了对
browser.getLocationAbsUrl()
的调用结果browser.getLocationAbsUrl()
是一个“待定”的Promise::105 {[[PromiseStatus]]: "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"
我收到的
Error while waiting for Protractor to sync with the page: "angular could not be found on the window"
是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. 您不能只在量角器/硒中使用
console.log()
不同的东西,这就是所有的承诺。 You should do the following instead (sorry I am not goodin in CoffeeScript): 您应该改为执行以下操作(很抱歉,我不擅长使用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',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.