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.

Not able to getWindowHanldes in outlook after closing splash window

See original GitHub issue
capabilities = new DesiredCapabilities();		
capabilities.setCapability("app", "C:\\Program Files (x86)\\Microsoft Office\\Office15\\OUTLOOK.exe");
windowDriver = new WindowsDriver<WebElement>(new URL("http://127.0.0.1:4723"), capabilities);			
windowDriver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
Thread.sleep(1000*10);
Set<String> set=windowDriver.getWindowHandles();
org.openqa.selenium.WebDriverException: Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
System info: host: 'NDE-58717135', ip: '10.187.67.237', 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=C:\Program Files (x86)\Microsoft Office\Office15\OUTLOOK.exe, platformName=Windows, platform=ANY}]
Session ID: 7068CCCF-836B-4F49-B6D0-47AF58CBF4AD
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
	at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
	at io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1)
	at org.openqa.selenium.remote.RemoteWebDriver.getWindowHandles(RemoteWebDriver.java:509)
	at com.bcg.outlook.testcases.OutlookDesktop.outlookDesktop(OutlookDesktop.java:53)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
	at org.testng.TestRunner.privateRun(TestRunner.java:648)
	at org.testng.TestRunner.run(TestRunner.java:505)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
	at org.testng.TestNG.runSuites(TestNG.java:1049)
	at org.testng.TestNG.run(TestNG.java:1017)
	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Kamilbrd1commented, Apr 16, 2019

Apologies for the delay, I’ve just implemented v1.1.1 and can confirm it works as intended, the workaround with multiple driver sessions is no longer required. Thank you for the support.

@YouWhy What I think you are doing above is trying to find the element in the splash screen window and that has been closed. You still have to switch windows and make sure it’s the correct one in case the splash screen is slow to disappear. Here’s a bit of code that should help you get the idea:

for (int attempt = 0; attempt < 5; attempt++)
                {
                    var WindowHandles = _driver.WindowHandles;
                    try
                    {
                        _driver.SwitchTo().Window(WindowHandles[0]);
                        if (_driver.FindElementByName(<outlook_main_window_name>).Displayed)
                        {
                            break;
                        }
                    }
                        catch (Exception) { }
                }    
return _driver;     
2reactions
liljohnakcommented, Feb 22, 2019

@Bulbul1234 This works for me. I have a splash screen and a log-in. But, here is the code for the splash screen.

public static void StartApplication()
    {
      if (session == null)
      {
        DesiredCapabilities appCapabilities = new DesiredCapabilities();
        appCapabilities.SetCapability("app", "MyApp.exe");
        appCapabilities.SetCapability("newCommandTimeout", "100");
        appCapabilities.SetCapability("platformName", "Windows");
        appCapabilities.SetCapability("deviceName", "WindowsPC");
        session = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);
        Assert.IsNotNull(session);
        string splash = $"{session.CurrentWindowHandle}";
        WebDriverWait wait = new WebDriverWait(session, new TimeSpan(0, 0, 15));
        wait.Until(drv => drv.WindowHandles[0] != splash);
        session.SwitchTo().Window(session.WindowHandles[0]);
        System.Collections.ObjectModel.ReadOnlyCollection<string> allWindowHandles = session.WindowHandles;
      }
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Outlook starts up slowly and hangs at splash screen when ...
Outlook starts up slowly and hangs at splash screen when REST to MAPI is unexpectedly toggled - Microsoft Support.
Read more >
Unable to get the handle of a newly opened window in IE ...
I found the solution to my problem. Just make sure you follow all the steps as you see at Solution answered by @DebanjanB....
Read more >
How to handle multiple windows in Selenium
Selenium WebDriver provides various methods for handling of windows. Few of them are: getWindowHandle( ): When a website opens, we need to ...
Read more >
Working with windows and tabs
Close all the windows and tabs associated with that WebDriver session · Close the browser process · Close the background driver process ·...
Read more >
W3layouts cms exploit
modrapal not close bootstrap modal popup bootstrap modal popup background fake ... splash on listview flutter, how to perform function after building screen...
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