WinAppDriver-KRE-Jenkins: Failed to locate opened application window with appId

Hello there,

We are supporting a customer to run Windows app automation test with using KRE (Katalon Runtime Engine).
I am putting an issue relates to integration, where is using KRE to run Window application automation test on Jenkins node.
I know the issue could involve many factors include WinAppDriver, Jenkins and KRE. However, I would like to put all details here to discuss further.

Environment:

Test can execute fine on

  • Katalon Studio Enterprise (KSE).
  • Open Remote Desktop to the Jenkins node, open CMD (Run as Administrator), run test with command-line using KRE.

Test cann’t execute when

  • Trigger Jenkins job, with sending the same command-line.
    Note: It cann’t be executed even loggin in the RDP, keep without lock screen but nothing could be seen.

The command-line that we used as below

C:\software\Katalon_Studio_Engine_Windows_64-8.6.9\Katalon_Studio_Engine_Windows_64-8.6.9\katalonc.exe -noSplash -runMode=console -projectPath=“<path_to_project_dir>\Test0405.prj” -retry=0 -testSuitePath=“Test Suites\TS002” -executionProfile=“Jenkins” -browserType=“Windows” -statusDelay=15 -apiKey=<secrets_here>

The error could be seen

2025-02-21 12:31:27.271 DEBUG testcase.ICOLIMS Login and Launcher      - 5: startApplication(ApplicationPath)
2025-02-21 12:31:27.370 INFO  c.k.k.c.w.driver.WindowsDriverFactory    - Starting application D:\App\myApp.exe on the local machine at address http://127.0.0.1:4723
2025-02-21 12:31:27.375 INFO  c.k.k.c.w.driver.WindowsDriverFactory    - desiredCapabilities = {"ms:waitForAppLaunch":"50"}
Windows Application Driver listening for requests at: http://127.0.0.1:4723/

Press ENTER to exit.





==========================================

POST /session HTTP/1.1


Accept-Encoding: gzip


Connection: Keep-Alive


Content-Length: 332


Content-Type: application/json; charset=utf-8


Host: 127.0.0.1:4723


User-Agent: selenium/3.141.59 (java windows)





{

  "desiredCapabilities": {

    "app": "D:\\App\\myApp.exe",

    "ms:waitForAppLaunch": "50",

    "platformName": "Windows"

  },

  "capabilities": {

    "firstMatch": [

      {

        "appium:app": "D:\\App\\myApp.exe",

        "ms:waitForAppLaunch": "50",

        "platformName": "windows"

      }

    ]

  }

}


--------------------------------------------------------------------------------
Test Suites/xxx_TS002 - Windows - 20250221_123124..0/1(0%)
--------------------------------------------------------------------------------


--------------------------------------------------------------------------------
Test Suites/xxx_TS002 - Windows - 20250221_123124..0/1(0%)
--------------------------------------------------------------------------------


--------------------------------------------------------------------------------
Test Suites/xxx_TS002 - Windows - 20250221_123124..0/1(0%)
--------------------------------------------------------------------------------

HTTP/1.1 500 Internal Error


Content-Length: 165


Content-Type: application/json





{"status":13,"value":{"error":"unknown error","message":"Failed to locate opened application window with appId: D:\\App\\myApp.exe, and processId: 64972"}}

