0

我正在尝试使用量角器编写基本的 e2e 测试。下面是我的测试。我添加了 console.log 以查看我是否可以访问 URL,日志中的输出显示调用的结果browser.getLocationAbsUrl()是一个“待定”( Promise::105 {[[PromiseStatus]]: "pending"}) 的承诺。我得到的错误是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 '/'

我的配置文件很简单:

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  baseUrl: 'http://localhost:8000',
  capabilities: {
    'browserName': 'chrome'
  },
  troubleshoot: true,
  specs: ['app/spec/e2e/**/*.coffee']
}
4

2 回答 2

0

你不能只是console.log()在 Protractor/Selenium 中做不同的事情,这都是承诺。您应该改为执行以下操作(对不起,我不擅长 CoffeeScript):

browser.get('index.html');
browser.getLocationAbsUrl().then(function(url) {
  console.log(url);
});
expect(browser.getLocationAbsUrl()).toBe('/');
于 2015-05-19T11:31:50.273 回答
-1

尝试删除这些行:

seleniumAddress: 'http://localhost:4444/wd/hub',
baseUrl: 'http://localhost:8000',
于 2015-05-18T13:55:39.787 回答