Commit ef5950cd authored by Gabriel L. Oliveira's avatar Gabriel L. Oliveira

Fix test, and refactor to slightly improve readability

- Make it wait for gadgets dialog to load
- Make it clear environment at the end
parent 9243b86b
...@@ -63,6 +63,7 @@ class TestUNGGadgets(UNGTestMixin): ...@@ -63,6 +63,7 @@ class TestUNGGadgets(UNGTestMixin):
def test_add_two_gadgets(self): def test_add_two_gadgets(self):
"""test that its possible to add more than just 1 gadget""" """test that its possible to add more than just 1 gadget"""
self.selenium.click("//a[@id=\"add-gadgets\"]") self.selenium.click("//a[@id=\"add-gadgets\"]")
self.wait_add_gadgets_dialog_to_load()
self.selenium.click("//input[@id=\"erp5_documentation\"]") self.selenium.click("//input[@id=\"erp5_documentation\"]")
self.selenium.click("//input[@id=\"erp5_rss\"]") self.selenium.click("//input[@id=\"erp5_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]") self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
...@@ -76,16 +77,19 @@ class TestUNGGadgets(UNGTestMixin): ...@@ -76,16 +77,19 @@ class TestUNGGadgets(UNGTestMixin):
self.selenium.wait_for_page_to_load("30000") self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_element_present("//div[@id=\"portal-column-0\"]/div[2]/h3/span/a[@title=\"Remove\"]")) self.failIf(self.selenium.is_element_present("//div[@id=\"portal-column-0\"]/div[2]/h3/span/a[@title=\"Remove\"]"))
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !")) self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.click("//a[@class=\"clickable-block block-remove\"]") self.selenium.click("//a[@class='clickable-block block-remove']")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation())) self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation()))
self.wait_for_activities() self.wait_for_activities()
self.selenium.open("?reset:int=1") self.selenium.open("?reset:int=1")
self.selenium.wait_for_page_to_load("30000") self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]")) self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_element_present("//a[@class='clickable-block block-remove']"))
self.clear_user_gadgets()
def test_add_gadget_on_different_users(self): def test_add_gadget_on_different_users(self):
"""test that different users have different gadgets""" """test that different users have different gadgets"""
self.selenium.click("//a[@id=\"add-gadgets\"]") self.selenium.click("//a[@id=\"add-gadgets\"]")
self.wait_add_gadgets_dialog_to_load()
self.selenium.click("//input[@id=\"erp5_documentation\"]") self.selenium.click("//input[@id=\"erp5_documentation\"]")
self.selenium.click("//input[@id=\"erp5_rss\"]") self.selenium.click("//input[@id=\"erp5_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]") self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
...@@ -105,11 +109,12 @@ class TestUNGGadgets(UNGTestMixin): ...@@ -105,11 +109,12 @@ class TestUNGGadgets(UNGTestMixin):
# self.selenium.wait_for_page_to_load("30000") # self.selenium.wait_for_page_to_load("30000")
self.selenium.type("__ac_name", "ung_user2") self.selenium.type("__ac_name", "ung_user2")
self.selenium.type("__ac_password", "1234") self.selenium.type("__ac_password", "1234")
self.selenium.click("//input[@type=\"submit\"]") self.selenium.click("//input[@value='Login']")
self.selenium.wait_for_page_to_load("30000") self.selenium.wait_for_page_to_load("30000")
self.failUnless(self.selenium.is_text_present("Please use link (Add gadgets) to prepare it yourself.")) self.failUnless(self.selenium.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.failIf(self.selenium.is_text_present("Join ERP5 Network !")) self.failIf(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.click("//a[@id=\"add-gadgets\"]") self.selenium.click("//a[@id=\"add-gadgets\"]")
self.wait_add_gadgets_dialog_to_load()
self.selenium.click("//input[@id=\"erp5_worklists\"]") self.selenium.click("//input[@id=\"erp5_worklists\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]") self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000") self.selenium.wait_for_page_to_load("30000")
...@@ -124,15 +129,16 @@ class TestUNGGadgets(UNGTestMixin): ...@@ -124,15 +129,16 @@ class TestUNGGadgets(UNGTestMixin):
self.selenium.wait_for_page_to_load("30000") self.selenium.wait_for_page_to_load("30000")
self.selenium.type("__ac_name", "zope") self.selenium.type("__ac_name", "zope")
self.selenium.type("__ac_password", "zope") self.selenium.type("__ac_password", "zope")
self.selenium.click("//input[@type=\"submit\"]") self.selenium.click("//input[@value='Login']")
self.selenium.wait_for_page_to_load("30000") self.selenium.wait_for_page_to_load("30000")
self.failUnless(self.selenium.is_text_present("Please use link (Add gadgets) to prepare it yourself.")) self.failUnless(self.selenium.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.selenium.click("//a[@id=\"add-gadgets\"]") self.selenium.click("//a[@id=\"add-gadgets\"]")
self.wait_add_gadgets_dialog_to_load()
self.selenium.click("//input[@id=\"erp5_worklists\"]") self.selenium.click("//input[@id=\"erp5_worklists\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]") self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000") self.selenium.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]")) self.assertEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.selenium.click("//a[@class=\"clickable-block block-remove\"]") self.selenium.click("//a[@class='clickable-block block-remove']")
self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation())) self.failUnless(re.search(r"^Are you sure you want to remove this gadget from your personalized page[\s\S]$", self.selenium.get_confirmation()))
self.wait_for_activities() self.wait_for_activities()
self.selenium.open("WebSite_logout") self.selenium.open("WebSite_logout")
...@@ -141,11 +147,10 @@ class TestUNGGadgets(UNGTestMixin): ...@@ -141,11 +147,10 @@ class TestUNGGadgets(UNGTestMixin):
self.assertNotEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]")) self.assertNotEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.assertEqual("Feed Reader", self.selenium.get_text("//span[@class=\"gadget_title\"]")) self.assertEqual("Feed Reader", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !")) self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.clear_user_gadgets()
self.clear_user_gadgets('ung_user2', '1234')
self.clear_user_gadgets('zope', 'zope')
#XXX clean gadgets from all users after test
# maybe using KnowledgePad tool
# url: http://localhost:18080/erp5/portal_skins/erp5_web_ung_theme/WebSection_viewMenuWidget/pt_editForm
# starting at <div class="front_pad">
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment