Skip to content

Window Handles list is empty #727

Open
@robertwatkins

Description

@robertwatkins

I'm trying to switch between windows using the 'switchto' method, which requires a window handle. When I try to get the list of window handles, I always get an empty list. The code below shows this. The code below also lists the titles of all the windows, indicating that there seems to be some disconnect.

Any thoughts?

import io.appium.java_client.windows.WindowsDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.URL;

public class GetWindowHandles {
    public static void main (String[] args) {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("app", "Root");
        WindowsDriver DesktopSession;
        try {
            DesktopSession = new WindowsDriver(new URL("http://127.0.0.1:5678"), capabilities);
            System.out.println("Window handles: " + DesktopSession.getWindowHandles());
            java.util.List elements = DesktopSession.findElementsByXPath("/Pane/Window");
            String titleText="";
            for (Object element : elements){
                titleText = ((WebElement)element).getText();
                System.out.println(titleText);
            }
            DesktopSession.switchTo().window("c:\\WINDOWS\\System32\\cmd.exe");
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

May 30, 2019 12:32:24 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: OSS
Window handles: []
C:\WINDOWS\System32\cmd.exe
C:\WINDOWS\System32\cmd.exe
Error: An unknown error occurred in the remote end while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'S7996', ip: '192.168.1.141', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: io.appium.java_client.windows.WindowsDriver
Capabilities {app: Root, javascriptEnabled: true, platform: WINDOWS, platformName: WINDOWS}
Session ID: B356EC4A-25F2-4A87-AB42-685428FA3434

Process finished with exit code 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions