My goal is to get minimum required snapshot depth for each test. To achieve this i try to get depth for each element used in the test. I tried accessing parents until they exist with:
let depth = 0;
let element = await client.$(selector);
while (element) {
depth += 1;
try {
element = await element.$("..");
} catch (_) {
break;
}
}
but it doesn’t work.
Is there any other option besides getting source at each step and analyzing it?
Edit:
I want it to work with every selector type (not just xpath).
For element.parentElement(); I get: Method is not implemented.
Did not see that, my bad.
Are there any alternative methods for determining depth on iOS, besides bisection, that are compatible with all types of selectors?