To use ion-nav.getByIndex() , you need to use the ion-nav component (), but not the navController.
const nav = document.querySelector('ion-nav')
for(let i=0;i<100;i++) {
let v: any = await nav.getByIndex(i)
if (!v) // no more view
break;
console.log( v.component.name)
}
Unfortunately, the method getLength() is not public yet which is why Iām checking the validity of the first 100th views! : cf. pull request https://github.com/ionic-team/ionic/pull/17516