Hello, Katalon users/ support. Having an issue launching app using in Katalon. Any suggestion how to resolve this
issue? Stack is attached
=============== ROOT CAUSE ========.txt|attachment (16.6 KB)
Based on the error logs, the core issue is a connection failure between Katalon and Appium, specifically java.net.ConnectException: Connection refused.
1. Verify Appium Server Status
groovy
// Add this check BEFORE starting the app
def isAppiumRunning = "netstat -an | find \"4723\"".execute().text.contains("LISTENING")
if (!isAppiumRunning) {
throw new Exception("❌ Appium server not running on port 4723!")
}
2. Force Appium Connection Reset
Replace your start command with:
groovy
import io.appium.java_client.service.local.AppiumDriverLocalService
import io.appium.java_client.service.local.AppiumServiceBuilder
// Stop any existing Appium instance
AppiumDriverLocalService service = AppiumDriverLocalService.buildService(
new AppiumServiceBuilder().usingPort(4723).withArgument(() -> "--allow-insecure=get_server_logs")
)
service.stop()
// Start fresh Appium session
service.start()
// Add 5-second stabilization delay
Thread.sleep(5000)
// Now launch app
Windows.startApplicationWithTitle("your_app_path", "your_app_title")
3. Update Key Capabilities
Add these to your desired capabilities:
groovy
'newCommandTimeout': 300,
'appium:automationName': 'windows',
'appium:createSessionTimeout': 60000,
'appium:platformName': 'Windows'
4. Port Conflict Resolution
groovy
// Find available port dynamically
def findFreePort() {
new ServerSocket(0).withCloseable { socket -> socket.getLocalPort() }
}
def appiumPort = findFreePort()
// Start Appium on dynamic port
def service = AppiumDriverLocalService.buildService(
new AppiumServiceBuilder()
.usingPort(appiumPort)
.withArgument(() -> "--base-path=/wd/hub")
)
service.start()
// Connect using dynamic port
WindowsDriver driver = new WindowsDriver(
new URL("http://127.0.0.1:$appiumPort/wd/hub"),
yourCapabilities
)
5. Firewall/Network Fix
Run these in PowerShell as administrator:
powershell
# Allow Appium through firewall
New-NetFirewallRule -DisplayName "Allow Appium" -Direction Inbound -LocalPort 4723 -Protocol TCP -Action Allow
# Reset network stack
netsh winsock reset
netsh int ip reset
ipconfig /release
ipconfig /renew
6. Driver Cleanup Workflow
Add this error recovery block:
groovy
try {
Windows.startApplicationWithTitle("your_app_path", "your_app_title")
} catch (Exception e) {
// Kill orphaned processes
Runtime.getRuntime().exec("taskkill /f /im WinAppDriver.exe")
Runtime.getRuntime().exec("taskkill /f /im node.exe")
// Wait 5 seconds
Thread.sleep(5000)
// Retry with new driver instance
WindowsDriverFactory.changeDriver(new WindowsDriver(...))
}
7. Environment Verification
Check these prerequisites:
- WinAppDriver installed at
C:\Program Files (x86)\Windows Application Driver - Developer Mode enabled in Windows Settings
- Appium installed via:
text
npm install -g appium@2.1.1
appium driver install windows
- Java version matches Katalon’s JRE (17.0.7)
8. Debugging Steps
Add these diagnostic commands:
groovy
// Check Appium connectivity
println "Appium status: ${new URL("http://localhost:4723/wd/hub/status").getText()}"
// Verify WinAppDriver
def winAppDriver = new File("C:/Program Files (x86)/Windows Application Driver/WinAppDriver.exe")
assert winAppDriver.exists() : "WinAppDriver missing at ${winAppDriver.path}"
Critical Configuration Notes:
- Appium 2.0+ requires plugins:
bash
appium driver install --source=npm appium-windows-driver
- Capability requirements:
groovy
[
'ms:experimental-webdriver': true,
'appium:windowsApp': 'your_app_path',
'appium:appArguments': '--start-maximized',
'appium:appWorkingDir': 'C:\\your_app_dir'
]
- Katalon Windows plugin must be enabled:
- Go to Settings > Plugins > Windows Testing and verify installation
If issues persist after these steps:
- Collect full network traces:
bash
netsh trace start capture=yes persistent=yes
# Run test
netsh trace stop
- Check Windows Event Viewer for
Application Errorlogs - Test manual connection using cURL:
bash
curl -X POST http://localhost:4723/wd/hub/session -d '{"capabilities":{...}}'
