isSelected returns false and isChecked shows compilation error

若如初见. 提交于 2019-12-04 05:45:31

问题


let checkBoxXpath = accessPolicyPage.listCheckBoxXpathS + i + accessPolicyPage.listCheckBoxXpathE;
//element(by.xpath(checkBoxXpath)).click();
expect(element(by.xpath(checkBoxXpath)).isSelected()).toBeTruthy();

in the above code isSelected returns false and if I replace it by isChecked, it shows error as "property 'ischecked' not found on ElementFinder"

How I can overcome this


回答1:


There is nothing called isChecked in Protractor. You can do this by using isSelected.

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

Refer this to more information. Hope this helps. :)



来源:https://stackoverflow.com/questions/36004599/isselected-returns-false-and-ischecked-shows-compilation-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!