Run error - [error] AttributeError ( 'NoneType' object has no attribute 'getX' )

Asked by Dev S

I am seeing this error recently, whenever the execution reaches to validate Pass / Fail, it passes the case but stops the run and throws this error, It wasn't there earlier, so not sure whats happening. I am new to sikuli - Python, Any one help me please?

[log] CLICK on L[339,95]@S(0) (528 msec)
*INFO* PASS: New media packager tab - passed
[error] script [ LMP_automated_tests ] stopped with error in line 292
[error] AttributeError ( 'NoneType' object has no attribute 'getX' )
[error] --- Traceback --- error source first
line: module ( function ) statement
54: logger ( passed ) region = (last_match.getX(), last_match.getY(), last_match.getW(), last_match.getH())
106: main ( lmp_publishing_package ) self.log.passed("New media packager tab - passed")
287: main ( runTest ) self.lmp_publishing_package()
292: main ( <module> ) story.runTest()
[error] --- Traceback --- end --------------

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

[error] AttributeError ( 'NoneType' object has no attribute 'getX' )
...
54: logger ( passed ) region = (last_match.getX(), last_match.getY(), last_match.getW(),

Apparently last_match is undefined or empty in that moment. Where was this meant to be set?

Eventually you should use getLastMatch().getX() etc.

Revision history for this message
Dev S (singh-dev13) said :
#2

It runs fine till this point- Self.log.passed, and passes the validation but stops with an error.

                     type("n", KeyModifier.ALT)
                    wait(3)
                    type("m")
                    wait(7)
                    if exists("packagertab.png"):
                            click("packagertab.png")
                            self.log.passed("New media packager tab - passed")
                    else:
                            self.log.failed("New media packager tab - failed")
                            wait(2)

Error:
[log] ( Alt ) TYPE "n"
[log] TYPE "m"
[log] CLICK on L[339,95]@S(0) (537 msec)
*INFO* PASS: New media packager tab - passed
[error] script [ LMP_automated_tests ] stopped with error in line 292
[error] AttributeError ( 'NoneType' object has no attribute 'getX' )
[error] --- Traceback --- error source first
line: module ( function ) statement
54: logger ( passed ) region = (last_match.getX(), last_match.getY(), last_match.getW(), last_match.getH())
106: main ( lmp_publishing_package ) self.log.passed("New media packager tab - passed")
287: main ( runTest ) self.lmp_publishing_package()
292: main ( <module> ) story.runTest()
[error] --- Traceback --- end --------------

Revision history for this message
Dev S (singh-dev13) said :
#3

this from my logger.py,

def passed(self, msg, *args, **kwargs):
  self.info('PASS: ' + msg, *args, **kwargs)

  #if self.isEnabledFor(logging.DEBUG) and len(getLastFoundImages()) != 0:
  if len(getLastFoundImages()) != 0:
    #source image
    #self.html_img("Source Image", common.cfgImageLibrary + '/' + getLastFoundImage())
    #matched image
    last_match = SCREEN.getLastMatch()
    region = (last_match.getX(), last_match.getY(), last_match.getW(), last_match.getH())
    self.screenshot(msg="Best Matches", folder='results', region=region)
    #score of match
    #self.info("Matched with score: %s" % last_match.getScore())

Revision history for this message
Manfred Hampl (m-hampl) said :
#4

What is getLastFoundImages() ?

I suggest that you add a few debug statements, e.g. to check what SCREEN.getLastMatch() is at the moment when you try using it.

Why are you adding SCREEN at that moment? I do not see any need, if you did not use SCREEN in any other related part of the scripts.

Can you help with this problem?

Provide an answer of your own, or ask Dev S for more information if necessary.

To post a message you must log in.