Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..
4106 views

TruClient Web - IF Block example needed

Jump to solution

Hello

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

THEN

GoTo STEP [Populate 'perfTest']

ELSE

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!

0 Likes
1 Solution

Accepted Solutions
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Is this the kind of thing you have in mind?

tc.png

View solution in original post

7 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Is this the kind of thing you have in mind?

tc.png

View solution in original post

Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

That is exactly it! I just can't see how that was built out

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

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.

0 Likes
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Doh! Got it, thanks very much, just needed that little nudge!

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Very welcome.  🙂

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Can you explain how to paste a step into the if block?  What I want to do is execute if block steps based on a defined parameter value.

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

To copy steps, you need to:

  1. 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.
  2. Copy
    Either from the right-click context menu or CTRL+C
  3. 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.

 

Edo

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.