Skip to content

🐞 bug: driver.WindowHandles behavior not limited to the app launched #67

@kinland

Description

@kinland

Is there an existing issue for this?

  • I have searched the existing issues

Appium Version

3.2.2

Appium Host Type

Command Line

Current Behavior

I'm in the process of switching from WinAppDriver to NovaWindows Driver... This line behaves totally differently:

driver.SwitchTo().Window(driver.WindowHandles.First());

In WinAppDriver, that would be the app that you launched. But with NovaWindowsDriver, driver.WindowHandles appears to list ALL window handles, not just the ones related to the app that was launched!

Expected Behavior

Behavior should match what happened in WinAppDriver unless there's good reason to depart from that. In particular, driver.WindowHandles should not have visibility into totally unrelated applications.

Appium Log

https://gist.github.com/kinland/a2fe4377dbad04d1719f5c193a8e4a60

Environment Details

  • Debug details (appium --show-debug-info): appium_debug_info.txt

  • Last component version(s) which did not exhibit the problem: N/A

  • Platform and version of device under test: Windows 11 x64, classic app

  • Real device or emulator/simulator: real

Minimal Reproducible Example

// C#
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Windows;

namespace Tests
{
    [TestFixture]
    public class MinimalAppiumTest
    {
        
        [Test]
        public void TestNotepadLaunch()
        {
            var options = new AppiumOptions();
            options.AddAdditionalCapability("platformName", "Windows");
            options.AddAdditionalCapability("appium:automationName", "NovaWindows");
            options.AddAdditionalCapability("appium:app", @"C:\Windows\System32\notepad.exe");
                        
            WindowsDriver<WindowsElement>? driver = null;
            driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), options, TimeSpan.FromMinutes(1));            
            Assert.That(driver.WindowHandles, Has.Count.EqualTo(1));
                
            driver?.Quit();
        }
    }
}

Further Information

Simply opening notepad as described above results in something like:

TestNotepadLaunch (2s 966ms): Error Message: Assert.That(driver.WindowHandles, Has.Count.EqualTo(1))
Expected: property Count equal to 1
But was: 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions