Ask a Question

Python AttributeError: 'Nonetype@ object has no attribute 'SetFocus'

New Contributor

Python AttributeError: 'Nonetype@ object has no attribute 'SetFocus'

I have the below code snippet written in Python

filltext= page.FindChildByXPath('//Input[@Id="textbox1"]',True)

It is not able to SetFocus() OR Click() OR Keys() on this text box.


When i Tried to log the type of 


It returns 0. Can someone please help me to resolve this error?

Community Hero

Re: Python AttributeError: 'Nonetype@ object has no attribute 'SetFocus'



> .FindChildByXPath()

As per documentation:

If the object is searched by XPath and is found, TestComplete tries to match the found object to the one from its objects tree. If the match succeeds, then TestComplete returns its wrapping object that contains all properties and methods added by TestComplete (SetFocus(), .Keys(), etc.).

If the match fails, than native DOM object is returned. In this case test code can use only native properties/methods provided by DOM for this given object within given web browser.

If search by XPath fails then (as described in the XPath documentation) null is returned.


The above is one from a number of reasons why XPath is highly not recommended practice in TestComplete's world.


So, the reason of your problem is simple: XPath failed to find the sought for object.

Recommended correction that works in most of cases: replace .FindChildByXPath() with .FindChildEx() and provide long enough timeout value to guarantee that the sought for control is rendered on the screen.


  /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.
Showing results for 
Search instead for 
Did you mean: