Ask a Question

You are trying to call the "Click" method or property of the "item" object that does not exist.

SOLVED
Nilam
Occasional Contributor

You are trying to call the "Click" method or property of the "item" object that does not exist.

You are trying to call the "Click" method or property of the "item" object that does not exist. This additional information comes when i search a web element using "page.NativeWebObject" and also in some case when i search by using X path , i got the same problem in test log like object doesn't exist. what is it mean and how can i solve it.

 
1 ACCEPTED SOLUTION

Accepted Solutions
shankar_r
Community Hero

Re: You are trying to call the "Click" method or property of the "item" object t

Hi,

 

Basically, The error message says the object you are trying to Click is not exists in your page.

 

Always good to check exists then do the operation as like below,

 

function clickObject(){
      var pageObject = page.FindChildByXpath("<your xpath>");
      
      if(pageObject.Exists){
            pageObject.Click();
      }else{
            Log.Error("Object not exists on the screen");
      }
      //Or you can use the CheckProperty which is in-build function
      https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqobject/checkproperty.html      
}

 

 

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

View solution in original post

5 REPLIES 5
shankar_r
Community Hero

Re: You are trying to call the "Click" method or property of the "item" object t

Hi,

 

Basically, The error message says the object you are trying to Click is not exists in your page.

 

Always good to check exists then do the operation as like below,

 

function clickObject(){
      var pageObject = page.FindChildByXpath("<your xpath>");
      
      if(pageObject.Exists){
            pageObject.Click();
      }else{
            Log.Error("Object not exists on the screen");
      }
      //Or you can use the CheckProperty which is in-build function
      https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqobject/checkproperty.html      
}

 

 

 


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

View solution in original post

AlexKaras
Community Hero

Re: You are trying to call the "Click" method or property of the "item" object t

Hi,

 

My $0.02 to the explanation given by @shankar_r:

-- When searching by XPath, TestComplete tries to match the found native DOM element(s) to the objects from its (TestComplete's) objects tree;

-- If the match succeeds, TestComplete's object is returned. Native DOM element is returned otherwise;

-- If XPath found nothing then null is returned (see TestComplete's documentation for more details).

 

So, if TestComplete was able to match the found DOM element to its objects tree, you will be able to call .Click() method because this is a method that TestComplete adds to all UI objects from its object tree.

If TestComplete failed to match the found DOM element to its objects tree and the native DOM element was returned, you will be able to call .Click() method only if it is supported by this given DOM element. And the chances are high that the call will fail because of case-sensitivity: .click(), but not .Click() is usually supported by DOM elements.

If XPath found nothing, it is obvious that the call to null.Click() will fail as well.

 

P.S. The above is one of the reasons why XPath search is highly not recommended for TestComplete.

 

P.P.S.

var pageObject = page.FindChildByXpath("<your xpath>");
if(pageObject.Exists
  ...

Note, that the above verification will work as expected only if TestComplete can match the found DOM element to its object. If not, then you will get an error that .Exists property does not exist (which is correct, because native DOM element does not contain .Exists property).
So, if you really need to search by XPath, you must check for null first to ensure that something was found, then check if .Exists property is supported. If it is, then you may assume that TestComplete's wrapping object was returned and can use any method provided by TestComplete. Otherwise, you can use only native web methods provided by this given found DOM element.

 

(This is another reason why XPath is not recommended for TestComplete 🙂 )

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
shankar_r
Community Hero

Re: You are trying to call the "Click" method or property of the "item" object t

This is obvious @AlexKaras, I haven't worked much with Web testing and TestComplete hence i missed that point to make it. Thanks for updating that too. Smiley Happy


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

AlexKaras
Community Hero

Re: You are trying to call the "Click" method or property of the "item" object t

> I haven't worked much with Web testing

Lucky you are I would say...

🙂

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
shankar_r
Community Hero

Re: You are trying to call the "Click" method or property of the "item" object t

Maybe i would say i escaped Smiley Happy


Thanks
Shankar R

LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com

“You must expect great things from you, before you can do them”

Extension Available

cancel
Showing results for 
Search instead for 
Did you mean: