Error in web automation (get data)

Hello.

I was following the tutorial on getting data from a website (https://www.youtube.com/watch?v=h2kqMrGv5kk) and I couldn’t get the part where I need to save it in a variable. How can I get it work?

Here’s the error message that I’ve got:
Error executing WebElementAction

com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=WebElementAction.ftl,id=6,name=Optional[WebElementAction],parent=3,arguments=ActionArguments[varName=[def],delay=[5000],exactMatch=[true],useElementAttribute=[false],timeoutMs=[10000],webElementLocatorType=[XPATH],xsi:type=[recorder:WebElementAction, recorder:WebElementAction],pollingInterval=[300],active=[true],searchInFrames=[false],webElementLocator=[//[@id=“zci-stocks”]/div/div/div/div[2]/span[1]],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: com.google.common.util.concurrent.UncheckedExecutionException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script5.groovy: 10: unexpected token: def @ line 10, column 13.
def = RString.of($(byXpath("//
[@id=“zci-stocks”]/div/div/div/div[2]/span[1]")).text())
^

1 error

  at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2199)
  at com.google.common.cache.LocalCache.get(LocalCache.java:3932)
  at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3936)
  at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4806)
  at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4812)
  at com.workfusion.studio.rpa.recorder.playback.shell.compiler.EnabledGroovyScriptCache.compile(EnabledGroovyScriptCache.java:30)
  at com.workfusion.studio.rpa.recorder.playback.shell.GroovyShellWrapper.executeScript(GroovyShellWrapper.java:44)
  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)

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script5.groovy: 10: unexpected token: def @ line 10, column 13.
def = RString.of($(byXpath("//*[@id=“zci-stocks”]/div/div/div/div[2]/span[1]")).text())
^

1 error

  at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:311)
  at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:151)
  at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:121)
  at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:133)
  at org.codehaus.groovy.control.SourceUnit.addError(SourceUnit.java:332)
  at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:226)
  at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:192)
  at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:230)
  at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:186)
  at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:968)
  at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
  at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:609)
  at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:586)
  at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:354)
  at groovy.lang.GroovyClassLoader.access$300(GroovyClassLoader.java:87)
  at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:323)
  at groovy.lang.GroovyClassLoader$5.provide(GroovyClassLoader.java:320)
  at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:147)
  at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:318)
  at groovy.lang.GroovyShell.parseClass(GroovyShell.java:547)
  at groovy.lang.GroovyShell.parse(GroovyShell.java:559)
  at groovy.lang.GroovyShell.parse(GroovyShell.java:595)
  at groovy.lang.GroovyShell.parse(GroovyShell.java:586)
  at com.workfusion.studio.rpa.recorder.playback.shell.compiler.GroovyShellCompiler.compile(GroovyShellCompiler.java:37)
  at com.workfusion.studio.rpa.recorder.playback.shell.compiler.EnabledGroovyScriptCache$1.load(EnabledGroovyScriptCache.java:22)
  at com.workfusion.studio.rpa.recorder.playback.shell.compiler.EnabledGroovyScriptCache$1.load(EnabledGroovyScriptCache.java:18)
  at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3522)
  at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2315)
  at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2278)
  at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2193)
  at com.google.common.cache.LocalCache.get(LocalCache.java:3932)
  at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3936)
  at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4806)
  at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4812)
  at com.workfusion.studio.rpa.recorder.playback.shell.compiler.EnabledGroovyScriptCache.compile(EnabledGroovyScriptCache.java:30)
  at com.workfusion.studio.rpa.recorder.playback.shell.GroovyShellWrapper.executeScript(GroovyShellWrapper.java:44)
  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)

@mdion can you share your recording on the screenshot of the Web element action that you use?

Untitled-12.zip (93.6 KB)

@mdion the issue id cause by the name of the variable - def. You cannot use it as a variable name. You can see the list of such words in the Knowledge Base: https://kb.workfusion.com/display/RPAe/Recorder+Variables#RecorderVariables-ListofReservedWords

Got it! Thanks, ashapkina, I got it working. However, it doesn’t work again when I tried it applying it to our website.

This exercise needs to get the value of “Loan Type” and save it to variable a_loantype.

Here’s the error message that I’ve got:

