NoSuchElementException error after successfully performing operation

Dear community,

I’ve been having a not very good experience with desktop automation on RPA Express 2.2.2.
The script correctly executes an operation which is meant to confirm a message box window using Enter Keystroke, and then throws an error. I see the window vanishing as expected but then I get the error and not sure why, it doesn’t make sense to me.

image
image

Error executing KeyboardAction
com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=KeyboardAction.ftl,id=39,name=Optional[KeyboardAction],parent=38,arguments=ActionArguments[keyCode=[28],delay=[0],keyLocation=[4],xsi:type=[recorder:KeyboardAction, recorder:KeyboardAction],keyChar=[13],pollingInterval=[300],active=[true],actionDetails=[({ENTER})],text=[{ENTER}],rawCode=[10],awaitTimeout=[5000]]]
at com.workfusion.studio.rpa.recorder.playback.flow.StandardControlFlow.execute(StandardControlFlow.java:54)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:28)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:15)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:64)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:152)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.NoSuchElementException: Element “” doesn’t exist on the window ‘com.workfusion.autoit.driver.DesktopWindow@1914fa1b’.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘9.2.0.4’, revision: ‘1a10eeeced’, time: ‘2018-11-29T10:44:59.891Z’
System info: host: ‘wvd-cghq-0’, ip: ‘10.15.32.18’, os.name: ‘Windows NT (unknown)’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_121’
Driver info: driver.version: unknown
Command duration or timeout: 0 milliseconds
at sun.reflect.GeneratedConstructorAccessor160.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:41)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:82)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:741)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteKeyboard.sendKeys(RemoteKeyboard.java:38)
at com.workfusion.rpa.helpers.RobotsKeyboard.sendKeys(RobotsKeyboard.java:49)
at com.workfusion.rpa.helpers.RPA.sendKeys(RPA.java:282)
at com.workfusion.rpa.helpers.RPA$sendKeys$1.callStatic(Unknown Source)
at Script14$_run_closure1.doCall(Script14.groovy:9)
at Script14$_run_closure1.doCall(Script14.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:104)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:326)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
at groovy.lang.Closure.call(Closure.java:421)
at groovy.lang.Closure.call(Closure.java:415)
at com.workfusion.rpa.helpers.RPA.inDesktop(RPA.java:670)
at com.workfusion.rpa.helpers.RPA$inDesktop$0.callStatic(Unknown Source)
at Script14.run(Script14.groovy:8)
at com.workfusion.studio.rpa.recorder.playback.shell.GroovyShellWrapper.executeScript(GroovyShellWrapper.java:48)
at com.workfusion.studio.rpa.recorder.playback.player.PlaybackContext.executeScript(PlaybackContext.java:65)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.executeBehavior(TemplateAction.java:33)
at com.workfusion.studio.rpa.recorder.playback.flow.StandardControlFlow.execute(StandardControlFlow.java:46)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:28)
at com.workfusion.studio.rpa.recorder.playback.action.template.TemplateAction.execute(TemplateAction.java:15)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:64)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:152)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.openqa.selenium.NoSuchElementException: Element “” doesn’t exist on the window ‘com.workfusion.autoit.driver.DesktopWindow@1914fa1b’.
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘9.2.0.4’, revision: ‘1a10eeeced’, time: ‘2018-11-29T10:44:59.891Z’
System info: host: ‘wvd-cghq-0’, ip: ‘10.15.32.18’, os.name: ‘Windows NT (unknown)’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_121’
Driver info: driver.version: unknown
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘9.2.0.4’, revision: ‘1a10eeeced’, time: ‘2018-11-29T10:44:59.891Z’
System info: host: ‘wvd-cghq-0’, ip: ‘10.15.32.18’, os.name: ‘Windows NT (unknown)’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_121’
Driver info: driver.version: unknown
at com.workfusion.autoit.driver.KeyboardManager.throwExceptionIfNotExists(KeyboardManager.java:62)
at com.workfusion.autoit.driver.KeyboardManager.typeInActiveWindow(KeyboardManager.java:52)
at com.workfusion.autoit.driver.KeyboardManager.sendKeys(KeyboardManager.java:27)
at org.openqa.selenium.remote.server.handler.interactions.SendKeyToActiveElement.resolve(SendKeyToActiveElement.java:64)
at org.openqa.selenium.remote.server.handler.interactions.SendKeyToActiveElement.lambda$call$0(SendKeyToActiveElement.java:48)
at org.openqa.selenium.remote.server.handler.interactions.SendKeyToActiveElement.call(SendKeyToActiveElement.java:54)
at org.openqa.selenium.remote.server.handler.interactions.SendKeyToActiveElement.call(SendKeyToActiveElement.java:22)
at org.openqa.selenium.remote.server.handler.WebDriverHandler.handle(WebDriverHandler.java:41)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:133)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:205)
at org.openqa.selenium.remote.server.InMemorySession.execute(InMemorySession.java:98)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:231)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Appreciate any support.

Try adding a couple of seconds Wait before pressing Enter after switching to the window.

3 Likes

Thank you so much @ashapkina!! It looks like adding a 1000ms wait did the job.
Will perform some more tests throughout the day and if no issues, mark it as solution. :slight_smile:

2 Likes

When adding another Window action next to that one, it would throw again the same error. :slightly_frowning_face:
What I’ve done that worked even when integrating with the other steps was to use the exception handling to ignore that error with the keyboard. Actually now it does not throw any exception and it’s been running fine for multiple times.

image

1 Like

Thanks for the update @brunoazev is it a desktop or a web-based application in which this error happens?

It’s desktop.

This exception in Java is thrown when one tries to access an iterable beyond its maximum limit. This means that, this exception is thrown by various accessor methods to indicate that the element being requested does not exist . The solution to NoSuchElementException is to check whether the next position of an iterable is filled or empty . The following methods are used to check the next position:

hasNext()
hasMoreElements()