Use dynamic variable values in robotics-flow plugin
This instruction describes how you can troubleshoot the issue when the robot class code taken to a variable on top of the <robotics-flow> plugin cannot pick the dynamic variable value used in the plugin.
Sample business case
Assume you need to download PDF notices and save them in a shared drive location accounting for the policy numbers. This requires performing the following actions:
- You extract data (policy numbers, for example, A12344455, F3445666) from SQL and save it in a WorkFusion Data Store, which is then used in the web application to generate the PDFs.
- You run the loop on the web application to download the PDFs one by one and save them to the shared drive with their respective policy numbers.
However, an issue occurs when the user is not able to save the PDFs to the shared drive based on their policy numbers.
Required resolution: the user needs to get the robot code to access the <robotics-flow>/<selenium-flow> plugin, which should pick the dynamic variable value of the policy number.
As a result, you will be able to save all the PDFs, one by one, to the shared drive together with their policy number.
note
This is just one use case example. However, the dynamic variable values can be used in different parts of the same or another use case.
Testing results
Below, you can find testing results.
Version 1
Description: tested by implementing the robot code in <selenium-flow>.
Action: the pdf2 variable code commented and pasted to <selenium-flow>, starting from robot initialization to the end of the variable, above the executeScript function of the pdf2 variable.
Result: failure to pick the dynamic value, as expected.
Version 2
Description: tested by initializing the variable in <selenium-flow>.
Action: initialized the policynum variable into <selenium-flow> and tested.
Result: failure to pick the dynamic value, as expected.
Version 3
Description: tested by the initialized variable in the Script tag.
Action: initialized variable in the <script> tag on top of the <var-def> tag, which is working fine in Studio as well in Business Processes.
Result: this provides static results and, hence, fails to resolve the problem.
Version 4
Description: tested an overwriting variable with the sys.defined variable.
Action: tried an overwriting variable in <selenium-flow> with the sys.defineVariable method.
Result: this provides static results and, hence, fails to resolve the problem.
Resolution
The below workaround runs fine with the sample code:
<var-def name="pdf2">
//The %s will be replaced by formatter
String theString ="\\\\USBDYNAS01B.ACEINS.COM\\landata\\RA-NOC\\Output\\NOC\\NOC-PDF
NOTICE OF CANCELLATION %s.pdf";
</var-def>
<selenium-flow>
<selenium start-in-private="true" close-on-completion="false"
browser="internet explorer" name="seleniumDriver3">
<selenium start-in-private="true" close-on-completion="false"
browser="autoit" name="autoitDriver1">
<script><![CDATA[
//String theString ="\\\\USBDYNAS01B.ACEINS.COM\\landata\\RA-NOC\\Output\\NOC\\NOC-PDF
NOTICE OF CANCELLATION "PolicyNum".pdf";
import java.util.concurrent.TimeUnit;
import com.thoughtworks.selenium.*;
.....
aiDriver = autoitDriver1.getWrappedObject();
String PolicyNum = "BPTesting11"
//Replace fromatted string:
String scriptBody = String.format(pdf2.toString(), PolicyNum)
//Execute the script with adjusted file path:
aiDriver.executeScript(scriptBody, "GROOVY");