Skip to content
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

After launching the application window get minimized and not showing any window then how to get that application open? #2029

Open
VishGJadhav opened this issue Aug 26, 2024 · 2 comments

Comments

@VishGJadhav
Copy link

No description provided.

@anunay1
Copy link

anunay1 commented Aug 30, 2024

Need to switch to the opened application. But I see no reasons for the application to be minimized unless it does from you code.

@VishGJadhav
Copy link
Author

////>>>>>>>> This code for 1st application
AppiumOptions desiredCapabilities = new AppiumOptions();
desiredCapabilities.AddAdditionalCapability("app", @"C:\Program Files (x86)\Symtrax\Compleo Hybrid\XMLMapperV6.exe");

            CompleoXmlSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), desiredCapabilities);
            Assert.IsNotNull(CompleoXmlSession);
            var currentWindowHandle = CompleoXmlSession.CurrentWindowHandle;
            Thread.Sleep(TimeSpan.FromSeconds(15));
            var allWindowHandles = CompleoXmlSession.WindowHandles;

            CompleoXmlSession.SwitchTo().Window(allWindowHandles[0]);

//////>>>>>> This is for 2nd application
AppiumOptions ao = new AppiumOptions();
ao.AddAdditionalCapability("app", @"C:\Program Files (x86)\Symtrax\Compleo Hybrid\AdminSupervisor.exe");
ao.AddAdditionalCapability("ms:waitForAppLaunch", $"{30}");
ao.AddAdditionalCapability("ms:experimental-webdriver", false);

                supervisor = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), ao);
                Thread.Sleep(TimeSpan.FromSeconds(10));
                //supervisor.Manage().Window.Maximize();
                var process = Process.GetProcessesByName("AdminSupervisor").FirstOrDefault();
                IntPtr hWnd = FindWindow(null, "Symtrax - Compleo Supervisor");
                if (process != null)
                {
                    // Bring the process window to the front
                    SetForegroundWindow(process.MainWindowHandle);
                    SetForegroundWindow(hWnd);
                    //IReadOnlyCollection<string> windowHandles = supervisor.WindowHandles;
                    supervisor.SwitchTo().Window(supervisor.CurrentWindowHandle);
                }
                else
                {
                    Console.WriteLine("Process not found.");
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants