Desktop Testing: Notepad Find and Replace

I have a relatively simple testcase to complete to see if Katalon Desktop testing is going to work for our business.

Open Notepad.exe - :white_check_mark:

  1. Enter “Hello Testing” :white_check_mark:
  2. Click menu item Edit :white_check_mark:
  3. Click sub menu Item replace :x:
  4. Enter “Testing” into the find text box
  5. Enter "Katalon Testing into the replace Textbox
  6. Click ‘Replace all’
  7. Close the Replace Modal
  8. Verify the Text now Reads “Hello Katalon Testing”

I’m sure I had been able to get the replace click working before, but then I struggled to get Katalon to recognise the popup window for replace, and therefore couldnt enter values or click buttons in that popup.

If anyone could guide me to get this simple prototype to work end to end it would help our evaluation of Katalon

This is the incomplete test script
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 static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
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.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

‘start application ok’
Windows.startApplicationWithTitle(‘C:\Windows\System32\notepad.exe’, ‘’)

‘target text pane’
Windows.click(findWindowsObject(‘Object Repository/Notepad/Document(1)’))

‘enter text into pane’
Windows.setText(findWindowsObject(‘Object Repository/Notepad/Document(1)’), ‘Hello Testing’)

‘click menu item edit’
Windows.click(findWindowsObject(‘Object Repository/Notepad/MenuItem(1)’))

‘issue getting the windows recorder to provide access to the replace menu item’
WebUI.click(findTestObject(null))

‘potential issue targeting pane’
Windows.click(findWindowsObject(‘Object Repository/Notepad/Pane’))

‘potential issue targeting pane objects’
Windows.setText(findWindowsObject(‘Object Repository/Notepad/Edit’), ‘Testing’)

Windows.setText(findWindowsObject(‘Object Repository/Notepad/Edit(1)’), ‘Katalon Testing’)

Windows.click(findWindowsObject(‘Object Repository/Notepad/Button’))

Windows.click(findWindowsObject(‘Object Repository/Notepad/Button(1)’))

changedText = Windows.getText(findWindowsObject(‘Object Repository/Notepad/Document(1)’))

WS.verifyEqual(changedText, “Hello Katalon Testing”)

Error at step 3


com.kms.katalon.composer.windows.exception.WindowsComposerException: org.openqa.selenium.TimeoutException: Expected condition failed: waiting for com.kms.katalon.core.windows.keyword.helper.WindowsActionHelper$1@1003e854 (tried for 0 second(s) with 50 milliseconds interval)
at com.kms.katalon.composer.windows.action.WindowsActionHandler$BaseActionObjectHandler.perform(WindowsActionHandler.java:319)
at com.kms.katalon.composer.windows.action.WindowsActionHandler.perform(WindowsActionHandler.java:83)
at com.kms.katalon.composer.windows.dialog.WindowsRecorderDialog.performAction(WindowsRecorderDialog.java:455)
at com.kms.katalon.composer.windows.dialog.WindowsRecorderDialog.lambda$2(WindowsRecorderDialog.java:413)
at com.kms.katalon.composer.windows.action.WindowsActionButtonWrapper$1.widgetSelected(WindowsActionButtonWrapper.java:33)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4213)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1037)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4030)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3630)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:823)
at org.eclipse.jface.window.Window.open(Window.java:799)
at com.kms.katalon.composer.windows.dialog.WindowsRecorderDialog.open(WindowsRecorderDialog.java:185)
at com.kms.katalon.composer.windows.handler.RecordWindowsObjectHandler.execute(RecordWindowsObjectHandler.java:81)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:319)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:253)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
at org.eclipse.e4.ui.workbench.renderers.swt.DirectContributionItem.executeItem(DirectContributionItem.java:133)
at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.handleWidgetSelection(AbstractContributionItem.java:449)
at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.lambda$2(AbstractContributionItem.java:475)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4213)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1037)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4030)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3630)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1158)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1047)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:658)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:557)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:154)
at com.kms.katalon.core.application.WorkbenchApplicationStarter.start(WorkbenchApplicationStarter.java:23)
at com.kms.katalon.application.Application.runGUI(Application.java:191)
at com.kms.katalon.application.Application.start(Application.java:102)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
at org.eclipse.equinox.launcher.Main.run(Main.java:1447)
Caused by: org.openqa.selenium.TimeoutException: Expected condition failed: waiting for com.kms.katalon.core.windows.keyword.helper.WindowsActionHelper$1@1003e854 (tried for 0 second(s) with 50 milliseconds interval)
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:304)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
at com.kms.katalon.core.windows.keyword.helper.WindowsActionHelper.findElement(WindowsActionHelper.java:120)
at com.kms.katalon.core.windows.keyword.helper.WindowsActionHelper.findElement(WindowsActionHelper.java:77)
at com.kms.katalon.core.windows.keyword.helper.WindowsActionHelper.findElement(WindowsActionHelper.java:69)
at com.kms.katalon.core.windows.keyword.helper.WindowsActionHelper.click(WindowsActionHelper.java:248)
at com.kms.katalon.composer.windows.action.WindowsActionHandler$ClickActionHandler.performAction(WindowsActionHandler.java:547)
at com.kms.katalon.composer.windows.action.WindowsActionHandler$BaseActionObjectHandler$1.run(WindowsActionHandler.java:275)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: Exceptions | Selenium
Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’
System info: host: ‘VSL-MSL-25’, ip: ‘192.168.86.40’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_282’
Driver info: io.appium.java_client.windows.WindowsDriver
Capabilities {app: C:\Windows\System32\notepad…, javascriptEnabled: true, platform: WINDOWS, platformName: WINDOWS}
Session ID: 2E1C55D8-C172-4272-B1B9-9B6DEC9BAD84
*** Element info: {Using=xpath, value=//Window/Pane[1]/Window[1]/Menu[1]/MenuItem[9]}
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
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.findElement(RemoteWebDriver.java:323)
at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62)
at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
at io.appium.java_client.windows.WindowsDriver.findElement(WindowsDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428)
at io.appium.java_client.DefaultGenericMobileDriver.findElementByXPath(DefaultGenericMobileDriver.java:152)
at io.appium.java_client.AppiumDriver.findElementByXPath(AppiumDriver.java:1)
at io.appium.java_client.windows.WindowsDriver.findElementByXPath(WindowsDriver.java:1)
at com.kms.katalon.core.windows.keyword.helper.WindowsActionHelper$1.apply(WindowsActionHelper.java:136)
at com.kms.katalon.core.windows.keyword.helper.WindowsActionHelper$1.apply(WindowsActionHelper.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
… 7 more

@david.fisher, after startApplicationWithTitle(), you would need to switch to the correct window using switchToWindowTitle() to detect the window you want to test with. You can check the keyword from this doc.

The example code will be like:

Windows.startApplicationWithTitle('C:\\Windows\\System32\\notepad.exe', 'Untitled - Notepad')
Windows.switchToWindowTitle('Untitled - Notepad') // Window title is "Untitled - Notepad"

If you want to take any action, you would need to make sure you switch to the correct title. Otherwise, it will fail.

1 Like