Highlighted
Absent Member.. Absent Member..
Absent Member..
912 views

Writing a captured value into notepad file for Ajax Tru client protocol

Hi,

 

I have recorded script in ajax tru client protocol. In my script I have captured a value from the application screen using Evaluate JS on Object(from toolbox) into a variable.

 

Now I want the variable value to be written into a notepad. on each iteration the new values of the variable gets written to the notepad one below the other.

 

I tried using the following code IO.write("C:\Users\Testera01\Desktop\New folder\b.txt",ProblemId,true,"UTF-8"); where the 1st parameter is the path(b.txt is the notepad),Problem Id is the variable.

 

Please provide sample code for the above problem.

 

Regards

JayKishan Saha

0 Likes
4 Replies
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

It should work, but make sure you escape the backslashes in the absolute path:

 

IO.write("C:\\Users\\Testera01\\Desktop\\New folder\\b.txt",ProblemId,true,"UTF-8");

Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Hi,

 

The line of code you wrote seems to be OK on its; own. The only possible issue is whether ProblemId is a string or a different data type (e.g. Object, Array)

 

Can you share the code or script so we can see the evaluate JS on object? This will help understand it better

 

Thanks,

Shlomi 

 

0 Likes
Highlighted
Regular Contributor.
Regular Contributor.

Hi ,

 

Any idea how to capture multiple variables in the same io.write function ?

 

IO.write("C:\\Users\\ASarraf\\Documents\\VuGen\\Scripts\\Warrant-TC\\Warrant_Batch.txt",BatchID, ItemNumber , RunDate , true,"UTF-8");

 

when I use this I am gettinh error as  BatchID , ItemNumber  , RunDate  these all are variables and I want all these to be written in one file .

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

@sarrafanmolsa96  The API of IO.Write states that the second argument should be a string.

You try to make it three different arguments so the 'contract' of the function is not obeyed.

When the three arguments are strings (or have the method toString()), you can construct them into a single string to write with e.g.:

"BatchID: " + BatchID + ",  ItemNumber:" + ItemNumber +", RunDate:" + RunDate

P.S.

I suggest that you get some experience with JS programming to understand the fundamentals.

Signature:
Reward community members who take time to respond and help.
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.