2025-02-21 12:32:23.840 ERROR c.k.k.core.keyword.internal.KeywordMain  - ? Unable to create a new remote session. Please check the server log for more details. Original error: Failed to locate opened application window with appId: D:\App\myApp.exe, and processId: 64972 (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 55.96 seconds

Based on the error message, we found few open issues like

In addition, the Jenkinsfile definition looks like

stages{
		stage ('Run Katalon Test') {
			steps {
				script {
					try {
						bat """
							echo "Clean old report ..."
							if exist ${REPORT_PUBLISH_ZIP} rmdir /S /Q ${REPORT_PUBLISH_ZIP}
							rmdir /S /Q ${WORKSPACE}\\${KATALON_PACKAGE_NAME}\\${REPORT_FOLDER}
							echo "Run Katalon ${CHOICE} test ..."
							if "${CHOICE}" == "${isTestSuite}" (
								${KATALON_CMD}\\katalonc.exe -noSplash -runMode=console -projectPath="${WORKSPACE}\\${KATALON_PACKAGE_NAME}\\${KATALON_PROJECT_FILENAME}" -retry=0 -testSuitePath="Test Suites\\${TSC_NAME}" -executionProfile="${KATALON_PROFILE}" -browserType="${BROWSER}" -statusDelay=15 --config -webui.autoUpdateDrivers=false
 							)
							)
							if "${CHOICE}" == "${isTestSuiteCollection}" (
								${KATALON_CMD}\\katalonc.exe -noSplash -runMode=console -projectPath="${WORKSPACE}\\${KATALON_PACKAGE_NAME}\\${KATALON_PROJECT_FILENAME}" -retry=0 -testSuitePath="Test Suites\\${TSC_NAME}" -executionProfile="${KATALON_PROFILE}" -browserType="${BROWSER}" -statusDelay=15 --config -webui.autoUpdateDrivers=false
 							)
							)
							set exitCode=%ERRORLEVEL%
							echo exitCode=%exitCode%                   
							

We are looking forward a solution or guideline to unblock this issue. Or it can be a sample project where it works then we can refer to.
Thank you in advance!

What’s the line that you’re launching the app look like? I had some issues with Windows.launchApplication() that sound similar, due to some updates to that keyword.

I have a fairly similar setup that I’m working on and have had similar issues that we had to resolve.

We’re working on a solution currently and trying to avoid RDP…Some of the posts i’ve read mention it’s not the best due to not being able to access the RDP session that is created.

Some of the solutions I’ve seen typically involve using a slave machine attached to the server and then sending SSH commands or something similar to execute the test suite.

The method I’ve been talking to katalon is essentially to send some SSH commands to the server (with some sort of UI device attached) to login to the server and then send the command lines to execute the test suite.

I am also interested in other solutions if anyone else has working examples.

After inspecting the current code and approach, probably, it isn’t adaptable to remote connection. More details are below.

Creating a batch file to get the current public IP of Node (via ipconfig) and use it to start WAD

launchWAD.bat

@ECHO OFF
 
FOR /F "TOKENS=2* DELIMS=:" %%A IN ('IPCONFIG ^| FIND "IPv4"') DO FOR %%B IN (%%A) DO SET IPADDR=%%B
ECHO %IPADDR%
 
cmd start /K "C:/Program Files (x86)/Windows Application Driver/WinAppDriver.exe" %IPADDR% 4723

:End

This requires to Run as Administrator, so let it be part of machine provisioning. Before coming to test execution, start WAD listens on e.g http://10.x.x.x:4723/

The test will be executed randomly on any Node. So, the next step will set the WAD URL to Desired Capabilities. I walk through KRE command-line syntax (Command-line syntax in Katalon Runtime Engine | Katalon Docs) but don’t see any argument to quick set for WinAppDriver URL.

  • I also tried with a few assumptions argument names like -winAppDriverUrl, -remoteWinAppDriverUrl, but none of them work.

So, I deal with it via script.

In Profile, adding a global variable with a default value

   <GlobalVariableEntity>
      <description>WinAppDriverUrl</description>
      <initValue>'http://127.0.0.1:4723/'</initValue>
      <name>WinAppDriverUrl</name>
   </GlobalVariableEntity>

In test, via RunConfiguration fetch global var and update new URL

import com.kms.katalon.core.configuration.RunConfiguration

RunConfiguration.setDriverPreferencesProperty('Windows', 'winAppDriverUrl', GlobalVariable.WinAppDriverUrl)

In Jenkinsfile, via KRE command line, pass the remote URL to arg -g_WinAppDriverUrl

The last thing would be RDP. There is no choice, we have to log off the remote session without disconnecting.

Hi @VietND96,

It’s great to see that you work hard to figure out the options. Currently, do you need further help or you are satisfied with what you found? We are willing to help you. Happy testing!

@Elly_Tran,

In the above comment, I have mentioned one point.

I walk through KRE command-line syntax (Command-line syntax in Katalon Runtime Engine | Katalon Docs) but don’t see any argument to quick set for WinAppDriver URL (Set desired capabilities in Windows desktop app testing | Katalon Docs)

Do we support an argument to change the URL quickly instead of changing via script?