I am recording a script using truclient protocol.In my script ,i need to externally call an API which generates the Password. The password is fetched using the co-relation,which is used as an input for Login. I am however unable to call the external API using the true client protocol. Could anybody please suggest how to call an external API in true client protocol.
-
if its REST call, you just have to provide API url in "generic browser action" function and supporting headers can be configured using Evaluate Javacript "Utils.addAutoHeader". This will help to call the API. Although i am not pretty sure about how can we correlate, because TruClient is purely on presentation layer, i doubt it would recognize API custom text. Atlease one way for manually correlate is using "verify" function and changing action from "verify" to "getProperty" and select the visible text. Provide variable name for saving the extracted value to. – Vishal Chepuri Sep 16 '20 at 11:27
1 Answers
Have you tried the evaluate JavaScript step? You can post the message to the server and get the generated password during the runtime. XHR and fetch API should be supported in Chrome and Firefox, TCIE should support XHR.
Sure. Please check the detail steps:
Drag and drop an evaluate JS step from TruClient
Open the script editor
Add these code, make sure use the sync XHR to ensure the password is returned before the end step started:
var xhr = new XMLHttpRequest(); xhr.open("POST", '/server', false);
//Send the proper header information along with the request xhr.setRequestHeader("xxx", "value"); xhr.send();
if (this.status === 200) { // Request finished. Do processing here. } var password = xhr.response;
Change the login password step from plain text to JS and use
ArgsContext.password
to reference the previous received password.
If you have another questions please let me know. How to use the argument context you could reference this link.
BTW. the window and document object of the page can be referenced with AUT.window, AUT.document in TruClient.
Please check the help document from here.

- 1,786
- 4
- 19
- 33
-
-
@Vishal the answer is updated. It there is any other issues please let me know. Thank you. – Erxin Sep 23 '20 at 06:34