Custom action not working in code perspective

I have a very simple custom action script that works as a custom action in record perspective but when I try to run it in the code perspective I get an error (down below). This is new so simply trying to learn how to use the code perspective to code and debug scripts. If I take the call of customScript() out it will execute. If I want to see the value that was assigned to out_text how is that done?

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
    <robotics-flow>
        <robot driver="universal" close-on-completion="true" start-in-private="true">
            <capability name="SEARCH_ALL_WINDOWS" value="true" />
            <script><![CDATA[
                import com.workfusion.studio.rpa.recorder.api.internal.representation.*
                import com.workfusion.studio.rpa.recorder.api.*
                import com.workfusion.studio.rpa.recorder.api.types.*
                import com.workfusion.studio.rpa.recorder.api.custom.*
                import static com.workfusion.studio.rpa.recorder.api.RandomValues.CharacterSet.*
 
                enableTypeOnScreen()
  
                // defining recorder variables (needed only in Studio)
				in_text = "Hello World!"

  
// ========= Copy from here ===============================================
  
 @CustomScriptAction(
    input = ['in_text'],
    output = 'out_text'
)
 
def customScript() {
	out_text = in_text
}

customScript()
                  
// ========= Copy to here (and paste to Recorder Script action) ===========
  
            ]]></script>
        </robot>
    </robotics-flow>
    <export include-original-data="true"/>
</config>

Error message…

16:10:29 [INFO] RoboticsFlowPlugin starts processing...
16:10:30 [INFO]     SeleniumCapabilityPlugin starts processing...
16:10:30 [INFO]     SeleniumCapabilityPlugin processor executed in 1ms.
16:10:30 [INFO]     RobotPlugin starts processing...
16:10:30 [INFO]         SeleniumCapabilityPlugin starts processing...
16:10:30 [INFO]         SeleniumCapabilityPlugin processor executed in 0ms.
Aug 13, 2019 4:10:30 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
16:10:31 [INFO]         SeleniumCapabilityPlugin starts processing...
16:10:31 [INFO]         SeleniumCapabilityPlugin processor executed in 1ms.
16:10:31 [INFO]         ScriptProcessor starts processing...
16:10:37 [WARN] [urn:uuid:0857BE48BDCCAEA45315657306298053] robotics-flow plugin execution exception : org.webharvest.exception.ScriptException: 
Config line 6: script block
groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
org.webharvest.exception.PluginException: org.webharvest.exception.ScriptException: 
Config line 6: script block
groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
	at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RobotPlugin.executePlugin(RobotPlugin.java:185)
	at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
	at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
	at org.webharvest.runtime.processors.BodyProcessor.execute(BodyProcessor.java:27)
	at org.webharvest.runtime.processors.WebHarvestPlugin.executeBody(WebHarvestPlugin.java:246)
	at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RoboticsFlowPlugin.executePlugin(RoboticsFlowPlugin.java:110)
	at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
	at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
	at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
	at org.webharvest.runtime.Scraper.execute(Scraper.java:182)
	at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:173)
	at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.processTaskInputs(SingleThreadWebHarvestProcess.java:77)
	at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.start(SingleThreadWebHarvestProcess.java:46)
	at com.workfusion.studio.launch.WebHarvestMainLauncher.launch(WebHarvestMainLauncher.java:108)
	at com.workfusion.studio.launch.WebHarvestMainLauncher.main(WebHarvestMainLauncher.java:180)
Caused by: org.webharvest.exception.ScriptException: 
Config line 6: script block
groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
	at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:138)
	at org.webharvest.runtime.processors.ScriptProcessor.execute(ScriptProcessor.java:74)
	at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
	at org.webharvest.runtime.processors.BodyProcessor.execute(BodyProcessor.java:27)
	at org.webharvest.runtime.processors.WebHarvestPlugin.executeBody(WebHarvestPlugin.java:246)
	at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RobotPlugin.executePlugin(RobotPlugin.java:178)
	... 14 more
Caused by: groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:72)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:80)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:161)
	at Script1.run(Script1.groovy:30)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:444)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:482)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:453)
	at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:136)
	... 19 more
16:10:37 [ERROR] [urn:uuid:0857BE48BDCCAEA45315657306298053] robotics-flow executePlugin exception: [nodeId=http://127.0.0.1:15410] org.webharvest.exception.ScriptException: 
Config line 6: script block
groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
org.webharvest.exception.PluginException: [urn:uuid:0857BE48BDCCAEA45315657306298053] robotics-flow executePlugin exception: [nodeId=http://127.0.0.1:15410] org.webharvest.exception.ScriptException: 
Config line 6: script block
groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
	at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RoboticsFlowPlugin.executePlugin(RoboticsFlowPlugin.java:121)
	at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
	at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
	at org.webharvest.runtime.Scraper.execute(Scraper.java:169)
	at org.webharvest.runtime.Scraper.execute(Scraper.java:182)
	at com.freedomoss.crowdcontrol.webharvest.executor.LocalWebharvestTaskExecutor.executeWebHarvestTask(LocalWebharvestTaskExecutor.java:173)
	at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.processTaskInputs(SingleThreadWebHarvestProcess.java:77)
	at com.workfusion.studio.launch.SingleThreadWebHarvestProcess.start(SingleThreadWebHarvestProcess.java:46)
	at com.workfusion.studio.launch.WebHarvestMainLauncher.launch(WebHarvestMainLauncher.java:108)
	at com.workfusion.studio.launch.WebHarvestMainLauncher.main(WebHarvestMainLauncher.java:180)
Caused by: org.webharvest.exception.PluginException: org.webharvest.exception.ScriptException: 
Config line 6: script block
groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
	at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RobotPlugin.executePlugin(RobotPlugin.java:185)
	at org.webharvest.runtime.processors.WebHarvestPlugin.execute(WebHarvestPlugin.java:125)
	at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
	at org.webharvest.runtime.processors.BodyProcessor.execute(BodyProcessor.java:27)
	at org.webharvest.runtime.processors.WebHarvestPlugin.executeBody(WebHarvestPlugin.java:246)
	at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RoboticsFlowPlugin.executePlugin(RoboticsFlowPlugin.java:110)
	... 9 more
Caused by: org.webharvest.exception.ScriptException: 
Config line 6: script block
groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
	at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:138)
	at org.webharvest.runtime.processors.ScriptProcessor.execute(ScriptProcessor.java:74)
	at org.webharvest.runtime.processors.BaseProcessor.run(BaseProcessor.java:127)
	at org.webharvest.runtime.processors.BodyProcessor.execute(BodyProcessor.java:27)
	at org.webharvest.runtime.processors.WebHarvestPlugin.executeBody(WebHarvestPlugin.java:246)
	at com.freedomoss.crowdcontrol.webharvest.plugin.selenium.RobotPlugin.executePlugin(RobotPlugin.java:178)
	... 14 more
Caused by: groovy.lang.MissingMethodException: No signature of method: Script1.customScript() is applicable for argument types: () values: []
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:72)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:80)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:161)
	at Script1.run(Script1.groovy:30)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:444)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:482)
	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:453)
	at org.webharvest.runtime.scripting.GroovyScriptEngine.eval(GroovyScriptEngine.java:136)
	... 19 more
16:10:37 [INFO] -------------------------------------------
16:10:37 [INFO] EXECUTION FAILED
16:10:37 [INFO] No signature of method: Script1.customScript() is applicable for argument types: () values: []
16:10:37 [INFO] (test.xml:30)
16:10:37 [INFO] -------------------------------------------

Hi, Craig.

The CustomScriptAction syntax is compiled differently from the script block in which you’ve pasted it, as it is intended for use in the recorder perspective. However, you should be able to call it with a call to

customScripActionCall_customScript: {}

in place of your call to customScript().

If that doesn’t work, you have two other options to debug your Custom Action:

  1. Extract the body of the customScript() method and paste it directly into the script block, allowing you direct access to out_text, which would normally be the output variable. Remove all other syntax specific to Custom Actions.

  2. While there’s no support for interactive debugging with recorder, you can perform application-based text debugging. You can open a notepad instance with Enter Keystrokes actions (On Windows: Ctrl-r, “notepad”, Enter), then do a Text from Variable variant of Enter Keystrokes where out_text is the variable to output.

I hope this helps!

2 Likes

Thanks Sean! The customScriptActionCall_customScript: {} was the missing link. I figured it was something simple as it was.

Just to let you know - at this link https://kb.workfusion.com/display/RPAe/Script+as+Custom+Action this is what led me down the path I first took. Not sure if I was mis-interpreting this or if this is outdated.

Once again thanks for getting me moving forward again!

Glad to help! Thank you for bringing that kb link to my attention; I’ve edited it. It may have been correct in a previous version.

Just to clarify, I noticed you corrected “Scrip” to “Script” in your reply. Which one worked correctly? I was under the impression the misspelled version was the correct method signature.

1 Like

Sorry about the edit as I didn’t realized I did that.

This is what I am using (which was a copy / paste from your post).

customScripActionCall_customScript: {}

So it is Scrip and not Script.

2 Likes