-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WindowsHandles: Currently selected window has been closed #656
Comments
How long does the splash screen stay, even I faced issues while trying to automate an application with splash screen. If the splash screen stays for more than 3sec then it does not acquire session, you need to use the existing session. |
The splash screen stays around 5-10 seconds. |
Hi @burakdnbb, Thanks for reaching out and bring up the issue. A splash screen window is a UI element that is a part of the application UI experience. When desired, WinAppDriver can be used to automate against the splash screen to validate certain UI elements such as texts and progress bar. In most cases however, people are much more interested in the main application window that typically appears after the splash screen. When creating a new session (launching an application), WinAppDriver treats the first appearing top level application window (including a splash screen window) as the main window of the application and performs every operation against it. This becomes a hindrance for developers who only care about the main application window and want to ignore the splash screen altogether. Below are the top recommended options to circumvent such scenario. 1. If possible, launch the application with a no splash screen flag/option Certain application takes a command line argument to launch without showing a splash screen window. For example, you can launch Microsoft Word, Excel, and PowerPoint without splash screen as follows:
You can provide the command line argument in the 2. Manually switch the session to the desired top level application window Starting in v1.1.1 release, you can enumerate all the top level application windows using GetWindowHandles command and switch to the desired application window using SwitchToWindow command. Prior to this release, you can only enumerate the top level windows when the current window handle is still active. Hence this command used to fail when the session was pointing to a splash screen window that has already disappeared. The latest release allows you to enumerate all application windows even when the current active window is closed. In your scenario where a splash screen appears for 5 seconds until the main application window appears, calling the GetWindowHandles multiple times during this application startup period allows you to detect when the splash screen is dismissed and when the new application window is ready to be switched into. 3. Create a new session by attaching to an existing window Attaching to existing window is by far the most versatile approach as it can attach to any top level window even the one with different process Id. Nevertheless, you will potentially need to use another session to locate the top level window handle which is less straight forward from both options above. |
How do I do this with RobotFramework + AppiumLibrary? |
You can do that in test initialize |
@anunay1 can you give me some example code in order to do this? There are two problems:
|
Hi @YouWhy, Attaching to existing window section shows how to use a Desktop session to locate any currently active window/UI element on the desktop. This generic approach also allows you to cover both scenarios you mentioned above:
Another example can also be found below: |
@timotiusmargo Thank you for your pointers, but my problem is that I am using the Appium Client Library in Robot Framework. How do I access the Desktop Session in this development environment? Am I limited to what I can do if I choose Appium Client Library + (RobotFramework OR Python)? If yes, then I need to abandon this Proof of Concept and look at using C# for automation. Can you please advice? My teams are blocked by this and cannot proceed till this is resolved. Appreciate your response. |
Hi @YouWhy, You can use any binding and programming language of your choice. To create a Desktop Session, you simply need to create a new session with DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "Root");
DesktopSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities); While the object names (e.g. |
@timotiusmargo that worked!! I was able to create a desktop session and find the main outlook window and manipulate it after the splash screen disappeared. Thank you so much. However, I did face another issue. While trying to delete the session after I was done, Outlook was still open. That did not happen with a UWP app that I was working on. Why is that? Is that a limitation of WinAppDriver? |
Hi @YouWhy, I'm glad you got it working 👍 As long as your session points to the right application window, calling |
@timotiusmargo I use the "Close All Applications" keyword provided by Appium that sends an API call to close each open open session one by one. The Winappdriver console shows each of these calls it returns success STATUS 200 OK. So I am curious as to why this is happening...Could this be an issue? |
Hi @timotiusmargo, I am using the following code to open a powerpoint file. But the code is opening 2 windows 1) the default Powerpoint window and then 2) The file. It does all the operations in the default powerpoint window file instead of the given file. Can you please check - desired_caps = {} |
I've launched Excel with the code given below. It works fine.
|
is this possible to open a saved Excel file with winapp driver? When I try to open this. I checked the settings where I permit it |
Yes, it is possible to open a saved file with Excel. Just pass the file path in as a desired capability.
|
Thanks for the help @naeemakram :).is this possible to edit some cells in excel with winappdriver ? |
You're welcome, no it is not possible to edit Excel cells according to my experience. |
Thanks. Will you help me: I have to edit some values in the excel sheet and after that need to read the output. How I can perform this. |
Maybe you could use VBA scripting for this purpose, there's an Office development SDK as well. I'm not sure since I haven't done this type of work before. Don't think I will be able to help in this specific case. |
Hello everyone,
I have a question regarding the splash screen problem. @timotiusmargo mentioned in previous topics, that the problem with the window handles and the splash screen has been fixed as of release 1.1.1 (see issues #621 and #611). Is it included in this pre-release of the winappdriver, or is the fix still in progress? We checked the latest commits of this pre release 1.1.1 and did not see any changes compared to the previous version.
Right now we are trying to automate the Microsoft Dynamics NAV Client and we still have this issue with the splash screen. We also checked that the processid is the same (between splash screen and the new window that opens) Could you provide some info on that?
Thanks in advance
The text was updated successfully, but these errors were encountered: