【问题标题】:Protractor selector and event issue量角器选择器和事件问题
【发布时间】:2014-06-19 07:11:25
【问题描述】:

我正在尝试使用量角器为我的应用创建一些测试。

browser.get 没问题,当我的页面加载完毕并启动我的应用程序时,第一个测试正在运行。

it('should go to the where and when page', function() {     
  var nextButton = element(by.id('cg_btnValidationQuoi'));
  expect(nextButton.getText()).toBe('Suivant');
}

这会导致超时。

it('should go to the where and when page', function() {     
  var nextButton = element(by.id('cg_btnValidationQuoi'));
  nextButton.click()
}

导致“错误:使用定位器找不到元素:By.id("cg_btnValidationQuoi")”

it('should go to the where and when page', function() {     
  var nextButton = element(by.id('cg_btnValidationQuoi'));
  expect(nextButton.getInnerHtml()).toBe('Suivant');
}

原因:

信息: 预期的 ' 被告人 '成为'Suvant'。

这听起来像是任何人都知道的事情吗?

【问题讨论】:

  • 你用的是哪个量角器版本?
  • 这确实很奇怪,我们显然遗漏了一些东西。你能给我们更多的代码/信息吗?
  • 我无法粘贴原始代码,但我写了一个类似的副本!在这里找到它:jsfiddle.net/89AR9

标签: angularjs protractor angularjs-e2e


【解决方案1】:

toBe() 检查它是否是完全相同的对象(字符串)。我建议使用toEqual() 看看它是否有效。 More info in this SO Answer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-21
    • 1970-01-01
    相关资源
    最近更新 更多