I am using page object model with yiewd
module.getElementByAccessibilityID = o_O(function* (ID, max_attempts) {
let cond = yield driver.hasElementByAccessibilityId(ID);
while (cond == false && max_attempts > 0) {
yield driver.setImplicitWaitTimeout(100);
cond = yield driver.hasElementByAccessibilityId(ID);
max_attempts--;
}
let el = yield driver.elementByAccessibilityId(ID);
return el;
});
I tried with the following function as well. Get page source if the element is not found. I checked the output of the source file, it did not contain the element I am after.
module.getElementByAccessibilityID = o_O(function* (ID, max_attempts) {
let cond = yield driver.hasElementByAccessibilityId(ID);
while (cond == false && max_attempts > 0) {
yield driver.setImplicitWaitTimeout(500);
var source = yield driver.source();
//console.log(source);
fs.writeFile('C:/logs/source.txt', source, function (err) {
if (err) return console.log(err);
console.log('Source > source.txt');
});
cond = yield driver.hasElementByAccessibilityId(ID);
max_attempts--;
}
let el = yield driver.elementByAccessibilityId(ID);
return el;
});