How to switch between window by Handle Id

Hi
I have two questions:

  1. I have 1 to 5 windows open, so is there any way to switch between these windows by using handle id or if you could suggest the preferred way to switch between the windows?
  2. I am trying to get handle id using the custom script and storing it in output variable but getting this error.

Error executing CustomScriptAction
com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=CustomScriptAction.ftl,id=63,name=Optional[CustomScriptAction],parent=61,nextSibling=64,arguments=ActionArguments[delay=[0],timeoutMs=[10000],xsi:type=[recorder:CustomScriptAction, recorder:CustomScriptAction],name=[Switch to next window],pollingInterval=[300],active=[true],script=[@CustomScriptAction(
output = ‘strhandle’
)
def CustomScript(){
def allHandles = driver().getWindowHandle()
strhandle =RString.Of(allHandles.toString());

}
],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:81)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:154)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)
Caused by: groovy.lang.MissingMethodException: No signature of method: static com.workfusion.studio.rpa.recorder.api.types.RString.Of() is applicable for argument types: (String) values: [CDwindow-F27DC71B57144335E4E41360B0521491]
Possible solutions: of(java.lang.CharSequence), is(java.lang.Object), md5(), any(), tap(groovy.lang.Closure), use([Ljava.lang.Object;)
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1528)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1514)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at CustomScript_CustomScript.CustomScript(Script5.groovy:14)
at CustomScript_CustomScript$CustomScript.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at Script5.run(Script5.groovy)
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:108)
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:81)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.playNextAction(PlaybackLogic.java:154)
at com.workfusion.studio.rpa.recorder.player.PlaybackLogic.run(PlaybackLogic.java:112)
at java.lang.Thread.run(Thread.java:745)

Hi @aashu.singh.

Why do you need custom script? You can switch between windows using their names or Object selectors.

Hi Lera,

I am doing this just because i am using open browser activity and all tabs are inside that activity but i am not able to put window activity inside open browser activity.

Is it the requirement to have all browser windows opening? If you need some information from another web browser window, you can save it in the Recorder variables or in file, then open new browser window and enter it by XPath, for example. Can you please describe your task that you need to resolve?

There are three website web1 ,web2 and web3,what i am doing i am cross checking the information between these website,if there is any mismatch then i have to update some information on web1 from web3.

Is it possible to store all required information in variables like List or Table? Then you can read information from the website 2 and compare with stored data. Will this work for you?

Hi Lera,

This solution will not work just because process will become very slow as i have more than 500 record to process,is there any issue with custom script, will custom script work in control tower?.

Hi @aashu.singh.

You can use your custom script, I’m just trying to understand why you want to use it, if another solution exists.
As about exception, I didn’t reproduce it, but it seems like you made a mistake in script. I assume that you need to use driver().getWindowHandles(), not getWindowHandle().

@aashu.singh use Constant value action to get the handle

1 Like