问题
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