Script unable to open File explorer and navigate to selected folder

I recorded a script to Open Windows File explorer, navigate to a drive, open a excel file, copy the contents and paste them in a web page on google chrome. When I run the script in RPA Express, it fails at the first step itself and is unable to proceed further. I’m getting the below error:

Error executing SwitchWindowAction
com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=SwitchWindowAction.ftl,id=3,name=Optional[SwitchWindowAction],parent=-1,nextSibling=9,children=[4, 8],arguments=ActionArguments[modeType=[SELECTED],delay=[0],timeoutMs=[10000],xsi:type=[recorder:SwitchWindowAction, recorder:SwitchWindowAction],pollingInterval=[300],active=[true],actionDetails=[],title=[File Explorer],clazz=[CabinetWClass],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:53)
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.NoSuchWindowException: Window ‘[CLASS:CabinetWClass;TITLE:File Explorer]’ is not found

Hi @sreedhar_neeli
For this task I would recommend using the excel actions in RPA. They are much faster and more reliable than navigating though file explorer and opening Excel in foreground.

1 Like

@sreedhar_neeli for the use case you described it is much better to use excel actions as @timriewe suggested.

But regarding the error you get: it seems that File Explorer is not opened when the bot tries to switch to it, so you need to add actions at the start to open it.

Thanks for the innsights. I’ll try adding another action to open File Explorer.

I also tried adding a direct action to Open the excel file from the path later. However it is throwing a ClassNotFound exception (probably the class responsible for opening the excel file) when I Play the script.

@sreedhar_neeli using Excel actions should work in this case. Could you share your script?

Hi @ashapkina,

This is the error I’m getting while trying to use the Open excel action:

Error executing OpenSpreadsheetAction
com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing OpenSpreadsheetAction[id=1,name=Optional[OpenSpreadsheetAction],parent=-1,nextSibling=2,arguments=ActionArguments[delay=[0],filePath=[E:\My_Details_111916.xlsx],xsi:type=[recorder:OpenSpreadsheetAction, recorder:OpenSpreadsheetAction],pollingInterval=[300],active=[true],actionDetails=[(“E:\My_Details_111916.xlsx”)],awaitTimeout=[5000]]]
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.tryExecuteScript(OpenSpreadsheetAction.java:108)
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.execute(OpenSpreadsheetAction.java:71)
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.execute(OpenSpreadsheetAction.java:16)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:53)
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.WebDriverException: java.lang.ClassNotFoundException: org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException cannot be found by com.workfusion.studio.dependencies.rpa-api_9.0.0.4
Build info: version: ‘9.0.0.4’, revision: ‘e6e278acd9’, time: ‘2018-06-19T14:40:11.651Z’
System info: host: ‘DESKTOP-YRS’, ip: ‘192.138.52.1’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_121’
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.internal.CustomWrapper.isCustomWrapperElement(CustomWrapper.java:44)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:218)
at org.openqa.selenium.remote.JsonToBeanConverter.convertMap(JsonToBeanConverter.java:351)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:228)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:48)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:149)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:48)
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:656)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:592)
at com.workfusion.rpa.helpers.RPA.executeScript(RPA.java:864)
at com.workfusion.rpa.helpers.RPA.executeGroovyScript(RPA.java:930)
at com.workfusion.rpa.helpers.Excel.openExcel(Excel.java:32)
at com.workfusion.rpa.helpers.Excel$openExcel.callStatic(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:206)
at Script2.run(Script2.groovy:1)
at com.workfusion.studio.rpa.recorder.playback.shell.GroovyShellWrapper.executeScript(GroovyShellWrapper.java:90)
at com.workfusion.studio.rpa.recorder.playback.player.PlaybackContext.executeScript(PlaybackContext.java:65)
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.tryExecuteScript(OpenSpreadsheetAction.java:99)
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.execute(OpenSpreadsheetAction.java:71)
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.execute(OpenSpreadsheetAction.java:16)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:53)
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: java.lang.ClassNotFoundException: org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException cannot be found by com.workfusion.studio.dependencies.rpa-api_9.0.0.4
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.openqa.selenium.remote.internal.CustomWrapper.isCustomWrapperElement(CustomWrapper.java:42)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:218)
at org.openqa.selenium.remote.JsonToBeanConverter.convertMap(JsonToBeanConverter.java:351)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:228)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:48)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:149)
at org.openqa.selenium.remote.JsonToBeanConverter.convert(JsonToBeanConverter.java:48)
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:656)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:592)
at com.workfusion.rpa.helpers.RPA.executeScript(RPA.java:864)
at com.workfusion.rpa.helpers.RPA.executeGroovyScript(RPA.java:930)
at com.workfusion.rpa.helpers.Excel.openExcel(Excel.java:32)
at com.workfusion.rpa.helpers.Excel$openExcel.callStatic(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:206)
at Script2.run(Script2.groovy:1)
at com.workfusion.studio.rpa.recorder.playback.shell.GroovyShellWrapper.executeScript(GroovyShellWrapper.java:90)
at com.workfusion.studio.rpa.recorder.playback.player.PlaybackContext.executeScript(PlaybackContext.java:65)
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.tryExecuteScript(OpenSpreadsheetAction.java:99)
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.execute(OpenSpreadsheetAction.java:71)
at com.workfusion.studio.rpa.recorder.playback.action.OpenSpreadsheetAction.execute(OpenSpreadsheetAction.java:16)
at com.workfusion.studio.rpa.recorder.playback.player.ActionPlayer.next(ActionPlayer.java:53)
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)

Is the spreadsheet you want to open already open in the background? If so you need to close it before running the process.

1 Like

@sreedhar_neeli it is also possible that the file you are trying to open is of an unsupported format. Could you please share it and we’ll have a look?

The file is not already open when I run the script

It is a .xlsx file I’m trying to open. I cannot share the file as it contains some sensitive information and also is password protected. In the scripting I have entered the password to open the file. But the process is failing while opening the file itself.

@sreedhar_neeli do you have any OLE objects in the file, like embedded documents, charts, etc.?

No. Its a simple excel file with some data. There are no embedded images, special characters or macros in it.

It is hard to tell without seeing the file. Can you replace sensitive information with some test data and share the file to have a look?

Are you still trying to use OpenSpreadsheetAction? With the password protected file I don’t think it would work.

1 Like

@timriewe yes, you’re absolutely right!

I have completely missed that in the post :confounded:
You cannot use Excel actions with password-protected files.

Yes. Can’t the OpenSpreadsheetAction open a password protected file? In my next action I’m giving the password to open the file

1 Like

It will not work. Either remove the password protecion from the file or go back to your initial attempt and use mouse clicks and keystrokes to open and process the Excel file in foreground.

1 Like