Highlighted
Visitor.
113 views

TruClient Web - How to Click a link that is associated with a static non-clickable text on web page?

Hi,

How can I record/code the TruClient script for the following scenario?

On a given web page, there is a table something similar to below.

How can I record the link that is associated to a particular static text in a row?

Thanks in Advance,

Deepika

Clickable LinksStatic text
Not Unique name  linkUnique text 1
Not Unique name  link
Unique text 2
Not Unique name  link
Unique text 3
0 Likes
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TruClient Web - How to Click a link that is associated with a static non-clickable text on web p

Hi @Deepika Ellur,

If the "Unique text" items in second column are not created dynamically, try Related Object to help identifying the link object left to it.

Otherwise, try JavaScript ID method of the Object. In the JavaScript code, use DOM APIs or XPath to locate "Unique text" item in the second column, then find the neighbor link left to it.

0 Likes
Highlighted
Visitor.

Re: TruClient Web - How to Click a link that is associated with a static non-clickable text on web p

Found an answer from StackOverflow -

TruClient support several ways to identify the test object:

Automatic
Descriptor
JavaScript
XPath
I don't think the automatic or descriptor are fit for this request. We need to write some JS code complete the request.

Change the object identification method to js from a Step > Object > ID Method.
Click the edit icon from the right of the input box. Make sure the evaluated value of the JS code is reference to the right DOM object. Here is a sample code base on your example to filter the Link element:
Added reference firstChild as you mentioned the link is contained in a div element. Glad to know it works. 🙂

Array.prototype.slice.call(document.querySelectorAll('td'), 0).filter(td=>td.innerText=="Name20200323005")[0].previousElementSibling .previousElementSibling.firstChild

0 Likes
Highlighted
Visitor.

Re: TruClient Web - How to Click a link that is associated with a static non-clickable text on web p

Thank you @Alex Zhou  It works with JS code.

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.