【问题标题】:isSelected returns false and isChecked shows compilation errorisSelected 返回 false 并且 isChecked 显示编译错误
【发布时间】:2016-03-15 16:39:26
【问题描述】:
let checkBoxXpath = accessPolicyPage.listCheckBoxXpathS + i + accessPolicyPage.listCheckBoxXpathE;
//element(by.xpath(checkBoxXpath)).click();
expect(element(by.xpath(checkBoxXpath)).isSelected()).toBeTruthy();

在上面的代码中isSelected返回false,如果我用isChecked替换它,它会显示错误为“在ElementFinder上找不到属性'ischecked'”

我该如何克服这个问题

【问题讨论】:

  • 那是因为 DOM 中没有该元素。
  • 元素在那里,我可以通过“click()”访问它
  • 我认为您使用的是量角器...如果是这样,isChecked 没有给出定义...您可以参考-angular.github.io/protractor/#/…

标签: angularjs jasmine protractor


【解决方案1】:

Protractor 中没有任何名为 isChecked 的内容。您可以使用 isSelected 来做到这一点。

webdriver.WebElement.prototype.isSelected = function() {
  return this.schedule_(
      new webdriver.Command(webdriver.CommandName.IS_ELEMENT_SELECTED),
      'WebElement.isSelected()');
};

请参阅this 了解更多信息。希望这可以帮助。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-17
    • 1970-01-01
    • 2012-06-24
    • 1970-01-01
    • 2018-12-14
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    相关资源
    最近更新 更多