Python Tests
Windmill provides an implementation of the controller that is used for windmill tests using functest.
# Generated by the windmill services transformer from windmill.authoring import WindmillTestClient def test(): client = WindmillTestClient(__name__) client.click(id=u'viewNavCenterRight') client.waits.sleep(milliseconds=2000) client.doubleClick(id=u'hourDiv1-1200') client.waits.sleep(milliseconds=2000) client.type(text=u'Properties Test', id=u'noteTitle') client.type(text=u'9:00', id=u'startTime') client.type(text=u'4:00', id=u'endTime') client.radio(id=u'startMeridianAM') client.radio(id=u'endMeridianPM') client.select(id=u'eventStatus', option=u'Tentative') client.type(text=u'A description for the properties test', id=u'noteDescription')
By default WindmillTestClient will throw an assertion whenever a test has a failed result. This triggers a failure for that test method in functest.
You can turn off these assertions and do the assertion yourself. This is useful if you want to assert that a test failed.
from windmill.authoring import WindmillTestClient def test(): client = WindmillTestClient(__name__, assertions=False) client.waits.forElement(xpath=u'html/body/center/p/font', timeout=u'3000') assert not client.asserts.assertValue(validator=u'Google Search', name=u'btnG')['result']
Notice that the object returned from client.waits.forElement is not a simple boolean, it's actually the entire result object returned from the windmill IDE. It includes the starttime, endtime, and other debugging information about the test call.
Moving On
Now that you know how to author tests in python you're ready to move on to learn how to run Python windmill tests.
