question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Session can´t find childWindow(s)

See original GitHub issue

Hi,

i can´t find the child window of my windows application. I am using WPF. The windows are under the same processes and there is no splashing screen.

I´ve tried to transfer the solution of #99, but the WindowPopUpFinder throws an timeout error. I also gave back the window handles, but i just got 1 item, the application itself.

inspec Here you can see the hierarchy. I am opening the mediaCollectionWindow with a MenuItem.

When I´m trying this:

            // Open menu 
            WindowsElement menu = _mainWindow.FindElementByAccessibilityId(MAIN_WINDOW.MENU_VIDEO);
            menu.Click();

            // Open modal window via finder
            WindowsElement openVideoWindow = 
(WindowsElement)menu.FindElementByAccessibilityId(MAIN_WINDOW.MENU_ITEM_OPEN_VIDEO);
            PopupWindowFinder finder = new PopupWindowFinder(_mainWindow);
            Thread.Sleep(2000); 
            string videoWindowHandler = finder.Click(openVideoWindow);

            // switch to window
            WindowsDriver<WindowsElement> videoWindow = 
(WindowsDriver<WindowsElement>)_mainWindow.SwitchTo().Window(videoWindowHandler);  

i get the timeout answer as “User-Unhandled”-Exception.

Here i also got an timeout-exception:

            // Open menu 
            WindowsElement menu = 
_mainWindow.FindElementByAccessibilityId(MAIN_WINDOW.MENU_VIDEO);
            menu.Click();

            // Open modal window 
            menu.FindElementByAccessibilityId(MAIN_WINDOW.MENU_ITEM_OPEN_VIDEO).Click();
            Thread.Sleep(2000); 
            
            // switch to window
            WindowsDriver<WindowsElement> videoWindow = 
(WindowsDriver<WindowsElement>)_mainWindow.SwitchTo().Window(MEDIA_COLLECTION.MEDIA_COLLECTION_WINDOW_TITLE);
            

And here i got just one item

            ReadOnlyCollection<string> windowHandlesBefore = _mainWindow.WindowHandles; 

            // Open menu 
            WindowsElement menu = _mainWindow.FindElementByAccessibilityId(MAIN_WINDOW.MENU_VIDEO);
            menu.Click();

            // Open modal window
            menu.FindElementByAccessibilityId(MAIN_WINDOW.MENU_ITEM_OPEN_VIDEO).Click();
            Thread.Sleep(2000);

            // Look for windows
            ReadOnlyCollection<string> windowHandlesAfter = _mainWindow.WindowHandles;

And here is the result windowHandles

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dquistcommented, Nov 18, 2019

I ran into similar problem in a .NET Core 3 WPF project. No splash screen. WindowHandles would only return the main window handle even after child windows were opened. The parent/owner was set correctly and I verified with inspect.exe that the new window was in fact a child.

You can, however, interact with the child window elements through the WindowsElement API of the window itself. I was able to use this approach to open an ‘About’ window through a menu and then close it.

[Test]
public void TestAboutWindow()
{
    // Open About window through menu
    _session.FindElementByName("Help").Click();
    _session.FindElementByName("About").Click();

    // Close child window through WindowElement API
    var aboutWindow = _session.FindElementByName("AboutWindow");
    aboutWindow.FindElementByName("Close").Click();
 }
1reaction
naeemakramcommented, Jun 24, 2019

I’m sorry, I can’t say for sure since I haven’t tried on Windows Server 2016. Which version of WinAppDriver are you using? I remember someone had a problem finding windows using desktop session in recent stable release(1.1). If you’re using the stable release, try using the pre-release version i.e. 1.1.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maintaining the same Session in Child Window - php
When writing AJAX apps, I usually use window.location.host property to get the domain in JS so that I'm sure the XMLHttpRequest is made...
Read more >
Getting the session from parent to child window in JSP - ...
The problem that am facing is, am not able to get the session object of the parent window in child window. It is...
Read more >
How to maintain session in Both Parent window and child ...
I am using session concept in application. After login my application the Main screen screen is comming which we call parent window. Under...
Read more >
How to handle multiple windows in Selenium
WebElement text = driver. findElement(By.id("sampleHeading")): Find the element and store in a web element through which we will get the text ...
Read more >
Handling child window with parent session
Hi All, In my bsp application there is a child window with in parent.While i logoff from the parent window i want the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found