Using C# how would I swipe until an element is found and once the element is found click the element.
In javascript I use the following iterative function.The logic should be pretty much same in C#
var swipeAndFindElement= async function (driver, elementId) {
let els = await driver.elementsById(elementId);
if (els.length > 0 && await els[0].isDisplayed()) {
console.log('The element has been found);
return await els[0].click();
} else {
await helper.swipe(driver);
await swipeAndFindElement(driver, elementId);
};
};
Swipe function in helper is:
var wd = require("wd");
var TouchAction = wd.TouchAction;
exports.swipe = async function (driver) {
try {
let action = new TouchAction(driver);
action
.press({ x: 17, y: 1300 })
.wait(2000)
.moveTo({ x: 17, y: 254 })
.release();
return await action.perform();
} catch (err) {
console.log(err);
}
};