我正在尝试实现定制的ExpectedConditions方法,它将等待element属性的更改。
以下是我的解决方案:
const ECC = function() {
this.attributeToHave = async (elementFinder, attrName, attrVal) => {
const EC = protractor.ExpectedConditions;
const hasAttr = async () => {
const actualText = elementFinder.getAttribute(attrName);
return actualText.indexOf(attrVal) !== -1;
};
return await EC.and(EC.presenceOf(elementFinder), await hasAttr);
};
};
module.exports = new ECC();
在我的心里
onPrepare
const {expectedConditions} = require('@utils/protractor');
global.ECC = expectedConditions;
最后在我的测试套件中:
await browser.wait(await ECC.attributeToHave(dropdown, 'aria-hidden', 'false'), 3000);
但它一直在说
Failed: Wait timed out after 3006ms