Re: TruClient - Table Row Example (380 Views)
Reply
Advisor
Shawn Wales
Posts: 24
Registered: ‎05-22-2008
Message 1 of 5 (454 Views)

TruClient - Table Row Example

See attached for instructions and required files.

 

If you ever needed to work with Tables in TruClient this sample should help.. or at least give you some ideas.

 

It is more of an advanced level example, but if you have some "DOM" and "JavaScript" experience you should be fine.

 

There are about 10 different things you can learn from this example:

- custom javascript functions in TruClient.

- calling those functions.

- using DOM XPath function.

- using If/Then blocks.

- using try/catch blocks.

- finding a cell in a table.

- using CONTAINS clause in an XPath.

- using dialogs to display debug messages.

- DOM arrays vs. XPath arrays

- When to use the Arguments section vs. JS-functions.js for your javascript code.

- Toolbox options for custom javascript.

 

If you have questions/comments/suggestions please let me know.

HP Expert
JerryYin
Posts: 95
Registered: ‎08-16-2011
Message 2 of 5 (437 Views)

Re: TruClient - Table Row Example

Great

Occasional Visitor
PennWang
Posts: 1
Registered: ‎06-18-2013
Message 3 of 5 (428 Views)

Re: TruClient - Table Row Example

Thanks, really helpful.
Esteemed Contributor
James Leatherman
Posts: 538
Registered: ‎06-05-2008
Message 4 of 5 (413 Views)

Re: TruClient - Table Row Example

Love the commentary!

Valued Contributor
drenze
Posts: 73
Registered: ‎01-05-2012
Message 5 of 5 (380 Views)

Re: TruClient - Table Row Example

[ Edited ]

Thank you! I'd been struggling with how to capture the dynamic text contents of a specific object for use later in the script, and based on what you included here, I was able to put the following fairly generic function together in about 10 min to grab the node object. It actually took me more time to debug my XPath than to write the function, based on your good tutorial. :-)

 

/**
 * Get text contents of node specified by xPath.
 *
 * @arg     xpath       XPath for requested node.
 *
 * @return              Node element.
 */
function getNodeByXpath(xpath)
{
    /** Node to be returned. */
    var node;
    
    // Get node.
    try {
        node = document.evaluate(xpath,document,null,0,null).iterateNext();
    }
    
    catch (err) {
        return false;
    }
    
    return node;
}

 

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.