Error executing WebElementAction
com.workfusion.studio.rpa.recorder.playback.PlaybackException: Error executing TemplateAction[templateName=WebElementAction.ftl,id=9,name=Optional[WebElementAction],parent=1,nextSibling=10,arguments=ActionArguments[varName=[a_loantype],elementAttribute=[],exactMatch=[true],xsi:type=[recorder:WebElementAction, recorder:WebElementAction],pollingInterval=[300],active=[true],searchInFrames=[false],delay=[100000],useElementAttribute=[false],timeoutMs=[10000],webElementLocatorType=[XPATH],webElementLocator=[//[@id=“form[Form_LoanType]”]],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: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“xpath”,“selector”:"//
[@id=“form[Form_LoanType]”]"}
(Session info: chrome=79.0.3945.130)
(Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘9.4.0.3’, revision: ‘abf2ebe0f1’, time: ‘2019-05-29T13:21:06.482Z’
System info: host: ‘LT18-L1-622’, ip: ‘10.20.187.199’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_121’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{mobileEmulationEnabled=false, hasTouchScreen=false, platform=XP, acceptSslCerts=false, goog:chromeOptions={debuggerAddress=localhost:55775}, acceptInsecureCerts=false, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, platformName=XP, setWindowRect=true, unexpectedAlertBehaviour=ignore, applicationCacheEnabled=false, rotatable=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90), userDataDir=C:\Users\con28\AppData\Local\Temp\scoped_dir11112_13522}, takesHeapSnapshot=true, unhandledPromptBehavior=ignore, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, version=79.0.3945.130, browserConnectionEnabled=false, nativeEvents=true, locationContextEnabled=true, cssSelectorsEnabled=true}]
Session ID: 40210431537d7968f828bfc48e382ac8
*** Element info: {Using=xpath, value=//[@id=“form[Form_LoanType]”]}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
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.RemoteWebDriver.findElement(RemoteWebDriver.java:446)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:548)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:438)
at com.workfusion.rpa.helpers.RPA.getElement(RPA.java:944)
at com.workfusion.rpa.helpers.RPA.$(RPA.java:864)
at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
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 org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:151)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.callStatic(StaticMetaMethodSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:55)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:197)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:209)
at Script10.run(Script10.groovy:10)
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)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:“xpath”,“selector”:"//
[@id=“form[Form_LoanType]”]"}
(Session info: chrome=79.0.3945.130)
(Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘9.4.0.3’, revision: ‘abf2ebe0f1’, time: ‘2019-05-29T13:21:06.482Z’
System info: host: ‘LT18-L1-622’, ip: ‘10.20.187.199’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_121’
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{mobileEmulationEnabled=false, hasTouchScreen=false, platform=XP, acceptSslCerts=false, goog:chromeOptions={debuggerAddress=localhost:55775}, acceptInsecureCerts=false, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, platformName=XP, setWindowRect=true, unexpectedAlertBehaviour=ignore, applicationCacheEnabled=false, rotatable=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90), userDataDir=C:\Users\con28\AppData\Local\Temp\scoped_dir11112_13522}, takesHeapSnapshot=true, unhandledPromptBehavior=ignore, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, version=79.0.3945.130, browserConnectionEnabled=false, nativeEvents=true, locationContextEnabled=true, cssSelectorsEnabled=true}]
Session ID: 40210431537d7968f828bfc48e382ac8
*** Element info: {Using=xpath, value=//*[@id=“form[Form_LoanType]”]}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘9.4.0.4’, revision: ‘1fbe520b9b’, time: ‘2019-06-20T13:08:57.971Z’
System info: host: ‘LT18-L1-622’, ip: ‘10.20.187.199’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_121’
Driver info: driver.version: UniversalDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
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.server.ActiveSessionCommandExecutor.execute(ActiveSessionCommandExecutor.java:43)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:741)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:446)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:548)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:438)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.openqa.selenium.remote.Augmenter$CompoundHandler.intercept(Augmenter.java:189)
at org.openqa.selenium.remote.RemoteWebDriver$$EnhancerByCGLIB$$962721c6.findElement()
at com.workfusion.universal.driver.UniversalDriver.findElement(UniversalDriver.java:80)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:48)
at org.openqa.selenium.remote.server.handler.FindElement.call(FindElement.java:33)
at org.openqa.selenium.remote.server.handler.WebDriverHandler.handle(WebDriverHandler.java:41)
at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:134)
at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:206)
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)