Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

self.driver.window_handles returns the list randomly

Open
#1,076 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
mobile

Research direction

Start with the reproduction code in the issue and inspect the linked Appium server log, focusing on the values returned by self.instance.window_handles after switching to the web context. Compare the observed ordering with the behavior from the earlier Appium version; done means the ordering issue or a concrete supported way to select the latest window is identified.

Written by the indexing model from the issue text.

Description

The problem

self.driver.window_handles returns the list randomly, earlier the latest window handle used to be max from the list, now its neither max nor latest element of the array i.e -1 so there is no concrete way to switch to the latest window.

Environment

  • Appium version: 2.13.1
  • Last Appium version that did not exhibit the issue (if applicable): 1.65
  • Desktop OS/version used to run Appium:
  • Node.js version (unless using Appium.app|exe): v18.19.1
  • Mobile platform/version under test: Samsung S23 FE
  • Real device or emulator/simulator:
  • Appium CLI or Appium.app|exe:

Link to Appium Logs

appium_server_logs_11-27-37.log

Create a GIST which is a paste of your full Appium logs, and link them here.

Code To reproduce issue

        ```
        self.appium_opr.switch_context(self.instance, "web")
        time.sleep(CONTEXT_WAIT)
        all_windows = self.instance.window_handles
        window_after = max(all_windows)
        self.instance.switch_to.window(window_after)
        url = self.instance.current_url
Dominant language
Python
Stars
1.8k
Forks
570
Avg merge
1d 10h
Merged PRs (30d)
24

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from appium/python-client

All issues in appium/python-client

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.