Forum Discussion

nitinn's avatar
nitinn
Occasional Contributor
7 years ago

JavaScript error

Hi ,

I am getting a javascript error using the below code.

Code:

var Page = Sys.Browser("chrome").Page("*");

function InviteSupplier()
{


Page.FindChildByXPath("//span[contains(text(),'Invitation to Join')]").Click();

}

 

Error:

 

TypeError Cannot read property 'Click' of null Error location: Unit: "V1 product codes\V1 product codes\Script\Function_Library" Line: 44 Column: 73.

TypeError
Cannot read property 'Click' of null
Error location:
Unit: "V1 product codes\V1 product codes\Script\Function_Library"
Line: 44 Column: 73.

 

 

2 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor

    Hi nitinn,

     

    Looks like something is wrong with your xpath, TestComplete doesn't find the element and FindChildByXPath method returns null.

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      It's always a good idea that, when using any Find method, that, before you use the result you check to see if you actually found something.