New Member.. Rosy101
New Member..
323 views

Truclient limitation need to know why I cant use different "getelements"

I am new to using Truclient and would like to know why I can not use the javascript method:

document.getElementsByClassName(), document.getElementsByName(), document.getElementsByTagName()

 

I was able to use document.getElementById() and was able to retrieve the textcontent but would like to also be able to use the other element because not all the html content have IDs.  My goal is to retrieve visible text from a table using the tagname <tr>.  Here is what I would like to put in the javascript evaluate: var table = document.getElementByTagName("tr")[3].textContext.

0 Likes
2 Replies
Contributor.. Edwin Contributor..
Contributor..

Re: Truclient limitation need to know why I cant use different "getelements"

Thank you for the feedback!

Which version of TC and browser do you use? These DOM APIs should works well on Evaluate JavaScript Code step. Please try

1. Add a Evaluate JavaScript Code step from toolbox in the Miscellaneous type

2. Set the arguments "Code" by click the Js icon

3. Execute the step.

Let me know if you encounter any futher issues. Thanks

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: Truclient limitation need to know why I cant use different "getelements"

All these methods, document.getElementsByClassName(), document.getElementsByName(), document.getElementsByTagName(), should work on all TC supported browsers (FF, IE, and Chromium).

I would suggest you split sentence

var table = document.getElementByTagName("tr")[3].textContext;

to three sentences, and add log after each step, to check which step actully has problem.

 

var trs = document.getElementByTagName("tr");
TC.log(trs, "Standard");
var tr3 = trs[3];
TC.log(tr3, "Standard");
var text = tr3.textContext;
TC.log(text, "Standard");

 

 

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.