WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

How to access the windows outside the current app

Open BISTArk opened this issue 2 years ago • 4 comments

I want to access the elements outside the child tree of my main window, is it possible to do with appium?

For example, In the picture of inspect.exe shown below assume,I have started the appium server with app capability as the path to the command prompt (App1) I have clicked a button in the command prompt window(App1) which opens a child process "untitled- Notepad " window(window2) even though the notepad(window2) is launched from command prompt(App1) , the window2 is not a child of window1(as seen in the picture). Is there any way to access the window2 using appium when the driver capability has the app as App1?

Basically, can i access the sibling windows that appear in the inspect tool from a driver with app capability as one of those apps? inspect

BISTArk avatar Jun 07 '22 02:06 BISTArk

you can use capability as capability.setCapability("app", "Root"); This will be root object for your desktop. Now you can access any objects using title name of the second notepad object and then you can traverse along.

stevensmaria22 avatar Jun 07 '22 15:06 stevensmaria22

@BISTArk You can also initialize two separate drivers which will be working on the same port of winAppDriver. When action to open second window is executed, You can find a Process by Name (notepad in this case), then get its MainWindowHandle and parse it to Hex (ToString('x'))and initialize second WindowsDriver but in appCapability use appTopLevelWindow instead of app location - this will create a new driver that attach to already opened application.

kamilchodola avatar Jun 29 '22 14:06 kamilchodola

@BISTArk You can also initialize two separate drivers which will be working on the same port of winAppDriver. When action to open second window is executed, You can find a Process by Name (notepad in this case), then get its MainWindowHandle and parse it to Hex (ToString('x'))and initialize second WindowsDriver but in appCapability use appTopLevelWindow instead of app location - this will create a new driver that attach to already opened application.

Sounds Interesting will try this out. sing Root as the app capability is working great for me as of now.

BISTArk avatar Jun 29 '22 15:06 BISTArk

you can use capability as capability.setCapability("app", "Root"); This will be root object for your desktop. Now you can access any objects using title name of the second notepad object and then you can traverse along.

Do you know the equivalent of this for macOs ?

BISTArk avatar Jul 07 '22 11:07 BISTArk