Commit 455f7a5c authored by Rafael Monnerat's avatar Rafael Monnerat

Added selenium tests created by Gabriel Oliveira for UNG on ERP5 UI.

parent 81888e4a
from selenium import selenium
import unittest
import urllib2
import os
ERP5_URL = "http://localhost:18080/erp5/"
UNG_URL = ERP5_URL + "web_site_module/ung/"
class UNGTestMixin(unittest.TestCase):
"""Base class for selenium UNG tests, containing useful methods."""
def setUp(self):
"""set up instance environment"""
self.verificationErrors = []
self.selenium = selenium("localhost", 4444, "*chrome", UNG_URL)
self.selenium.start()
#do default actions
self.init()
def init(self):
"""clear cache, open default page, login, wait for activities
and then set default tree view as 'All Documents'"""
self.clear_cache()
self.open_ung_default_page()
self.login_as_default_user()
self.wait_for_activities()
self.set_default_tree_view()
#XXX all tests parsed may have
# <tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/delete-all-documents"/>
# but it was omitted since it's not permited to delete objects
def login_as_default_user(self):
"""login as default user 'test_user'"""
#login to access home page -- equals to macros/login
self.selenium.type("name", "test_user")
self.selenium.type("password", "test_user")
self.selenium.click("logged_in:method")
self.selenium.wait_for_page_to_load("30000")
def set_default_tree_view(self):
"""select default opened tree view as 'All Documents'"""
try:
if not "All Documents" == self.selenium.get_text("//button[@class=\"tree-open\"]"):
self.selenium.click("//table[@class='your_listbox-table-domain-tree']/tbody/tr[1]/td/button")
self.selenium.wait_for_page_to_load("30000")
except:
self.selenium.click("//table[@class='your_listbox-table-domain-tree']/tbody/tr[1]/td/button")
self.selenium.wait_for_page_to_load("30000")
def clear_cache(self):
"""call method 'Base_clearCache' of bt5 erp5_ui_test, that orders
portal_catalog to clear all allocated cache"""
self.selenium.open("Base_clearCache")
self.selenium.wait_for_page_to_load("30000")
def wait_for_activities(self):
"""wait untill all activities end up, trying 60 times to see it,
sleeping 2 seconds after each try"""
activities = urllib2.urlopen(ERP5_URL + 'portal_activities/getMessageList')
for _try in range(60):
#XXX 'readlines' is proxyfied, so url is opened everytime it's called
message_queue = activities.readlines()
if not message_queue:
break
unittest.time.sleep(2) #XXX give time to selenium to recompose page when refresh
def open_ung_default_page(self, page="", clear_cache=0, wait_for_activities=0):
"""open ung default page
page = UNG page to be opened, default to UNG Docs
clear_cache = if enabled, will call 'clear_cache'
wait_for_activities = if enabled, will call 'wait_for_activities'"""
if clear_cache:
self.clear_cache()
if wait_for_activities:
self.wait_for_activities()
self.selenium.open(page)
self.selenium.wait_for_page_to_load("30000")
if page == "calendar":
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
def get_file_path(self, filename):
"""returns the absolute path to a test file given a 'filename'"""
return os.path.join(os.path.abspath(os.curdir), 'test_data', filename)
def tearDown(self):
"""method called immediately after the test method has been called and
the result recorded."""
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
def create_document(self, portal_type, name=None, keywords=None):
"""create web documents, given a portal_type, optionally changing
properties:
name = name of the document
keywords = keyword_list of the document
"""
self.selenium.open("ERP5Site_createNewWebDocument?template=web_%s_template" % portal_type)
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
if name:
self.selenium.type("//input[@id=\"name\"]", name)
if keywords:
self.selenium.type("//textarea[@id=\"keyword_list\"]", keywords)
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.wait_for_activities()
return self.selenium.get_eval('selenium.browserbot.getCurrentWindow().location').split('?')[0]
def create_calendar_event(self, event_type, name, start_month=None,
end_month=None, start_day=None, end_day=None,
start_year=None, end_year=None,
start_hour=None, end_hour=None,
start_minute=None, end_minute=None,
do_refresh=True):
"""Create an event at UNG Calendar.
Requires that the UNG Calendar is open."""
self.selenium.click("//span[@class=\"addcal\"]")
self.selenium.wait_for_condition("selenium.isElementPresent(\"portal_type\")", "10000")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.select("//select[@name=\"portal_type\"]", event_type)
self.selenium.type("//input[@name=\"title\"]", name)
if start_month:
self.selenium.type("start_date_month", start_month)
if end_month:
self.selenium.type("stop_date_month", end_month)
else:
self.selenium.type("stop_date_month", start_month)
if start_day:
self.selenium.type("start_date_day", start_day)
if end_day:
self.selenium.type("stop_date_day", end_day)
else:
self.selenium.type("stop_date_day", start_day)
if start_year:
self.selenium.type("start_date_year", start_year)
if end_year:
self.selenium.type("stop_date_year", end_year)
else:
self.selenium.type("stop_date_year", start_year)
if not start_hour:
start_hour = unittest.time.localtime().tm_hour + 1
if not end_hour:
end_hour = unittest.time.localtime().tm_hour + 1
self.selenium.type("start_date_hour", start_hour)
self.selenium.type("stop_date_hour", end_hour)
if start_minute:
self.selenium.type("start_date_minute", start_minute)
if end_minute:
self.selenium.type("stop_date_minute", end_minute)
else:
self.selenium.type("stop_date_minute", start_minute)
self.selenium.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
self.wait_for_activities()
if do_refresh:
#XXX due to interface delay
#refresh interface 10 times
for _try in range(10):
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
if self.selenium.is_text_present(name):
break
else:
unittest.time.sleep(2)
if __name__ == "__main__":
unittest.main()
This diff is collapsed.
This diff is collapsed.
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGDocsSharing(UNGTestMixin):
"""tests related to the action of share documents on UNG Docs"""
def test_share_web_page_with_another_user(self):
"""test that web_page is correctly shared with another user"""
self.selenium.open("ERP5Site_createNewWebDocument?template=web_page_template")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.type("//input[@id=\"name\"]", "Document Shared")
self.selenium.click("//p[@id=\"more_properties\"]")
self.selenium.type("//input[@id=\"version\"]", "002")
self.selenium.type("//input[@id=\"language\"]", "pt-br")
self.selenium.type("//textarea[@id=\"keyword_list\"]", "My Subject")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", self.selenium.get_value("//input[@id=\"version\"]"))
self.assertEqual("pt-br", self.selenium.get_value("//input[@id=\"language\"]"))
self.assertEqual("My Subject", self.selenium.get_value("//textarea[@id=\"keyword_list\"]"))
self.assertEqual("Document Shared", self.selenium.get_value("//input[@id=\"name\"]"))
self.selenium.click("//a[@id=\"share_document\"]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Shared", self.selenium.get_text("//a[@name=\"document_state\"]"))
document_url = self.selenium.get_text("//span[@id=\"sharing_url\"]")
self.wait_for_activities()
self.selenium.open("")
self.selenium.wait_for_page_to_load("30000")
#XXX this could be changed (for a generic approach) to //button[@value='ung_domain/shared.0']
self.selenium.click("//table[@class=\"your_listbox-table-domain-tree\"]/tbody/tr[9]/td/button")
self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_text_present("No Result"))
self.assertEqual("Shared by me", self.selenium.get_text("//button[@class=\"tree-open\"]"))
self.selenium.click("//div[@id='wrapper_navigation']/div[2]/fieldset/div[2]/div/div/a[5]")
self.selenium.wait_for_page_to_load("30000")
#XXX user already created
# self.selenium.click("//td[@id=\"new-account-form\"]")
# self.selenium.type("//input[@name=\"firstname\"]", "Another")
# self.selenium.type("//input[@name=\"lastname\"]", "User")
# self.selenium.type("//input[@name=\"email\"]", "example2@example.com")
# self.selenium.type("//input[@name=\"login_name\"]", "ung_user2")
# self.selenium.type("//input[@name=\"password\"]", "1234")
# self.selenium.type("//input[@name=\"confirm\"]", "1234")
# self.selenium.click("//input[@value=\"Create Account\"]")
# self.selenium.wait_for_page_to_load("30000")
self.selenium.type("__ac_name", "ung_user2")
self.selenium.type("__ac_password", "1234")
self.selenium.click("//input[@type=\"submit\"]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.open(document_url)
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Document Shared", self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", self.selenium.get_value("//input[@id=\"version\"]"))
self.assertEqual("pt-br", self.selenium.get_value("//input[@id=\"language\"]"))
self.assertEqual("My Subject", self.selenium.get_value("//textarea[@id=\"keyword_list\"]"))
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.login_as_default_user()
self.selenium.click("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.selenium.type("//input[@id=\"version\"]", "003")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("003", self.selenium.get_value("//input[@id=\"version\"]"))
#XXX this test delete all documents here
# but it won't be done
if __name__ == "__main__":
unittest.main()
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGDocsTableEditor(UNGTestMixin):
def test_fill_some_cells_in_web_table(self):
"""test the action of add, fill cells, assert title of sheet and
content of cells of a Web Table document"""
self.selenium.open("ERP5Site_createNewWebDocument?template=web_table_template")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Web Table", self.selenium.get_text("//a[@name=\"document_title\"]"))
self.failUnless(self.selenium.is_element_present("//td[@id='0_table0_cell_c0_r1']"))
self.failUnless(self.selenium.is_element_present("//td[@id='0_table0_cell_c1_r1']"))
self.assertEqual("Spreadsheet Playground", self.selenium.get_text("//td[@id=\"jSheetTitle_0\"]"))
self.assertEqual("MENU", self.selenium.get_text("//td[@id=\"jSheetMenu_0\"]/span[@class=\"rootVoice\"]"))
self.selenium.run_script("$(\"#0_table0_cell_c0_r0\").html(\"Gabriel\")")
self.selenium.run_script("$(\"#0_table0_cell_c1_r1\").html(\"Monnerat\")")
self.selenium.click("//button[@class=\"save\"]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Gabriel", self.selenium.get_text("//td[@id='0_table0_cell_c0_r0']"))
self.assertEqual("Monnerat", self.selenium.get_text("//td[@id='0_table0_cell_c1_r1']"))
if __name__ == "__main__":
unittest.main()
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGDocsTextEditor(UNGTestMixin):
"""tests related to UNG Docs text editors"""
def test_fill_content_on_web_page_with_fck_editor(self):
"""test the action of filling content on FCK Editor for a Web Page
document"""
#configure settings
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.check("//input[@value=\'fck_editor\']")
self.selenium.check("//input[@value=\'text/html\']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
#create new Web Page
self.selenium.click("//div[@id='wrapper_main']/div[1]/fieldset/div/div/div/div/div/div[1]/li/ul/li[3]/a/span")
self.selenium.wait_for_page_to_load("30000")
#type text on FCK Editor
self.selenium.select_frame("//td[@id='xEditingArea']/iframe")
self.selenium.type("//body", "<p>hello there</p>")
self.selenium.select_window("null")
#save Web Page
self.selenium.click("//button[@name='Base_edit:method']")
self.selenium.wait_for_page_to_load("30000")
#wait for activities
self.wait_for_activities()
#assert text was typed
self.assertEqual("<p>hello there</p>", self.selenium.get_eval("window.document.getElementById('field_my_text_content').value"))
#go back to home page
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
#go back to the created Web Page (the last one modified on the list)
self.selenium.click("//tr[@class='your_listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
#assert text was saved
self.selenium.wait_for_condition("selenium.browserbot.getCurrentWindow().document.getElementById('field_my_text_content')", "5000")
self.assertEqual("<p>hello there</p>", self.selenium.get_eval("window.document.getElementById('field_my_text_content').value"))
self.selenium.select_window("null")
def test_upload_text_with_image(self):
"""test that uploading a Text Document (Open Office) with an image, as a
Web Page, will have its text and image correctly showed on fck editor"""
test_time = int(unittest.time.time())
#set default text editor as FCKeditor
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.check("//input[@value=\'fck_editor\']")
self.selenium.check("//input[@value=\'text/html\']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
#get file_path
test_file_path = self.get_file_path("ung-UNGDocs.Sample.TextWithImage.Text-001-en.odt")
web_page_name = "Functional UNG Test %d - Uploaded Web Page With Image" % test_time
#upload document
self.selenium.click("//input[@id=\"upload\"]")
self.selenium.select("//select[@name=\"portal_type\"]", "Web Page")
self.selenium.click("//input[@id=\"submit_document\"]")
self.selenium.type("//input[@id=\"upload-file\"]", test_file_path)
self.selenium.click("//input[@id=\"submit_document\"]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.wait_for_condition("selenium.isTextPresent(\"Opening\")", "30000")
self.selenium.wait_for_page_to_load("30000")
#XXX this requires enabling a System Preference with Cloudooo
self.selenium.wait_for_condition("selenium.isElementPresent(\"//a[@name='document_title']\")", "30000")
#save document
self.selenium.click("//button[@name='Base_edit:method']")
self.selenium.wait_for_page_to_load("30000")
#assert web_page title
self.failUnless(self.selenium.is_text_present("UNGDocs Text"))
web_page_content = self.selenium.get_eval("window.document.getElementById('field_my_text_content').value")
#assert text content is present
self.failUnless('<b>Functional UNG Test</b>' in web_page_content)
self.failUnless('<p style="margin-bottom: 0in; font-weight: normal;">'
'Sample text document created in order to test some UNG features.'
'</p>' in web_page_content)
#assert image content is present
self.failUnless('<img align="LEFT" width="122" height="30" border="0"'
' name="ung_docs-logo" src="image_module/' in web_page_content)
def test_select_xinha_as_preferred_text_editor(self):
"""test that its possible to select Xinha instead of FCKeditor
for Edit Text Documents on UNG Docs."""
#assert Xinha Editor is shown as an option
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name='field_my_preferred_text_editor']\")", "3000")
self.failUnless(self.selenium.is_text_present("Text Format"))
self.failUnless(self.selenium.is_text_present("Xinha Editor"))
#select Xinha Editor as Preferred Text Editor
self.selenium.check("//input[@value='xinha']")
self.selenium.check("//input[@value='text/html']")
#save settings
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
#assert settings were saved
self.selenium.open("WebSite_logout")
self.login_as_default_user()
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name='field_my_preferred_text_editor']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value='xinha']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value='text/html']@checked"))
def test_fill_content_on_web_page_with_xinha_editor(self):
"""test the possibility to edit a Web Page document using
Xinha Text Editor"""
#select Xinha as Text Editor
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name='field_my_preferred_text_editor']\")", "3000")
self.selenium.check("//input[@value='xinha']")
self.selenium.check("//input[@value='text/html']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
#add new web_page
test_time = int(unittest.time.time())
self.create_document('page', name='Functional UNG Test %d - Web Page using Xinha' % test_time)
#activate Xinha Editor
self.selenium.click("//textarea[@id='my_text_content']")
#type text
self.selenium.select_frame("//iframe[@id='XinhaIFrame_my_text_content']")
web_page_content = """<p><strong>Chapter 1</strong></p> \n <p>&nbsp;Sample Text</p>"""
self.selenium.type("//body", web_page_content)
self.selenium.select_window("null")
#save Web Page
self.selenium.click("//button[@name='Base_edit:method']")
self.selenium.wait_for_page_to_load("30000")
#wait for activities
self.wait_for_activities()
#assert text was typed
self.assertEqual(web_page_content, self.selenium.get_eval("window.document.getElementById('my_text_content').value"))
#go back to home page
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
#go back to the created Web Page (the last one modified on the list)
self.selenium.click("//tr[@class='your_listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
#assert text is the same
self.selenium.wait_for_condition("selenium.browserbot.getCurrentWindow().document.getElementById('my_text_content')", "5000")
self.assertEqual(web_page_content, self.selenium.get_eval("window.document.getElementById('my_text_content').value"))
self.selenium.select_window("null")
if __name__ == "__main__":
unittest.main()
from UNGTestMixin import UNGTestMixin
import unittest
import re
class TestUNGGadgets(UNGTestMixin):
"""tests related to gadgets on UNG"""
def test_add_and_delete_gadget(self):
"""test:
- default gadget message is show when no gadgets are present
- add gadget
- delete gadget
"""
self.failUnless(self.selenium.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.assertEqual("Add gadgets", self.selenium.get_text("//a[@id=\"add-gadgets\"]/span"))
self.failIf(self.selenium.is_text_present("Join ERP5 Network !"))
self.failIf(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.failUnless(self.selenium.is_text_present("Add Gadget"))
self.selenium.click("//input[@id=\"erp5_documentation\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.failUnless(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
self.failIf(self.selenium.is_element_present("//div[@id=\"page_wrapper\"]/div[1]/h4"))
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.wait_for_activities()
self.selenium.open("")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Add gadgets", self.selenium.get_text("//a[@id=\"add-gadgets\"]/span"))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Feed Reader", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
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.wait_for_activities()
self.selenium.open("")
self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
def test_add_two_gadgets(self):
"""test that its possible to add more than just 1 gadget"""
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_documentation\"]")
self.selenium.click("//input[@id=\"erp5_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Feed Reader", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.click("//div[@id=\"portal-column-0\"]/div[1]/h3/span/a[@title=\"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.wait_for_activities()
self.selenium.open("")
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.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
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.wait_for_activities()
self.selenium.open("?reset:int=1")
self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
def test_add_gadget_on_different_users(self):
"""test that different users have different gadgets"""
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_documentation\"]")
self.selenium.click("//input[@id=\"erp5_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.wait_for_activities()
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
#XXX user already created
# self.selenium.click("//td[@id=\"new-account-form\"]")
# self.selenium.type("//input[@name=\"firstname\"]", "Another")
# self.selenium.type("//input[@name=\"lastname\"]", "User")
# self.selenium.type("//input[@name=\"email\"]", "example2@example.com")
# self.selenium.type("//input[@name=\"login_name\"]", "ung_user2")
# self.selenium.type("//input[@name=\"password\"]", "1234")
# self.selenium.type("//input[@name=\"confirm\"]", "1234")
# self.selenium.click("//input[@value=\"Create Account\"]")
# self.selenium.wait_for_page_to_load("30000")
self.selenium.type("__ac_name", "ung_user2")
self.selenium.type("__ac_password", "1234")
self.selenium.click("//input[@type=\"submit\"]")
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.failIf(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_worklists\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.login_as_default_user()
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.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.selenium.type("__ac_name", "zope")
self.selenium.type("__ac_password", "zope")
self.selenium.click("//input[@type=\"submit\"]")
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.selenium.click("//a[@id=\"add-gadgets\"]")
self.selenium.click("//input[@id=\"erp5_worklists\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", self.selenium.get_text("//span[@class=\"gadget_title\"]"))
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.wait_for_activities()
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.login_as_default_user()
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.failUnless(self.selenium.is_text_present("Join ERP5 Network !"))
#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__":
unittest.main()
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGLogin(UNGTestMixin):
"""tests related to login on UNG"""
def test_login(self):
"""try to login as different users"""
self.selenium.open("WebSite_logout")
self.login_as_default_user()
#XXX bug because All Documents is not selected by default (it's saving "cache")
self.set_default_tree_view()
self.assertEqual("All Documents", self.selenium.get_text("//button[@class='tree-open']"))
self.assertEqual("Settings", self.selenium.get_text("//a[@id='settings']"))
self.failUnless(self.selenium.is_text_present("Web Illustration"))
self.failUnless(self.selenium.is_text_present("Web Page"))
self.failUnless(self.selenium.is_text_present("Web Table"))
#XXX: the user used on test's instance is 'nsi'
self.failUnless(self.selenium.is_text_present("test_user"))
self.selenium.click("link=Sign out")
self.selenium.wait_for_page_to_load(5000)
self.failUnless(self.selenium.is_text_present("Welcome to UNG Web Office"))
self.failUnless(self.selenium.is_text_present("Create an account now"))
self.selenium.click("//td[@id='new-account-form']")
self.selenium.click("//td[@id='back-login']")
#XXX: user is not created and, by orders, can't be created
#<tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/create-user" />
self.selenium.type("__ac_name", "ung_user2")
self.selenium.type("__ac_password", "1234")
self.selenium.click("//input[@type='submit']")
self.selenium.wait_for_page_to_load(5000)
self.assertEqual("ung_user2", self.selenium.get_text("//div[@class=\' navigation-right\']/fieldset/div[2]/div/div/a[2]"))
if __name__ == "__main__":
unittest.main()
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGSettings(UNGTestMixin):
"""tests related to UNG settings"""
def test_saving_settings_even_on_different_users(self):
"""test that:
- settings are correct displayed
- settings remain saved
- different users have different settings
"""
self.failIf(self.selenium.is_text_present('Text Format'))
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.failUnless(self.selenium.is_text_present("Text Format"))
self.failUnless(self.selenium.is_text_present("FCK Editor"))
self.selenium.check("//input[@value=\'fck_editor\']")
self.selenium.check("//input[@value=\'text/html\']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'fck_editor\']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text/html\']@checked"))
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.check("//input[@value=\'text_area\']")
self.selenium.check("//input[@value=\'text/plain\']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text/plain\']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text_area\']@checked"))
self.selenium.click("//span[@class=\'ui-icon ui-icon-closethick\']")
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load(5000)
#don't try to create a new user since
#test's instance already have one with login_name 'ung_user2'
#XXX this is not correct, because it has to be created once a time
# next ones, just login
## self.selenium.click("//td[@id='new-account-form']")
# # self.selenium.type("//input[@name='firstname']", "Another")
# sel#.type("//input[@name='lastname']", "User")
# self.selenium.type(#"//input[@name='email']", "example2@example.com")
# # self.selenium.type("//input[@name='login_name']", "ung_use#r2")
# self.selenium.type("//input[@name='password']", "1#234")
# self.selenium.type("//input[@name='confirm']", "1234")
# self.selenium.click("//input[@value='Create Account']")
# self.selenium.wait_for_page_to_load(30000)
self.selenium.type("__ac_name", "ung_user2")
self.selenium.type("__ac_password", "1234")
self.selenium.click("//input[@type='submit']")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.check("//input[@value=\'fck_editor\']")
self.selenium.check("//input[@value=\'text/html\']")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.check("//input[@value=\'fck_editor\']")
self.selenium.check("//input[@value=\'text/html\']")
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.selenium.click("//html/body/div[3]/div[11]/div/button[1]")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'fck_editor\']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text/html\']@checked"))
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load(5000)
self.selenium.type("__ac_name", "test_user")
self.selenium.type("__ac_password", "test_user")
self.selenium.click("//input[@type='submit']")
self.selenium.wait_for_page_to_load(5000)
self.selenium.click("//a[@id='settings']")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text_area\']@checked"))
self.assertEqual(u'true', self.selenium.get_attribute("//input[@value=\'text/plain\']@checked"))
if __name__ == "__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