appium / appium/python-client

self.driver.window_handles returns the list randomly

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

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
570
Avg merge
1d 10h
Merged PRs (30d)
24

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

Contributor guide

No contributing guide indexed for this repository

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.

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.