Skip to content

[🚀 Feature]: [java] Ordered version of getWindowHandles() #16253

@abhishekmali1950-ops

Description

@abhishekmali1950-ops

Description

Hi Selenium Team,

I’m quite new to Selenium, still learning and practicing, so apologies if this suggestion sounds basic.

Right now, driver.getWindowHandles() returns a Set. Since a Set is unordered, when we convert it into a List/ArrayList, the order of window handles is not guaranteed. Many beginners (including me at first) end up using indexing after converting it to a List, which doesn’t always give the expected result.

I know the best practice is to loop and check by title/URL, but I was thinking — would it make sense to provide an additional method like getWindowHandlesOrdered() which returns the handles in the order they were opened?

It might help people (especially beginners) who assume index-based navigation will work, and make test code a bit simpler in cases where order matters.

Thank you for considering this idea 🙏

Have you considered any alternatives or workarounds?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-javaJava BindingsI-enhancementSomething could be better

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions