Switch to window title takes long - desktop app

When running switch To Window Title, it takes more than 30 seconds to finish execute. How do I find an application window faster

1 Like

How is it written in your script? Because I have no problems with changing windows and it goes pretty fast.

I use:
Windows.startApplicationWithTitle() followed by
WIndows.switchToWindowTitle()

I just decided to run the script with these two lines and necessary parameters and it took 10s to switch

However if I use
Windows.startApplicationWithTitle() followed by
switchToWindow(findWindowsObject())

then it takes 1s

Also i am using Windows.startApplicationWithTitle() multiple times to start multiple applications

Ah, this is for a desktop app right?
I thought this was a webbased question. I got no experience in desktop apps with Katalon. Only using the WebUI one. Sorry can’t help you with this :frowning:

Hope someone else can!

Hello Safrad,
Greetings !!

I just started with my desktop automation and facing the same issue- switching between windows is too slow. appreciate if you can assist me in resolving this issue

1 Like

I have the same problem. Slow switching :confused:

Same here. It takes 10-15 seconds ti click on the title bar.

Hi,

Try below steps:

  1. Windows.getDriver().getwindowhandles() --> this step gives all windowhandle names
  2. Windows.getDriver().switchto(handlename) --> iterate through each handle
  3. Windows.getDriver().gettitle().equals() --> compare the title, if match, use the handle else, get back current to window handle

Note: this works if you want to switch between same application windows, because getwindowhandles() method returns windows of application we are using

1 Like

I’m also facing the same problem. It is very slow and execution time is too long. Somebody please throw some light here.

Thanks

Hi @ram.natarajan ,

I saw that @safrazd has found a workaround for this issue, but it seems not really clear for anyone to follow.

So, I will show here a demo script for that solution.

import com.kms.katalon.core.testobject.WindowsTestObject
import com.kms.katalon.core.testobject.WindowsTestObject.LocatorStrategy


Windows.startApplicationWithTitle('notepad', '')

// Or if you want to switch to another window immediately, use this:

//Windows.startApplicationWithTitle('Root', '')
//WindowsTestObject targetWindow0 = new WindowsTestObject()
//targetWindow0.setLocator('hello.txt - Notepad')
//targetWindow0.setLocatorStrategy(LocatorStrategy.NAME)
//Windows.switchToWindow(targetWindow0)


Windows.setText(findWindowsObject('Object Repository/Notepad 01/Edit'), 'hello')

// You can create a dummy Windows Test Object
WindowsTestObject targetWindow1 = new WindowsTestObject()
targetWindow1.setLocator('hello.txt - Notepad')
targetWindow1.setLocatorStrategy(LocatorStrategy.NAME)

// ...or you can use an existing Windows Test Object
WindowsTestObject targetWindow2 = findWindowsObject('Object Repository/Notepad 01/Window', [('title') : 'hello.txt - Notepad'])

Windows.switchToDesktop()
Windows.switchToWindow(targetWindow1)

Windows.setText(findWindowsObject('Object Repository/Notepad 01/Edit'), 'hello')

Windows.closeApplication()

and this is my “existing Windows Test Object” that I used in the example above

1 Like

Hi, I have tried many things to be able to switch to a window with a certain title and nothing works except one thing.

I have tried all solutions proposed on this page (and others), and the only one that kind of works is

Windows.switchToWindowTitle()

But this process ALWAYS goes trough the full 120 seconds to find it.

Before it switches, I am unable to tell it to switch using a title or a handle
I am unable to get any handle and it won’t find the title
After it switches (using whatever title in the method), I am able to get its title and handle…

I have not found a way to override the 120 seconds or any way to make this work otherwise

It is an HTA app that closes itself to open another HTA one.