I'm not too savvy with TruClient yet, and what I am needing is an IF ELSE statement. I see the IF Block in the toolbox, and dragged it into my script - and that's as far as I've got!
What I need to do is:
IF 'perfTest' field IS VISIBLE
GoTo STEP [Populate 'perfTest']
SELECT 'Add Task' btn
If that makes sense! Essentially, sometimes a user will reach a page where a field to enter data already displays, in which case the data is just entered; otherwise the field isn't displayed and the user has to click an 'add' button to get it to display before proceeding to populate it.
Thanks in advance!
LOL, okay, let's try.
First, drag over an "If Exists" item from the toolbox. Then choose an object for it. Choose the object that may or may not exist.
But you probably don't want it to wait the default full 20s. So for that step, change the Object Timeout value from 20s to say 5s.
Then record or paste into that step, the steps you want to have happen if the object is found.
There should also be an "Add Else" link in there. Click on that and the Else clause is created. Paste or record the 'Else' steps into that block.
To copy steps, you need to:
- Select the relevant steps
You can do this either by dragging the mouse around the steps or click the first step, hold SHIFT and click on the last step.
Either from the right-click context menu or CTRL+C
- Past the steps
Right-click anywhere in the IF step and in the context menu select Paste > Paste Into
You can also drag the selected steps into the IF step, to move them.
Alternatively, select the steps, right click and select Group Into > If Clause.
In the IF step condition, you can input the boolean logic. Use the TC.getParam API to acquire a parameter value.