Forum Discussion

ssa's avatar
Occasional Contributor
11 years ago

Can't finding TD's DIV using EvaluateXPath Method.

My scenario is like this..













I am trying to use EvaluateXPath method to find the "STATUS" if page contains "requiredText"

Here is my XPath..

var obj = page.EvaluateXPath("//*[contains(text(), '" + text+ "')]/../../td[4]/div");

if ( obj !== null && obj !== undefined ) {

     var status = obj[0].innerText;



When i run the script it gives me below error...

'0.innerText' is null or not an object

Any idea what might possible be gone wrong or how can i my expected resut?

Thanks in advance for you help.

  • You need to convert the EvaluateXPath result to a JScript-compatible array (this is mentioned in the EvaluateXPath method description):

    var obj = page.EvaluateXPath(...);

    if (obj != null) {

      obj = obj.toArray();



    Or, you can use FindChildByXPath instead - it returns a single object instead of an array.