Katalon testing with Winium, unable to focus on window

Hi all, I’m trying to follow the instruction for testing with Winium for the default Windows 10 calculator app, I followed this post here:

I added all jars files as instructed, I had Winium.Desktop.Driver running at port 9999

However there is 1 problem which I don’t know how to solve, this block of code right here

driver.findElementByName(“Four”).click()
driver.findElementByName(“Plus”).click()
driver.findElementByName(“Five”).click()
driver.findElementByName(“Equals”).click()

Everything up until that point was fine, the calculator app started up, but then my cursor started clicking randomly, at the taskbar, at the corner of the desktop, anywhere but the button 4 or + from the calculator. Can anyone help, what’s going on?

This is my full source code:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

import org.eclipse.persistence.internal.oxm.record.json.JSONParser.pair_return
import org.openqa.selenium.By as By
import org.openqa.selenium.WebElement as WebElement
import org.openqa.selenium.winium.DesktopOptions as DesktopOptions
import org.openqa.selenium.winium.WiniumDriver as WiniumDriver
import java.net.MalformedURLException as MalformedURLException
import java.net.URL as URL
import io.appium.java_client.windows.WindowsDriver as WindowsDriver
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW

WiniumDriver driver = null
String appPath = “C:/windows/system32/calc.exe”
DesktopOptions option = new DesktopOptions()
option.setApplicationPath(appPath)
option.setDebugConnectToRunningApp(false)
option.setLaunchDelay(2)
driver = new WiniumDriver(new URL(“http://localhost:9999”),option)
Thread.sleep(1000)
WebElement window = driver.findElement(By.name(“Calculator”))

driver.findElementByName(“Four”).click()
Thread.sleep(100)

driver.findElementByName(“Plus”).click()
Thread.sleep(1000)
driver.findElementByName(“Five”).click()
Thread.sleep(1000)
driver.findElementByName(“Equals”).click()

String result = driver.findElement(By.id(‘CalculatorResults’)).getAttribute(‘Name’)

Thread.sleep(200)

WebUI.verifyEqual(result, “Display is 9”)