Multiple webviews in hybrid app: Does getWindowHandles() maintain order of webviews?

If app page has multiple webviews on it and if we call driver.getWindowHandles() after switching context to webviews, does Appium (Or underlying automation framework) return the handles in a sequence they are rendered or seen in the application ?

getWindowHandles returns a set. Hence the order is not supposed to be maintained.

In case of multiple webviews(handles), one apporach is to iterate over all the webviews and find an object which we want. But this seems to be a costly approach for now.

So is it possible to relate webview index number with its handle ?

refer this : Switch to WebView using getcontexthandles()

The link doesn’t explain the behaviors of multiple webviews (Multiple handles) it explains the behavior of multiple contexts (There can be maximum 2 contexts in any app)