From dfa227cbe5e9f1f6b37d944275b698bf33fecfad Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 27 Aug 2008 08:18:54 +0000 Subject: [PATCH] Updated windmill tests to use python syntax, as this will scale better git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@61626 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- tests/CMSMainTest.yml | 19 ++++++++------ tests/test_windmill/__init__.py | 4 --- tests/test_windmill/failed-login.json | 7 ----- .../test_windmill/login-and-create-page.json | 26 ------------------- tests/test_windmill/test_admin/__init__.py | 25 ++++++++++++++++++ .../test_admin/test_CreateGroup.py | 26 +++++++++++++++++++ 6 files changed, 62 insertions(+), 45 deletions(-) delete mode 100644 tests/test_windmill/failed-login.json delete mode 100644 tests/test_windmill/login-and-create-page.json create mode 100644 tests/test_windmill/test_admin/__init__.py create mode 100644 tests/test_windmill/test_admin/test_CreateGroup.py diff --git a/tests/CMSMainTest.yml b/tests/CMSMainTest.yml index 83e7b8ab..bfd0f699 100644 --- a/tests/CMSMainTest.yml +++ b/tests/CMSMainTest.yml @@ -1,12 +1,15 @@ Page: - page1: - Title: Page 1 - page2: - Title: Page 2 - page3: - Title: Page 2 - page4: - Title: Page 2 + home: + Title: Home + URLSegment: home + page1: + Title: Page 1 + page2: + Title: Page 2 + page3: + Title: Page 2 + page4: + Title: Page 2 Group: admin: diff --git a/tests/test_windmill/__init__.py b/tests/test_windmill/__init__.py index b65827c1..6883e0ca 100644 --- a/tests/test_windmill/__init__.py +++ b/tests/test_windmill/__init__.py @@ -1,5 +1 @@ -import cherrypy.lib -import windmill.authoring from windmill.authoring import setup_module, teardown_module, enable_collector - -enable_collector() diff --git a/tests/test_windmill/failed-login.json b/tests/test_windmill/failed-login.json deleted file mode 100644 index 4eed1b25..00000000 --- a/tests/test_windmill/failed-login.json +++ /dev/null @@ -1,7 +0,0 @@ -{"params": {"id": "MemberLoginForm_LoginForm_Email"}, "method": "asserts.assertNode"} -{"params": {"id": "MemberLoginForm_LoginForm_Email"}, "method": "click"} -{"params": {"text": "td", "id": "MemberLoginForm_LoginForm_Email"}, "method": "type"} -{"params": {"text": "badpassword", "id": "MemberLoginForm_LoginForm_Password"}, "method": "type"} -{"params": {"id": "MemberLoginForm_LoginForm_action_dologin"}, "method": "click"} -{"params": {"id": "MemberLoginForm_LoginForm_error", "timeout": 5000}, "method": "waits.forElement"} -{"params": {"id": "MemberLoginForm_LoginForm_error"}, "method": "asserts.assertNode"} diff --git a/tests/test_windmill/login-and-create-page.json b/tests/test_windmill/login-and-create-page.json deleted file mode 100644 index 894fb2e9..00000000 --- a/tests/test_windmill/login-and-create-page.json +++ /dev/null @@ -1,26 +0,0 @@ -{"params": {"id": "MemberLoginForm_LoginForm_Email"}, "method": "click"} -{"params": {"text": "admin", "id": "MemberLoginForm_LoginForm_Email"}, "method": "type"} -{"params": {"text": "password", "id": "MemberLoginForm_LoginForm_Password"}, "method": "type"} -{"params": {"id": "MemberLoginForm_LoginForm_action_dologin"}, "method": "click"} - -{"params": {"id": "heading_sitetree", "timeout": 240000}, "method": "waits.forElement"} -{"params": {"milliseconds": 30000}, "method": "waits.sleep"} - -{"params": {"xpath": "\/html\/body\/div\/div\/div\/ul\/li\/button"}, "method": "click"} -{"params": {"id": "Form_AddPageOptionsForm_PageType"}, "method": "click"} - -{"params": {"option": "Page", "id": "Form_AddPageOptionsForm_PageType"}, "method": "select"} -{"params": {"validator": "Page", "id": "Form_AddPageOptionsForm_PageType"}, "method": "asserts.assertValue"} - - -{"params": {"xpath": "\/html\/body\/div\/div\/div\/form\/div[2]\/input"}, "method": "click"} - -{"params": {"milliseconds": 10000}, "method": "waits.sleep"} -{"params": {"timeout": 10000, "id": "Form_EditForm_Title"}, "method": "waits.forElement"} -{"params": {"validator": "New Page", "id": "Form_EditForm_Title"}, "method": "asserts.assertValue"} -{"params": {"id": "Form_EditForm_Title"}, "method": "click"} -{"params": {"text": "test page", "id": "Form_EditForm_Title"}, "method": "type"} -{"params": {"id": "tab-Root_Content_set_Metadata"}, "method": "click"} -{"params": {"validator": "test-page", "id": "Form_EditForm_URLSegment"}, "method": "asserts.assertValue"} -{"params": {"id": "Form_EditForm_action_publish"}, "method": "click"} -{"params": {"id": "viewLiveSite"}, "method": "click"} diff --git a/tests/test_windmill/test_admin/__init__.py b/tests/test_windmill/test_admin/__init__.py new file mode 100644 index 00000000..ee49af4a --- /dev/null +++ b/tests/test_windmill/test_admin/__init__.py @@ -0,0 +1,25 @@ +from windmill.authoring import setup_module, teardown_module, enable_collector, WindmillTestClient +import windmill + +def setup_module(module): + client = WindmillTestClient(__name__) + + client.open(url=windmill.settings['TEST_URL'], id=u'fixture-file') + client.type(text=u'cms/tests/CMSMainTest.yml', id=u'fixture-file') + client.click(id=u'start-session') + + client.waits.forPageLoad(timeout=u'20000') + client.click(id=u'admin-link') + client.waits.forPageLoad(timeout=u'20000') + + client.type(text=u'admin@example.com', id=u'MemberLoginForm_LoginForm_Email') + client.type(text=u'ZXXlkwecxz2390232233', id=u'MemberLoginForm_LoginForm_Password') + client.click(id=u'MemberLoginForm_LoginForm_action_dologin') + client.waits.forPageLoad(timeout=u'120000') + +def teardown_module(module): + client = WindmillTestClient(__name__) + + client.open(url=windmill.settings['TEST_URL'], id=u'fixture-file') + client.click(id=u'end-session') + \ No newline at end of file diff --git a/tests/test_windmill/test_admin/test_CreateGroup.py b/tests/test_windmill/test_admin/test_CreateGroup.py new file mode 100644 index 00000000..d53c18ec --- /dev/null +++ b/tests/test_windmill/test_admin/test_CreateGroup.py @@ -0,0 +1,26 @@ +# Generated by the windmill services transformer +from windmill.authoring import WindmillTestClient + +def test(): + client = WindmillTestClient(__name__) + + client.click(link=u'Security') + client.waits.forPageLoad(timeout=u'20000') + client.click(xpath=u"/html/body/div[@id='left']/div[@id='treepanes']/ul[@id='TreeActions']/li[@id='addgroup']/button") + client.waits.sleep(milliseconds=u'5000') + + client.asserts.assertText(validator=u'New Group', id=u'record-2') + client.asserts.assertValue(validator=u'New Group', id=u'Form_EditForm_Title') + + client.click(id=u'Form_EditForm_Title') + client.type(text=u'Test Group', id=u'Form_EditForm_Title') + client.click(id=u'Form_EditForm_action_save') + client.waits.sleep(milliseconds=u'5000') + + client.asserts.assertText(validator=u'Test Group', id=u'record-2') + + client.click(id=u'Form_AddRecordForm_FirstName') + client.type(text=u'Test', id=u'Form_AddRecordForm_FirstName') + client.type(text=u'Person', id=u'Form_AddRecordForm_Surname') + client.type(text=u'test@example.com', id=u'Form_AddRecordForm_Email') + client.click(id=u'Form_AddRecordForm_action_addtogroup') \ No newline at end of file