Wait for image - checking outcome. How does it work?


#1

Hi
I am experimenting with a small script. There is a Wait For Image action, and I want to check for the outcome with an If-Else action. For some reason I don’t understand, I always end up in the Else part. Please advice.

<?xml version="1.0" encoding="UTF-8"?>
<recorder:ActionFlow xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:recorder="http://www.workfusion.com/recorder/v1.1.1" ignoreDelays="false">
  <actions xsi:type="recorder:OpenURLAction" active="true" actionDetails="(https://www.oslobors.no)" delay="0" url="https://www.oslobors.no" waitTimeout="5000"/>
  <actions xsi:type="recorder:WaitForImageAction" active="true" actionDetails="(2000 ms)" delay="0" imageName="1496239462161-anchor.apng" fullImageName="1496239462150.png" varType="java.lang.Boolean" waitTimeout="2000"/>
  <actions xsi:type="recorder:MouseClickAction" active="true" actionDetails="(click left button)" delay="0" imageName="1496239507426-anchor.apng" fullImageName="1496239507414.png" button="1"/>
  <actions xsi:type="recorder:KeyboardAction" active="true" actionDetails="(from variable 'selskap')" delay="0" paramString="" varName="selskap" varType="java.lang.String" text="" type="TEXT_FROM_VAR"/>
  <actions xsi:type="recorder:KeyboardAction" active="true" actionDetails="({ENTER})" delay="0" paramString="NATIVE_KEY_PRESSED,keyCode=28,keyText=Enter,keyChar=Undefined,keyLocation=KEY_LOCATION_STANDARD,rawCode=13" text="{ENTER}" rawCode="10" keyCode="28" keyChar="65535" keyLocation="1"/>
  <actions xsi:type="recorder:WaitForImageAction" active="true" actionDetails="(5000 ms)" delay="0" imageName="1496385788793-anchor.apng" fullImageName="1496385788768.png" varName="rc" varType="java.lang.Boolean" waitTimeout="5000"/>
  <actions xsi:type="recorder:IfElseAction" active="true" actionDetails="(&quot;rc&quot; = &quot;true&quot;)" delay="100" leftOperand="rc" rightOperand="true">
    <ifBlock active="true">
      <actions xsi:type="recorder:OpenURLAction" active="true" actionDetails="(http://vg.no)" delay="0" url="http://vg.no"/>
    </ifBlock>
    <elseBlock active="true">
      <actions xsi:type="recorder:OpenURLAction" active="true" actionDetails="(http://knowit.no)" delay="0" url="http://knowit.no"/>
    </elseBlock>
  </actions>
  <actions xsi:type="recorder:WaitAction" active="true" actionDetails="for 5000 ms" delay="5000"/>
</recorder:ActionFlow>

#2

@bjorn.kvisli - are you putting the result of Wait For Image to the rc variable?


#3

Yes I do


#4

So it means that robot cannot find the image you’ve provided on the current screen. You can increase the wait time or redo the screenshot.


#5

It can’t be that, because if I change the if to rc=false I also go to the Else part.

rc=false and rc=true both take me to Else.


#6

Hi @bjorn.kvisli

What version of RPA Express do you have?
If you still have the installation file you can find version text file next for installer. Otherwise you can check in recorder about menu.
I think I had something similar in the prior versions.
Please note that the latest one is 1.1.1 https://kb.workfusion.com/display/RPAe/Sunbird+1.1.1


#7

Hi

build=189
version_number=1.1.1
version=Sunbird
timestamp=Tue 05/30/2017 13:22:55.45


#8

Does a simple case with pre-defined boolean variable work in your Recorder?

var a = true
if (a == true)
  do this
else
  do that

#9

This script goes to Else:

// UTILS CODE SECTION START
enableTypeOnScreen();
// UTILS CODE SECTION END
openAndFocus(“notepad”, 0, 0);
a = true;
if (“a”.equals(“true”)) {
sendKeys(“then”);
} else {
sendKeys("else ");
}
sleep(5000);

<?xml version="1.0" encoding="UTF-8"?>
<recorder:ActionFlow xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:recorder="http://www.workfusion.com/recorder/v1.1.1" ignoreDelays="false">
  <actions xsi:type="recorder:LaunchAppAction" active="true" actionDetails="(notepad; wait for 0ms; poll every 0ms)" delay="0" command="notepad" autoDetectWindow="true"/>
  <actions xsi:type="recorder:ConstantValueAction" active="true" actionDetails="(to 'a' = true) - Boolean" delay="0" varName="a" varType="java.lang.Boolean" stringValue="" numberValue="0" booleanValue="true" dateTimeValue="1496992937811" useCurrentDate="false" listValue="rO0ABXNyADRjb20ud29ya2Z1c2lvbi5zdHVkaW8ucnBhLnJlY29yZGVyLm1vZGVsLkxpc3RXcmFwcGVyYmOLQVEsNagCAAFMAAZ2YWx1ZXN0ABBMamF2YS91dGlsL0xpc3Q7eHBzcgATamF2YS51dGlsLkFycmF5TGlzdHiB0h2Zx2GdAwABSQAEc2l6ZXhwAAAAAHcEAAAAAHg=" tableValue="rO0ABXNyADVjb20ud29ya2Z1c2lvbi5zdHVkaW8ucnBhLnJlY29yZGVyLm1vZGVsLlRhYmxlV3JhcHBlckALw5JBABS+AgABTAAEcm93c3QAEExqYXZhL3V0aWwvTGlzdDt4cHNyABNqYXZhLnV0aWwuQXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAAAdwQAAAAAeA=="/>
  <actions xsi:type="recorder:IfElseAction" active="true" actionDetails="(&quot;a&quot; = &quot;true&quot;)" delay="0" leftOperand="a" rightOperand="true">
    <ifBlock active="true">
      <actions xsi:type="recorder:KeyboardAction" active="true" actionDetails="(typed text)" delay="0" paramString="" text="then" type="KEY_TYPE"/>
    </ifBlock>
    <elseBlock active="true">
      <actions xsi:type="recorder:KeyboardAction" active="true" actionDetails="(typed text)" delay="0" paramString="" text="else  " type="KEY_TYPE"/>
    </elseBlock>
  </actions>
  <actions xsi:type="recorder:WaitAction" active="true" actionDetails="for 5000 ms" delay="5000"/>
</recorder:ActionFlow>

#10

Hello,
please use variable placeholder instead of text value of variable name
you can input ${a} at the left side of the expression

or select variable from dropdown, than ${a} will set automatically

Best regards,
Anton


#11

Thans, that worked