Question #255662 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/255662
Summary changed to:
Jython scripting: using observe(): handler functions cannot be cast as a
handler in Eclipse integration
Description changed to:
I'm running some user acceptance tests before beginning a section of a project,
so the code is very generic. I'm attempting to create a background listener
before launching my automation code to look for unexpected errors within UI
regression suites.
I'm getting the following error:
Traceback (most recent call last):
File "C:\test\TPS_70\Script\GUI\MatchingExample.sikuli\MatchingExample.py",
line 18, in <module>
r.onAppear(sikuli.Pattern("folder.png").similar(0.69), errorOut)
at org.sikuli.script.Region.onAppear(Region.java:2023)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
java.lang.ClassCastException: java.lang.ClassCastException:
org.python.core.PyFunction cannot be cast to
org.sikuli.script.SikuliEventObserver
This is coming from the following code:
import sikuli.Sikuli as sikuli
sikuli.Settings.OcrTextRead = True
sikuli.Settings.OcrTextSearch = True
import datetime
import time
def errorOut(event):
assert False, "WOO!"
r = sikuli.Region.create(1 , 35,500,500)
r.onAppear(sikuli.Pattern("thing.png").similar(0.69), errorOut)
print "before" + str(datetime.datetime.now().time().isoformat())
r.observe(25, background=True)
print "onward" + str(datetime.datetime.now().time().isoformat())
for x in xrange(15):
time.sleep(1)
print "This"
I've been waiting about 5-10 seconds and then opening the Google Chrome
homepage which is what "thing.png" is of, and I want it to throw the exception
when it shows up in the middle of the print statements. It is working as
expected in the Sikuli IDE, but we are using Eclipse for our projects as they
are very large.
I'm using Sikulix 1.0.1 but to use the IDE I have needed to replace the files
with an r930 build (Work around I found online for a bug causing the IDE not to
launch), this causes an error that org.sikuli.basics cannot be found if I
attempt to run the script in Eclipse with this version being run. It's a 32-bit
system.
The question was replaced with spam so I am fixing it. (Second update)
replaced with the wrong question, sorry
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.
_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help : https://help.launchpad.net/ListHelp