Highlighted
Respected Contributor.
Respected Contributor.
2176 views

TruClient Verify Object dynamically

Hi,

I'm testing a site where either you end up on a page with the text "Analysis Done" or you end up on a page with the text "We're finished".

Either page is OK to receive and should result in the transaction to end OK.

How can I create a "Wait for object" or anything to make sure any of these texts are visible?

 

Something like a regex check "/ (Done) | (finished) /" maybe, but I can't figure out how to include regex in a Wait for object.

Protocol TruCLient Firefox
VuGen v.12.1

Advice please 🙂

/Fredrik

0 Likes
4 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: TruClient Verify Object dynamically

I haven't tried this, but can you, in a loop ...

grab all of the text, then programatically check if either string exists? Then break out of the loop when either is found?

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: TruClient Verify Object dynamically

Hi,

You need to change the Object Identification method ("ID Method") of the Wait for Object step from Automatic to JavaScript and write the regex in the JavaScript editor. You can find reference for JavaScript RegExp here: http://www.w3schools.com/jsref/jsref_obj_regexp.asp

Regards,

Shlomi

 

Highlighted
Respected Contributor.
Respected Contributor.

Re: TruClient Verify Object dynamically

Thank you for your answer Shlomi.

I usually change from Automatic to Javascript since the Automatic mostly get it wrong in TruClient scripts.

When changing to ID method JavaScript it gives an example code:
evalXPath("//div[text()]=\"Analysis Done\"]");

A regex that would capture both woult look like this: /(Done) | (finished)/

I don't get the syntax used in TrueClient. How should I incorperate the regex /(Done) | (finished)/ in the JavaScript: evalXPath("//div[text()]=\"Analysis Done\"]");

I can't get it to work. Can you give me an example on how to include Regex in the JavaScript?

Thanks

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: TruClient Verify Object dynamically

There is another way get what you want.

You can add two event handlers.

Select type as object in General section. In Object section choose the text element as the object for each handler.

Select Object Exists in Event section. Finally select the function which has an Eval JavaScript step with the code LR.endTransaction()

0 Likes
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.