sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #05367
[Question #171387]: Can squish use the sikuli jython interpreter?
New question #171387 on Sikuli:
https://answers.launchpad.net/sikuli/+question/171387
So I like to push boundaries.
Dev is pushing to use QTest and other Qt APIs to test a new Qt based gui. QTest can test the API, but I don't feel it captures the GUI user experience testing adequately. Some testers feel we should use Squish, which does similar testing as QTest, and so still doesn't fully test the user experience.
So, I thought if I could set Squish to use the Sikuli Jython interpreter as it's Jython interpreter, I could write jython scripts in the Squish IDE that also use Sikuli. I've had some success: When I add sikuli-script.jar as a Jython interpreter, Squish doesn't complain, and shows the sikuli-script.jar\Lib in the PYTHONPATH, but I'm not sure how to add the org.python.util.jython argument to this setup. Assuming, of course, that squishrunner invokes something like the "java -cp %SIKULI_HOME%\sikuli-script.jar org.python.util.jython %SCRIPT%" syntax to run the test scripts.
The Squish preferences page for setting up the jython interpreter for squish to use lets you specify the following:
Path to the .jar file
I set this to sikuli-script.jar
Libraries
SIKULI_HOME\Lib
SIKULI_HOME\sikuli-script.jar\Lib
SIKULI_HOME\sikuli-script\Lib (extracted from sikuli-script.jar)
squish libraries
Forced Builtins
I see things like StringIO, os, email, ..., no sikuli builtins, though
Predefined Completions
Environment
String Substitution Variables
These last three have nothing defined.
(see http://pydev.org/manual_101_interpreter.html for more details about this)
Since I am new to both Java and Python, I'm not sure what, if anything, I should be adding here.
Every time I use squish to run the .py script, it complains on the import: No module named sikuli.Sikuli
Any clues?
My script at this point looks like:
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bgriffin"
__date__ ="$Jul 29, 2011 2:00:36 PM$"
from sikuli.Sikuli import *
# adjust the variables to match your setup
import os
import os.path
# base directory of Squish
home = os.environ["USERPROFILE"]
squishdir = os.path.join(home, "Downloads", "squish-4.1.0-qt47x-win64-msvc10", "squish-4.1.0-qt47x-win64-msvc10")
if not squishdir in sys.path:
sys.path.append(squishdir)
sys.path.append(os.path.join(squishdir, "python", "Lib"))
sikulidir = os.environ['SIKULI_HOME']
if not sikulidir in sys.path:
sys.path.append(sikulidir)
sys.path.append(os.path.join(sikulidir, "sikuli-script", "Lib"))
from sikuli.Sikuli import *
# directory to which the HTML results should be written
outdir = os.path.join(home, "results")
# list of test suites to execute
suites = [
os.path.join(squishdir, "examples", "qt4", "suite_addressbook_py"),
os.path.join(squishdir, "examples", "qt4", "suite_addressbook_js"),
]
# list of hosts on which the suites should be executed
hosts = [
"127.0.0.1",
]
def invokeMenuItem(menu, item):
activateItem(waitForObjectItem("{type='QMenuBar' visible='true'}", menu))
activateItem(waitForObjectItem("{type='QMenu' title='%s'}" % menu, item))
def addNameAndAddress(oneNameAndAddress):
invokeMenuItem("Edit", "Add...")
for fieldName, text in zip(("Forename", "Surname", "Email", "Phone"), oneNameAndAddress):
type(waitForObject(":%s:_QLineEdit" % fieldName), text)
clickButton(waitForObject(":Address Book - Add.OK_QPushButton"))
def closeWithoutSaving():
invokeMenuItem("File", "Quit")
clickButton(waitForObject(":Address Book.Cancel_QPushButton"))
def main():
startApplication("addressbook")
table = waitForObject(":Address Book_QTableWidget")
invokeMenuItem("File", "New")
test.verify(table.rowCount == 0)
data = [("Andy", "Beach", "andy.beach@xxxxxxxxxxx", "555 123 6786"),
("Candy", "Deane", "candy.deane@xxxxxxxxxxx", "555 234 8765"),
("Ed", "Fernleaf", "ed.fernleaf@xxxxxxxxxxx", "555 876 4654")]
for oneNameAndAddress in data:
addNameAndAddress(oneNameAndAddress)
test.verify(table.rowCount == len(data))
closeWithoutSaving()
if __name__ == "__main__":
print "Hello World"
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.