Commit 87e28097 authored by Gabriel L. Oliveira's avatar Gabriel L. Oliveira

Move test files to correct location

parent 356f6fd3
import unittest
from selenium import selenium
import urllib2
import os
ERP5_URL = "http://localhost:18080/erp5/"
ERP5_ACTIVITIES_URL = ERP5_URL + \
'portal_activities/getMessageList?include_processing=1'
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.selenium.open('')
self.selenium.wait_for_page_to_load(30000)
self.login_as_default_user()
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
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 was 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'"""
self.wait_ung_listbox_to_load()
if not self.selenium.is_element_present("//button[@class='tree-open']"):
self.selenium.click("//table[@class='listbox-table-domain-tree']/tbody/tr[1]/td/button")
self.selenium.wait_for_page_to_load("30000")
elif not "All Documents" == self.selenium.get_text("//button[@class='tree-open']"):
self.selenium.click("//table[@class='listbox-table-domain-tree']/tbody/tr[1]/td/button")
self.selenium.wait_for_page_to_load("30000")
def wait_ung_listbox_to_load(self, waiting_time="30000"):
"""wait until UNG listbox is fully loaded"""
self.selenium.wait_for_condition("selenium.isElementPresent(\""
"//table[@class='listbox-table-domain-tree']\")",
waiting_time)
self.selenium.wait_for_condition("selenium.browserbot"
".getCurrentWindow().$('#knowledge_pad_module_ung_knowledge_pad"
"_ung_docs_listbox_content').css('opacity') == '1'",
waiting_time)
def wait_ung_calendar_to_load(self, waiting_time="30000"):
"""wait until UNG calendar is fully loaded"""
self.selenium.wait_for_condition("selenium.browserbot"
".findElementOrNull('loadingpannel').style.display == 'none'",
waiting_time)
def wait_add_gadgets_dialog_to_load(self, waiting_time="30000"):
"""wait until UNG gadgets dialog is fully loaded"""
self.selenium.wait_for_condition("selenium.browserbot"
".getCurrentWindow().$('div.gadget-listbox table#gadget-table')"
".children().length > 0",
waiting_time)
def clear_user_gadgets(self, user=None, password=None):
"""remove all gadgets from given user
if no user is given, then just remove all gadgets"""
if user:
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.selenium.type("__ac_name", user)
self.selenium.type("__ac_password", password)
self.selenium.click("//input[@value='Login']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
while self.selenium.is_element_present("//a[@class='clickable-block"
" block-remove']"):
self.selenium.click("//a[@class=\"clickable-block block-remove\"]")
self.selenium.get_confirmation()
self.open_ung_default_page('ung')
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_ACTIVITIES_URL)
for _try in range(60):
message_queue = activities.readlines()
if not message_queue:
break
#give time to selenium to recompose page when refresh
unittest.time.sleep(2)
def open_ung_default_page(self, page='ung', 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 == 'ung':
self.wait_ung_listbox_to_load()
elif page == "calendar":
self.wait_ung_calendar_to_load()
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, keywords=None,
wait_for_activities=True, **kw):
"""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")
if keywords or kw:
self.rename_document(keywords=keywords,
wait_for_activities=wait_for_activities, **kw)
elif wait_for_activities:
self.wait_for_activities()
return self.selenium.get_eval("selenium.browserbot."
"getCurrentWindow().location").split('?')[0]
def rename_document(self, url=None, keywords=None, stop_try=False,
wait_for_activities=True, **kw):
"""Change document attributes. At the end, check if rename was
successfull and, if not, repeat steps.
url - visit url of document, case given
keywords - list of keywords to put under keyword_list
**kw - dict of locator:value to type as document attributes"""
if url:
self.selenium.open(url)
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name='document_title']")
self.selenium.click("//p[@id='more_properties']")
for locator, value in kw.items():
self.selenium.type(locator, value)
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")
if wait_for_activities:
self.wait_for_activities()
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.wait_ung_calendar_to_load()
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.wait_ung_calendar_to_load()
if self.selenium.is_text_present(name):
break
else:
unittest.time.sleep(2)
if __name__ == "__main__":
unittest.main()
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGCalendar(UNGTestMixin):
""" Tests related to UNG Calendar
"""
def test_simple_add_of_two_note_events(self):
"""
- Test that shortcut buttons 'Month View' and 'Day View' exists.
- Search for events, and assert that no event was found with correct
message.
- Add 2 events, both of type 'Note'.
- Search for events, and assert that events were found with correct
message.
- Search by pressing key 'Enter' (code \13)
"""
test_subject_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Refresh", self.selenium.get_text(
"//span[@class='showdayflash']"))
self.assertEqual("Su", self.selenium.get_text(
"//span[@title='Sunday']"))
self.selenium.click("//span[@class='showmonthview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull"
"('loadingpannel').style.display == 'none'",
"10000");
self.selenium.click("//span[@class='showdayview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.type("//input[@name='searchable-text']", "My Event %d" % test_subject_time)
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//div[@id=\"blank-result\"]')", "1000")
self.assertEqual("Results: 0 to My Event %d" % test_subject_time, self.selenium.get_text("//td[@id=\"resultview\"]"))
self.failUnless(self.selenium.is_text_present("No Results"))
self.selenium.click("//a[@id=\"back-calendar\"]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
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\"]", "Note")
self.selenium.type("//input[@name=\"title\"]", "My Event %d" % test_subject_time)
self.selenium.type("//textarea[@name=\"event_text_content\"]", "Text of Event")
self.selenium.type("//input[@name=\"start_date_hour\"]", unittest.time.localtime().tm_hour + 1)
self.selenium.type("//input[@name=\"stop_date_hour\"]", unittest.time.localtime().tm_hour + 1)
self.selenium.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
#XXX handle this behaviour differently: wait_for_activities is called
# twice because sometimes its passing through method even with some
# remaining activities
self.wait_for_activities()
self.clear_cache()
self.wait_for_activities()
self.open_ung_default_page("calendar")
self.selenium.wait_for_condition("selenium.isTextPresent('My Event %d')" % test_subject_time, "10000")
self.failUnless(self.selenium.is_text_present("My Event %d" % test_subject_time))
self.selenium.type("//input[@name='searchable-text']", "My Event %d" % test_subject_time)
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//span[@class=\"addcal\"]")
self.selenium.wait_for_condition("selenium.isElementPresent(\"portal_type\")", "10000")
self.selenium.select("//select[@name=\"portal_type\"]", "Note")
self.selenium.type("//input[@name=\"title\"]", "My Second Event %d" % test_subject_time)
self.selenium.type("//textarea[@name=\"event_text_content\"]", "Second Event")
self.selenium.type("//input[@name=\"start_date_hour\"]", unittest.time.localtime().tm_hour + 1)
self.selenium.type("//input[@name=\"stop_date_hour\"]", unittest.time.localtime().tm_hour + 1)
self.selenium.key_press("//input[@name=\"stop_date_hour\"]", "\\13")
self.wait_for_activities()
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.type("//input[@name='searchable-text']", "My Second Event %d" % test_subject_time)
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "2000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.selenium.type("//input[@name='searchable-text']", "My Second Event %d" % test_subject_time)
self.selenium.key_press("//input[@name='searchable-text']", "\\13")
self.failIf(self.selenium.is_text_present("No Results"))
def test_add_new_acknowledgement_event(self):
"""check the action of add a new event of type 'Acknowledgement'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Acknowledgement'
event_name = 'Functional UNG Test %d - My Acknowledgement' % test_time
self.create_calendar_event('Acknowledgement', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_fax_message_event(self):
"""check the action of add a new event of type 'Fax Message'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Fax Message'
event_name = 'Functional UNG Test %d - My Fax Message' % test_time
self.create_calendar_event('Fax Message', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_letter_event(self):
"""check the action of add a new event of type 'Letter'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Letter'
event_name = 'Functional UNG Test %d - My Letter' % test_time
self.create_calendar_event('Letter', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_mail_message_event(self):
"""check the action of add a new event of type 'Mail Message'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Mail Message'
event_name = 'Functional UNG Test %d - My Mail Message' % test_time
self.create_calendar_event('Mail Message', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_note_event(self):
"""check the action of add a new event of type 'Note'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Note'
event_name = 'Functional UNG Test %d - My Note' % test_time
self.create_calendar_event('Note', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.failUnless(self.selenium.is_text_present(event_name))
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_phone_call_event(self):
"""check the action of add a new event of type 'Phone Call'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Phone Call'
event_name = 'Functional UNG Test %d - My Phone Call' % test_time
self.create_calendar_event('Phone Call', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.failUnless(self.selenium.is_text_present(event_name))
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_short_message_event(self):
"""check the action of add a new event of type 'Short Message'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Short Message'
event_name = 'Functional UNG Test %d - My Short Message' % test_time
self.create_calendar_event('Short Message', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.failUnless(self.selenium.is_text_present(event_name))
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_site_message_event(self):
"""check the action of add a new event of type 'Site Message'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Site Message'
event_name = 'Functional UNG Test %d - My Site Message' % test_time
self.create_calendar_event('Site Message', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.failUnless(self.selenium.is_text_present(event_name))
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_visit_event(self):
"""check the action of add a new event of type 'Visit'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Visit'
event_name = 'Functional UNG Test %d - My Visit' % test_time
self.create_calendar_event('Visit', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.failUnless(self.selenium.is_text_present(event_name))
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_add_new_web_message_event(self):
"""check the action of add a new event of type 'Web Message'"""
test_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#create event of type 'Web Message'
event_name = 'Functional UNG Test %d - My Web Message' % test_time
self.create_calendar_event('Web Message', name=event_name)
#assert event was created successfully
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
#XXX due to interface delay
#try 5 times to see new event under interface
for _try in range(5):
try:
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.failUnless(self.selenium.is_text_present(event_name))
if self.selenium.is_text_present(event_name):
break
except:
pass
self.failUnless(self.selenium.is_text_present(event_name))
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(self.selenium.is_element_present("//td[@id=\"event-date\"]"))
self.failIf(self.selenium.is_text_present("No Results"))
self.assertEqual(event_name, self.selenium.get_text("//div[@class='event-listview']/table/tbody/tr/td[3]"))
def test_modify_day_month_year_of_event(self):
"""test to verify that changing day, month or year of an event
will update it"""
test_time = int(unittest.time.time())
#create an event
self.open_ung_default_page("calendar")
#create event of type 'Visit'
event_name = 'Functional UNG Test %d - My Event' % test_time
self.create_calendar_event('Note', name=event_name)
#assert event object is displayed
self.selenium.is_element_present("//div[contains(@title,'Title:%s')]" % event_name)
#change day of event
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
#XXX due to limitation of days in a month
old_event_start_day = int(self.selenium.get_value("start_date_day"))
new_event_start_day = old_event_start_day > 26 and 1 or old_event_start_day + 1
old_event_stop_day = int(self.selenium.get_value("stop_date_day"))
new_event_stop_day = old_event_stop_day > 26 and 1 or old_event_stop_day + 1
self.selenium.type("start_date_day", new_event_start_day)
self.selenium.type("stop_date_day", new_event_stop_day)
self.selenium.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
self.open_ung_default_page("calendar", clear_cache=1, wait_for_activities=1)
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#"surf" to the event
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "10000")
self.selenium.click("//td[@id='event-date']")
#check new start and stop days on event
self.selenium.wait_for_condition("selenium.isElementPresent('//div[contains(@title,\"Title:%s\")]')" % event_name, "10000")
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
self.assertEqual(new_event_start_day, int(self.selenium.get_value("start_date_day")))
self.assertEqual(new_event_stop_day, int(self.selenium.get_value("stop_date_day")))
self.selenium.click("//a[@class='ui-dialog-titlebar-close ui-corner-all']")
#change month of event
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
#XXX due to limitation of months in a year
old_event_start_month = int(self.selenium.get_value("start_date_month"))
new_event_start_month = old_event_start_month > 11 and 1 or old_event_start_month + 1
old_event_stop_month = int(self.selenium.get_value("stop_date_month"))
new_event_stop_month = old_event_stop_month > 11 and 1 or old_event_stop_month + 1
self.selenium.type("start_date_month", new_event_start_month)
self.selenium.type("stop_date_month", new_event_stop_month)
self.selenium.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
self.open_ung_default_page("calendar", clear_cache=1, wait_for_activities=1)
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#"surf" to the event
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "10000")
self.selenium.click("//td[@id='event-date']")
#check new start and stop months on event
self.selenium.wait_for_condition("selenium.isElementPresent('//div[contains(@title,\"Title:%s\")]')" % event_name, "10000")
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
self.assertEqual(new_event_start_month, int(self.selenium.get_value("start_date_month")))
self.assertEqual(new_event_stop_month, int(self.selenium.get_value("stop_date_month")))
self.selenium.click("//a[@class='ui-dialog-titlebar-close ui-corner-all']")
#change year of event
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
old_event_start_year = int(self.selenium.get_value("start_date_year"))
new_event_start_year = old_event_start_year + 1
old_event_stop_year = int(self.selenium.get_value("stop_date_year"))
new_event_stop_year = old_event_stop_year + 1
self.selenium.type("start_date_year", new_event_start_year)
self.selenium.type("stop_date_year", new_event_stop_year)
self.selenium.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
self.open_ung_default_page("calendar", clear_cache=1, wait_for_activities=1)
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#"surf" to the event
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "10000")
self.selenium.click("//td[@id='event-date']")
#check new start and stop years on event
self.selenium.wait_for_condition("selenium.isElementPresent('//div[contains(@title,\"Title:%s\")]')" % event_name, "10000")
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
self.assertEqual(new_event_start_year, int(self.selenium.get_value("start_date_year")))
self.assertEqual(new_event_stop_year, int(self.selenium.get_value("stop_date_year")))
self.selenium.click("//a[@class='ui-dialog-titlebar-close ui-corner-all']")
def test_create_multiple_events_by_click(self):
"""test possibility to create multiple events by just clicking
on UNG Calendar interface"""
self.open_ung_default_page("calendar")
#create 4 events, each one on its specific 'day-column'
test_time = int(unittest.time.time())
event_name = "Functional UNG Test %d - Event %d"
for event_index in range(1, 5):
self.selenium.click_at("//div[@id='tgCol%d' and @class='tg-col-eventwrapper']" % event_index, (1,1))
self.selenium.type("//input[@id='bbit-cal-what']", event_name % (test_time, event_index))
self.selenium.click("//input[@id='bbit-cal-quickAddBTN']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.wait_for_activities()
self.open_ung_default_page('calendar', clear_cache=1, wait_for_activities=1)
#assert events are present
for event_index in range(1, 5):
self.assertTrue(self.selenium.is_text_present(event_name % (test_time, event_index)))
def test_check_calendar_buttons(self):
"""Test if the buttons Month, Day, Week shows the appropriate calendar
including the date range at calendar bar (near by previous/next
period arrows)."""
#XXX this test needs an empty instance
# due to the button 'other#' under month view, when there are many
# events do be displayed in just one day
self.open_ung_default_page("calendar")
test_time = int(unittest.time.time())
#create 4 events:
# 2 on same day, and another on same week
# last one on next week
event_name = "Functional UNG %d - Event %d"
dates = [(9, 13), (9, 13), (9, 16), (9, 20)]
for event_index, (month, day) in enumerate(dates):
self.create_calendar_event('Note',
event_name % (test_time, event_index),
start_month = month, start_day = day,
start_year=2011,
do_refresh=False)
#select month view
self.selenium.click("//span[@class='showmonthview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue('fcurrent' in self.selenium.get_attribute("//div[@id='showmonthbtn']@class"))
#select month 9/2011 (month starts at 0)
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2011, 8, 13)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#wait due to interface delay
unittest.time.sleep(2)
#update page
self.selenium.click("//span[@class='showmonthview']")
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#XXX due to interface delay again, try two times
# on second, sleeping 3 seconds before refreshing page again
#XXX: this part needs the 'Other##' workaround when many events are present
try:
for event_index in range(len(dates)):
self.assertTrue(self.selenium.is_text_present(event_name % (test_time, event_index)))
except:
unittest.time.sleep(3)
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
for event_index in range(len(dates)):
self.assertTrue(self.selenium.is_text_present(event_name % (test_time, event_index)))
#assert date displayed
self.assertEqual('Aug 28 2011 - Oct 1', self.selenium.get_text("//div[@id='display-datetime']"))
#select week view
self.selenium.click("//span[@class='showweekview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue('fcurrent' in self.selenium.get_attribute("//div[@id='showweekbtn']@class"))
#select day 09/13/2011 (month starts at 0)
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2011, 8, 13)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#assert just the 3 events from days 13 and 16 are present
for event_index in range(3):
self.assertTrue(self.selenium.is_text_present(event_name % (test_time, event_index)))
#assert fourth event (event number 3, starting from 0) is not present
self.assertFalse(self.selenium.is_text_present(event_name % (test_time, 3)))
#assert date displayed
self.assertEqual('Sep 11 2011 - Sep 17', self.selenium.get_text("//div[@id='display-datetime']"))
#select day view
self.selenium.click("//span[@class='showdayview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue('fcurrent' in self.selenium.get_attribute("//div[@id='showdaybtn']@class"))
#select day 09/13/2011 (month starts at 0)
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2011, 8, 13)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#assert just the 2 events from day 13 are present
for event_index in range(2):
self.assertTrue(self.selenium.is_text_present(event_name % (test_time, event_index)))
#assert third and fourth event (event number 2 and 3, starting from 0)
# are not present
for event_index in range(2, 4):
self.assertFalse(self.selenium.is_text_present(event_name % (test_time, event_index)))
#assert date displayed
self.assertEqual('Sep 13 2011', self.selenium.get_text("//div[@id='display-datetime']"))
def test_refresh_button_should_not_multiplicate_event(self):
"""test that 'Refresh' button doesn't multiplicate an event that was
just created"""
self.open_ung_default_page("calendar")
#create event
test_time = int(unittest.time.time())
event_name = "Functional UNG Test %d - An Event" % test_time
self.selenium.click_at("//div[@id='tgCol1' and @class='tg-col-eventwrapper']", (1,1))
self.selenium.type("//input[@id='bbit-cal-what']", event_name)
self.selenium.click("//input[@id='bbit-cal-quickAddBTN']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.open_ung_default_page('calendar', clear_cache=1, wait_for_activities=1)
#assert event is present
self.assertTrue(self.selenium.is_text_present(event_name))
#click refresh button 10 times
for _refresh in range(10):
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#assert only 1 event is present
self.assertEqual(1, self.selenium.get_xpath_count("//div[contains(@title,'Title:%s')]" % event_name))
def test_edit_event(self):
"""test edit and event, including change the portal types"""
test_time = int(unittest.time.time())
self.open_ung_default_page('calendar')
#create event with specific properties
event_name = "Functional UNG Test %d - A Note" % test_time
event_type = 'Note'
event_kw = {"start_month" : 01,
"end_month" : 01,
"start_day" : 01,
"end_day" : 01,
"start_year" : 2011,
"end_year" : 2011,
"start_hour" : 01,
"end_hour" : 01,
"start_minute" : 01,
"end_minute" : 01}
self.create_calendar_event(event_type, event_name, do_refresh=False, **event_kw)
self.open_ung_default_page("calendar", clear_cache=1, wait_for_activities=1)
#XXX due to either a bug on javascript that doesn't allow to search
# or delay on creation of document
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2011, 00, 01)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#assert event properties
self.assertTrue(self.selenium.is_text_present(event_name))
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
self.assertEqual(event_type, self.selenium.get_selected_value("//select[@name=\"portal_type\"]"))
self.assertEqual(event_name, self.selenium.get_value("//input[@name=\"title\"]"))
self.assertEqual(event_kw["start_month"], int(self.selenium.get_value("start_date_month")))
self.assertEqual(event_kw["end_month"], int(self.selenium.get_value("stop_date_month")))
self.assertEqual(event_kw["start_day"], int(self.selenium.get_value("start_date_day")))
self.assertEqual(event_kw["end_day"], int(self.selenium.get_value("stop_date_day")))
self.assertEqual(event_kw["start_year"], int(self.selenium.get_value("start_date_year")))
self.assertEqual(event_kw["end_year"], int(self.selenium.get_value("stop_date_year")))
self.assertEqual(event_kw["start_hour"], int(self.selenium.get_value("start_date_hour")))
self.assertEqual(event_kw["end_hour"], int(self.selenium.get_value("stop_date_hour")))
self.assertEqual(event_kw["start_minute"], int(self.selenium.get_value("start_date_minute")))
self.assertEqual(event_kw["end_minute"], int(self.selenium.get_value("stop_date_minute")))
#change event properties
for key, value in event_kw.items():
event_kw[key] = event_kw[key] + 2
event_type = 'Letter'
event_name = "Functional UNG Test %d - A Letter" % test_time
self.selenium.select("//select[@name=\"portal_type\"]", event_type)
self.selenium.type("//input[@name=\"title\"]", event_name)
self.selenium.type("start_date_month", event_kw["start_month"])
self.selenium.type("stop_date_month", event_kw["end_month"])
self.selenium.type("start_date_day", event_kw["start_day"])
self.selenium.type("stop_date_day", event_kw["end_day"])
self.selenium.type("start_date_year", event_kw["start_year"])
self.selenium.type("stop_date_year", event_kw["end_year"])
self.selenium.type("start_date_hour", event_kw["start_hour"])
self.selenium.type("stop_date_hour", event_kw["end_hour"])
self.selenium.type("start_date_minute", event_kw["start_minute"])
self.selenium.type("stop_date_minute", event_kw["end_minute"])
self.selenium.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
self.wait_for_activities()
self.open_ung_default_page("calendar", clear_cache=1, wait_for_activities=1)
#XXX due to page delay
unittest.time.sleep(1)
#XXX this time search is possible
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "10000")
self.selenium.click("//td[@id=\"event-date\"]")
self.selenium.wait_for_condition("selenium.isTextPresent(\"%s\")" % event_name, "10000")
#assert new event properties
self.assertTrue(self.selenium.is_text_present(event_name))
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
self.assertEqual(event_type, self.selenium.get_selected_value("//select[@name=\"portal_type\"]"))
self.assertEqual(event_name, self.selenium.get_value("//input[@name=\"title\"]"))
self.assertEqual(event_kw["start_month"], int(self.selenium.get_value("start_date_month")))
self.assertEqual(event_kw["end_month"], int(self.selenium.get_value("stop_date_month")))
self.assertEqual(event_kw["start_day"], int(self.selenium.get_value("start_date_day")))
self.assertEqual(event_kw["end_day"], int(self.selenium.get_value("stop_date_day")))
self.assertEqual(event_kw["start_year"], int(self.selenium.get_value("start_date_year")))
self.assertEqual(event_kw["end_year"], int(self.selenium.get_value("stop_date_year")))
self.assertEqual(event_kw["start_hour"], int(self.selenium.get_value("start_date_hour")))
self.assertEqual(event_kw["end_hour"], int(self.selenium.get_value("stop_date_hour")))
self.assertEqual(event_kw["start_minute"], int(self.selenium.get_value("start_date_minute")))
self.assertEqual(event_kw["end_minute"], int(self.selenium.get_value("stop_date_minute")))
self.selenium.click("//a[@class='ui-dialog-titlebar-close ui-corner-all']")
def test_edit_event_with_long_duration(self):
"""test edit an event with a long duration,
including change the portal types"""
test_time = int(unittest.time.time())
self.open_ung_default_page('calendar')
#create event with specific properties
event_name = "Functional UNG Test %d - A Note" % test_time
event_type = 'Note'
localtime = unittest.time.localtime()
event_kw = {"start_month" : 01,
"end_month" : 02,
"start_day" : 01,
"end_day" : 02,
"start_year" : 2011,
"end_year" : 2012,
"start_hour" : 01,
"end_hour" : 02,
"start_minute" : 01,
"end_minute" : 02}
self.create_calendar_event(event_type, event_name, do_refresh=False, **event_kw)
self.open_ung_default_page("calendar", clear_cache=1, wait_for_activities=1)
#XXX due to either a bug on javascript that doesn't allow to search
# or delay on creation of document
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2011, 01, 01)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#assert event properties
self.assertTrue(self.selenium.is_text_present(event_name))
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
self.assertEqual(event_type, self.selenium.get_selected_value("//select[@name=\"portal_type\"]"))
self.assertEqual(event_name, self.selenium.get_value("//input[@name=\"title\"]"))
self.assertEqual(event_kw["start_month"], int(self.selenium.get_value("start_date_month")))
self.assertEqual(event_kw["end_month"], int(self.selenium.get_value("stop_date_month")))
self.assertEqual(event_kw["start_day"], int(self.selenium.get_value("start_date_day")))
self.assertEqual(event_kw["end_day"], int(self.selenium.get_value("stop_date_day")))
self.assertEqual(event_kw["start_year"], int(self.selenium.get_value("start_date_year")))
self.assertEqual(event_kw["end_year"], int(self.selenium.get_value("stop_date_year")))
self.assertEqual(event_kw["start_hour"], int(self.selenium.get_value("start_date_hour")))
self.assertEqual(event_kw["end_hour"], int(self.selenium.get_value("stop_date_hour")))
self.assertEqual(event_kw["start_minute"], int(self.selenium.get_value("start_date_minute")))
self.assertEqual(event_kw["end_minute"], int(self.selenium.get_value("stop_date_minute")))
#change event properties
for key, value in event_kw.items():
event_kw[key] = event_kw[key] + 3
event_type = 'Letter'
event_name = "Functional UNG Test %d - A Letter" % test_time
self.selenium.select("//select[@name=\"portal_type\"]", event_type)
self.selenium.type("//input[@name=\"title\"]", event_name)
self.selenium.type("start_date_month", event_kw["start_month"])
self.selenium.type("stop_date_month", event_kw["end_month"])
self.selenium.type("start_date_day", event_kw["start_day"])
self.selenium.type("stop_date_day", event_kw["end_day"])
self.selenium.type("start_date_year", event_kw["start_year"])
self.selenium.type("stop_date_year", event_kw["end_year"])
self.selenium.type("start_date_hour", event_kw["start_hour"])
self.selenium.type("stop_date_hour", event_kw["end_hour"])
self.selenium.type("start_date_minute", event_kw["start_minute"])
self.selenium.type("stop_date_minute", event_kw["end_minute"])
self.selenium.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
self.wait_for_activities()
self.open_ung_default_page("calendar", clear_cache=1, wait_for_activities=1)
#XXX due to page delay
unittest.time.sleep(1)
self.selenium.type("//input[@name='searchable-text']", '\"' + event_name + '\"')
self.selenium.click("//input[@id='submit-search']")
self.selenium.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.selenium.click("//td[@id=\"event-date\"]")
self.selenium.wait_for_condition("selenium.isTextPresent(\"%s\")" % event_name, "10000")
#assert new event properties
self.assertTrue(self.selenium.is_text_present(event_name))
self.selenium.click("//div[contains(@title,'Title:%s')]" % event_name)
self.selenium.click("//span[@id='bbit-cs-editLink']")
self.assertEqual(event_type, self.selenium.get_selected_value("//select[@name=\"portal_type\"]"))
self.assertEqual(event_name, self.selenium.get_value("//input[@name=\"title\"]"))
self.assertEqual(event_kw["start_month"], int(self.selenium.get_value("start_date_month")))
self.assertEqual(event_kw["end_month"], int(self.selenium.get_value("stop_date_month")))
self.assertEqual(event_kw["start_day"], int(self.selenium.get_value("start_date_day")))
self.assertEqual(event_kw["end_day"], int(self.selenium.get_value("stop_date_day")))
self.assertEqual(event_kw["start_year"], int(self.selenium.get_value("start_date_year")))
self.assertEqual(event_kw["end_year"], int(self.selenium.get_value("stop_date_year")))
self.assertEqual(event_kw["start_hour"], int(self.selenium.get_value("start_date_hour")))
self.assertEqual(event_kw["end_hour"], int(self.selenium.get_value("stop_date_hour")))
self.assertEqual(event_kw["start_minute"], int(self.selenium.get_value("start_date_minute")))
self.assertEqual(event_kw["end_minute"], int(self.selenium.get_value("stop_date_minute")))
self.selenium.click("//a[@class='ui-dialog-titlebar-close ui-corner-all']")
def test_current_day_different_color(self):
"""test for UNG Calendar current day color.
On Month and Week view, UNG Calendar defines diferent colors to current
day. Include a test for left top bar of Month view, where the current day
is also maked (as blue)."""
#prepare date
current_month = str(unittest.time.localtime().tm_mon)
current_day = str(unittest.time.localtime().tm_mday)
current_year = str(unittest.time.localtime().tm_year)
current_date = '/'.join([current_month, current_day, current_year])
self.open_ung_default_page("calendar")
#test color for current day on week view
self.selenium.click("//span[@class='showweekview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
date_marked = self.selenium.get_attribute("//td[div/@class='tg-today']@abbr")
self.assertEqual(current_date, date_marked)
#test color for current day on month view
self.selenium.click("//span[@class='showmonthview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
date_marked = self.selenium.get_attribute("//td[contains(@class,'st-bg-today')]@abbr")
self.assertEqual(current_date, date_marked)
#test color for left top bar of current day on month view
date_marked = self.selenium.get_attribute("//td[contains(@class,'st-dtitle-today')]@abbr")
self.assertEqual(current_date, date_marked)
def test_button_today_goes_to_current_day(self):
"""Check the button today shows current day.
Also checks the behaviour when using month, week and day views.
"""
test_time = int(unittest.time.time())
#prepare date
current_month = str(unittest.time.localtime().tm_mon)
current_day = str(unittest.time.localtime().tm_mday)
current_year = unittest.time.localtime().tm_year
current_date = '/'.join([current_month, current_day, str(current_year)])
self.open_ung_default_page("calendar")
#create an event for current date
event_name = "Functional UNG Test %d - Checking Today button" % test_time
self.create_calendar_event('Note', event_name,
start_month=current_month,
start_day=current_day,
start_year=current_year)
#check button for month view
#XXX this part needs an empty instance, due to 'group events' behaviour
# of interface when there are many events on a single day
self.selenium.click("//span[@class='showmonthview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#first, go to an year long time ago
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(%d, 00, 01)).BcalGetOp();" % (current_year - 10))
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#check current date is not displayed
self.assertFalse(self.selenium.is_text_present(event_name))
#click Today button
self.selenium.click("//span[@class='showtoday']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#in cases when there are many events on same day, the 'month' view
# group them, only showing them after clicking on 'Others##'
if self.selenium.is_element_present("//td[@abbr='%s'][@ch='more']" % current_date):
self.selenium.click("//td[@abbr='%s'][@ch='more']" % current_date)
self.selenium.wait_for_condition("selenium.isTextPresent('%s')" % event_name, 30000)
self.assertTrue(self.selenium.is_text_present(event_name))
#check button for week view
self.selenium.click("//span[@class='showweekview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#first, go to an year long time ago
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(%d, 00, 01)).BcalGetOp();" % (current_year - 10))
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#check current date is not displayed
self.assertFalse(self.selenium.is_text_present(event_name))
#click Today button
self.selenium.click("//span[@class='showtoday']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue(self.selenium.is_text_present(event_name))
#check button for day view
self.selenium.click("//span[@class='showdayview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#first, go to an year long time ago
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(%d, 00, 01)).BcalGetOp();" % (current_year - 10))
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#check current date is not displayed
self.assertFalse(self.selenium.is_text_present(event_name))
#click Today button
self.selenium.click("//span[@class='showtoday']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue(self.selenium.is_text_present(event_name))
def test_current_hour_mark(self):
"""Test that on Day and Week view, UNG Calendar defines a red line to
mark current time. """
#this calc is based on jquery.calendar.js, where there's a calc
# find correct position of red mark and set it on mark style attribute
def gP(h, m):
return h * 42 + int(float(m) / 60 * 42)
self.open_ung_default_page("calendar")
#test mark for week view
self.selenium.click("//span[@class='showweekview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#prepare time
current_hour = unittest.time.localtime().tm_hour
current_minute = unittest.time.localtime().tm_min
#assert mark is present
self.assertTrue(self.selenium.is_element_present("//div[@id='tgnowmarker']"))
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#find mark top distance
mark_style = self.selenium.get_attribute("//div[@id='tgnowmarker']@style")
mark_top_distance = int(mark_style.split(' ')[3][:-3]) #it ends with 'px;'
#assert mark top distance
correct_mark_top_distance = gP(current_hour, current_minute)
self.assertEqual(mark_top_distance, correct_mark_top_distance)
#test mark for day view
self.selenium.click("//span[@class='showweekview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#prepare time
current_hour = unittest.time.localtime().tm_hour
current_minute = unittest.time.localtime().tm_min
#assert mark is present
self.assertTrue(self.selenium.is_element_present("//div[@id='tgnowmarker']"))
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#find mark top distance
mark_style = self.selenium.get_attribute("//div[@id='tgnowmarker']@style")
mark_top_distance = int(mark_style.split(' ')[3][:-3]) #it ends with 'px;'
#assert mark top distance
correct_mark_top_distance = gP(current_hour, current_minute)
self.assertEqual(mark_top_distance, correct_mark_top_distance)
def test_event_with_long_date(self):
"""test events that happen in multiple days"""
test_time = int(unittest.time.time())
self.open_ung_default_page("calendar")
#create 2 events
# 2011 ---------------- 2012 ---------------- 2013
# ..........event1..........
# ..........event2..........
event1_name = "Functional UNG Test %d - Long Event 1" % test_time
event1_kw = {"start_month" : 01,
"end_month" : 12,
"start_day" : 01,
"end_day" : 31,
"start_year" : 2011,
"end_year" : 2012,
"start_hour" : 01,
"end_hour" : 23,
"start_minute" : 01,
"end_minute" : 59}
self.create_calendar_event('Visit', event1_name, do_refresh=False,
**event1_kw)
event2_name = "Functional UNG Test %d - Long Event 2" % test_time
event2_kw = {"start_month" : 01,
"end_month" : 12,
"start_day" : 01,
"end_day" : 31,
"start_year" : 2012,
"end_year" : 2013,
"start_hour" : 01,
"end_hour" : 23,
"start_minute" : 01,
"end_minute" : 59}
self.create_calendar_event('Letter', event2_name, do_refresh=False,
**event2_kw)
#XXX this is maybe required is due to page delay
self.open_ung_default_page("calendar", clear_cache=1, wait_for_activities=1)
#for precise approach, this test will be done in day view
self.selenium.click("//span[@class='showdayview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#go one day before first day of event1, and assert any of them are present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2010, 11, 31)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertFalse(self.selenium.is_text_present(event1_name))
self.assertFalse(self.selenium.is_text_present(event2_name))
#go to first day of event1, and assert only event1 is present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2011, 00, 01)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue(self.selenium.is_text_present(event1_name))
self.assertFalse(self.selenium.is_text_present(event2_name))
#go to 06/30/2011, and assert only event1 is present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2011, 05, 30)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue(self.selenium.is_text_present(event1_name))
self.assertFalse(self.selenium.is_text_present(event2_name))
#go to first day of event2, and assert both are present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2012, 00, 01)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue(self.selenium.is_text_present(event1_name))
self.assertTrue(self.selenium.is_text_present(event2_name))
#go to last day of event1, and assert both are present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2012, 11, 31)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertTrue(self.selenium.is_text_present(event1_name))
self.assertTrue(self.selenium.is_text_present(event2_name))
#go one day after last day of event1, and assert only event2 is present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2013, 00, 01)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertFalse(self.selenium.is_text_present(event1_name))
self.assertTrue(self.selenium.is_text_present(event2_name))
#go to 06/30/2013, and assert only event2 is present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2013, 05, 30)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertFalse(self.selenium.is_text_present(event1_name))
self.assertTrue(self.selenium.is_text_present(event2_name))
#go to last day of event2, and assert only event2 is present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2013, 11, 31)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertFalse(self.selenium.is_text_present(event1_name))
self.assertTrue(self.selenium.is_text_present(event2_name))
#go one day after last day of event2, and assert any of them are present
self.selenium.run_script("$('#gridcontainer').gotoDate(new Date(2014, 00, 01)).BcalGetOp();")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.assertFalse(self.selenium.is_text_present(event1_name))
self.assertFalse(self.selenium.is_text_present(event2_name))
if __name__ == "__main__":
unittest.main()
from UNGTestMixin import UNGTestMixin
import unittest
import urllib2
SVG_CONTENT = urllib2.quote("<svg width='640' height='480' \
xmlns='http://www.w3.org/2000/svg'> \
<g><title>Layer 1</title> \
<ellipse ry='46' rx='47' id='svg_1' cy='93' cx='138' stroke-width='5' \
stroke='#000000' fill='#FF0000'/> </g></svg>")
class TestUNGDocs(UNGTestMixin):
"""Tests related to UNG Docs"""
def test_web_illustration(self):
"""test add, fill, rename and search for a Web Illustration document"""
url = self.create_document('illustration')
try:
self.selenium.set_timeout(1)
self.selenium.open(url + "/setTextContent?value=%s" % SVG_CONTENT)
except:
pass
finally:
self.selenium.set_timeout(30000)
self.selenium.open(url + "/WebIllustration_viewEditor?"
"editable_mode:int=1")
self.selenium.wait_for_page_to_load("30000")
self.selenium.select_frame("//iframe[@id='svgframe']")
self.selenium.wait_for_condition("window.document.getElementById"
"('svg_1')", "1000")
self.assertEqual("46", self.selenium.get_eval("window.document."
"getElementById('svg_1').ry.baseVal.value"))
self.selenium.select_window('null')
self.assertEqual("Web Illustration", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Draft", self.selenium.get_text(
"//a[@name=\"document_state\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Edit More Properties",
self.selenium.get_text("//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.selenium.click("//span[@class=\"ui-icon ui-icon-closethick\"]")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.type("//input[@id=\"name\"]", "Functional UNG Test")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]"
"/button[1]/span")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.failIf(self.selenium.is_text_present("All Documents"))
self.open_ung_default_page('ung', wait_for_activities=1)
self.assertEqual("All Documents", self.selenium.get_text(
"//button[@class=\"tree-open\"]"))
self.selenium.type("//input[@name=\"field_your_search_text\"]",
"Functional UNG Test")
self.selenium.click("//input[@value=\"Search Docs\"]")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No result."))
def test_web_page(self):
"""test the action of add, cancel, delete and then delete again a
Web Page document"""
self.create_document('page')
self.assertEqual("Web Page", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.selenium.click("//div[@class=\"action_menu\"]/li/ul/li[1]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Cancelled", self.selenium.get_text(
"//a[@name=\"document_state\"]"))
self.open_ung_default_page('ung', wait_for_activities=1)
self.assertEqual("All Documents", self.selenium.get_text(
"//button[@class='tree-open']"))
self.selenium.click("//div[@class=\"favorite\"]/a[2]") # Refresh
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual("All Documents", self.selenium.get_text(
"//button[@class='tree-open']"))
self.selenium.click("//table[@class=\"listbox listbox listbox-table\"]"
"/tbody/tr[1]/td[1]/input")
self.selenium.click("//button[@class='delete']")
self.selenium.wait_for_page_to_load("30000")
self.open_ung_default_page('ung', wait_for_activities=1)
self.selenium.click("//button[@value='ung_domain/trash.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No result."))
self.assertEqual("Deleted", self.selenium.get_text("//table/tbody/"
"tr[1]/td[4]"))
self.selenium.click("//input[@title='Check All']")
self.selenium.click("//button[@class='delete']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual("No result.", self.selenium.get_text(
"//td[@class='listbox-table-no-result-row']/span"))
self.assertEqual("Trash", self.selenium.get_text(
"//button[@class='tree-open']"))
self.selenium.click("//button[@value='ung_domain/hidden.0']")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("No result.", self.selenium.get_text(
"//td[@class=\"listbox-table-no-result-row\"]/span"))
self.assertEqual("Hidden", self.selenium.get_text(
"//button[@class='tree-open']"))
def test_title_abbreviation(self):
"""test the abbreviation of a long title of the document"""
self.create_document('page')
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.type("//input[@id=\"name\"]",
"Add a Big Title to Test the abbreviation")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/"
"span")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Add a Big Title to Test the ab...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Add a Big Title to Test the abbreviation",
self.selenium.get_value("//input[@id=\"name\"]"))
def test_help_button_translation(self):
"""test that help button is translated"""
self.open_ung_default_page('ung')
self.selenium.click("//div[@id=\"select_language\"]/li/ul/li/"
"span[@id=\"fr\"]")
self.selenium.wait_for_page_to_load("30000")
self.failUnless(self.selenium.is_text_present("Aide"))
self.selenium.click("//div[@id=\"select_language\"]/li/ul/li/"
"span[@id=\"en\"]")
self.selenium.wait_for_page_to_load("30000")
self.failUnless(self.selenium.is_text_present("Help"))
def test_web_table_upload_twice(self):
"""test the twice upload of a spreadsheet file into a Web Table
document."""
test_file_path = self.get_file_path(
"tiolive-ERP5.Freedom.TioLive.Spreadsheet-001-en.ods")
for index in range(2):
self.selenium.click("//a[@class=\"ung_docs\"]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//input[@id=\"upload\"]")
self.selenium.select("//select[@name=\"portal_type\"]",
"Web Table")
self.selenium.click("//input[@id=\"submit_document\"]")
self.assertEqual("Please input a file", self.selenium.get_text(
"//span[@id='no-input-file']"))
self.failUnless(self.selenium.is_text_present("Loading..."))
self.failUnless(self.selenium.is_element_present(
"//input[@id=\"upload-file\"]"))
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")
self.failUnless(self.selenium.is_text_present(
"TioLive Spreadsheet"))
self.assertEqual("1", self.selenium.get_attribute(
"//td[@id='0_table0_cell_c0_r1']@sdval"))
self.assertEqual("2", self.selenium.get_attribute(
"//td[@id='0_table0_cell_c1_r1']@sdval"))
def test_web_table_upload_converting_to_web_page(self):
"""test upload of a spreadsheet converting to a Web Page document"""
test_file_path = self.get_file_path(
"tiolive-ERP5.Freedom.TioLive.Spreadsheet-001-en.ods")
self.selenium.click("//a[@class=\"ung_docs\"]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//input[@id=\"upload\"]")
self.selenium.select("//select[@name=\"portal_type\"]", "Web Page")
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")
self.selenium.wait_for_condition("selenium.isElementPresent("
"\"//a[@name='document_title']\")", "30000")
self.failUnless(self.selenium.is_text_present("TioLive Spreadsheet"))
def test_cancel_web_page(self):
"""test the action of cancelling a Web Page document"""
self.create_document('page', name='Cancelled Document')
self.selenium.click("//a[contains(./@href, 'cancel_action')]")
self.selenium.wait_for_page_to_load("30000")
self.open_ung_default_page('ung')
#XXX needs to click 'All Documents' tree again -- selecting it before
#uploading the first file
self.selenium.click("//table[@class=\"listbox listbox listbox-table\"]"
"/tbody/tr[1]/td[1]/input")
self.selenium.click("//button[@class='delete']")
self.selenium.wait_for_page_to_load("30000")
self.open_ung_default_page(wait_for_activities=1)
self.wait_ung_listbox_to_load()
self.selenium.click("//button[@value='ung_domain/trash.0']") # Trash
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual("Cancelled Document", self.selenium.get_text(
"//table/tbody/tr[1]/td[3]"))
self.selenium.click("//table[@class=\"listbox listbox listbox-table\"]"
"/tbody/tr[1]/td[1]/input")
self.selenium.click("//button[@class='delete']")
self.selenium.wait_for_page_to_load("30000")
def test_change_title(self):
"""test the action of changing a title, by:
- opening the window to change title, and closing it
- opening again, changing values, but closing without saving
- opening again, changing values, and saving
- assert values are saved
- rename values to others
- assert new valures are saved
for Web Illustration, Web Table and Web Page documents"""
#New Web Illustration
self.create_document('illustration')
self.assertEqual("Web Illustration", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Draft", self.selenium.get_text(
"//a[@name=\"document_state\"]"))
#First just check properties
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Illustration", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Web Illustration", self.selenium.get_value(
"//input[@id='name']"))
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.assertEqual("", self.selenium.get_value(
"//textarea[@id='keyword_list']"))
self.selenium.click("//span[@class=\"ui-icon ui-icon-closethick\"]")
#Than check and fill properties, without saving
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Illustration", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Web Illustration", self.selenium.get_value(
"//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Web Illustration")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Web Illustration")
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "002")
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "fr")
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "0")
self.assertEqual("", self.selenium.get_value(
"//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list", "Functional UNG Test\nUNG Test")
self.selenium.click("//span[@class=\"ui-icon ui-icon-closethick\"]")
#Than check and fill properties, saving
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Illustration", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Web Illustration", self.selenium.get_value(
"//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Web Illustration")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Web Illustration")
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "002")
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "fr")
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "1")
self.assertEqual("",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list", "Functional UNG Test\nUNG Test")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/"
"span")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Illu...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.refresh()
self.assertEqual("Functional UNG Test - Web Illu...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
#Finally, verify
self.open_ung_default_page('ung', wait_for_activities=1)
self.assertEqual("Functional UNG Test - Web Illustration",
self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]"))
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Illu...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Web Illustration",
self.selenium.get_value("//input[@id='name']"))
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Web Illustration",
self.selenium.get_value("//input[@id='short_title']"))
self.assertEqual("002", self.selenium.get_value(
"//input[@id='version']"))
self.assertEqual("fr", self.selenium.get_value(
"//input[@id='language']"))
self.assertEqual("1", self.selenium.get_value(
"//input[@id='sort_index']"))
self.assertEqual("Functional UNG Test\nUNG Test",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.open_ung_default_page('ung')
self.selenium.type("//input[@name=\"field_your_search_text\"]",
"\"Functional UNG Test - Web Illustration\"")
self.selenium.click("//input[@value=\"Search Docs\"]")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No result."))
#Change to other
self.open_ung_default_page('ung')
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Illu...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Web Illu...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.assertEqual("", self.selenium.get_text("//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Renamed Web "
"Illustration")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Web Illustration",
self.selenium.get_value("//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Renamed Web "
"Illustration")
self.assertEqual("002", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "003")
self.assertEqual("fr", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "en")
self.assertEqual("1", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "2")
self.assertEqual("Functional UNG Test\nUNG Test",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list", "Functional UNG Test Renamed\n"
"UNG Test Renamed")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/"
"span")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.refresh()
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
#Verify changes
self.open_ung_default_page('ung', wait_for_activities=1)
self.assertEqual("Functional UNG Test - Renamed Web Illustration",
self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]"))
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Renamed Web Illustration",
self.selenium.get_value("//input[@id='name']"))
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Renamed Web Illustration",
self.selenium.get_value("//input[@id='short_title']"))
self.assertEqual("003", self.selenium.get_value(
"//input[@id='version']"))
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.assertEqual("2", self.selenium.get_value(
"//input[@id='sort_index']"))
self.assertEqual("Functional UNG Test Renamed\nUNG Test Renamed",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.open_ung_default_page('ung', wait_for_activities=1)
self.selenium.type("//input[@name=\"field_your_search_text\"]",
"\"Functional UNG Test - Renamed Web Illustration\"")
self.selenium.click("//input[@value=\"Search Docs\"]")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No result."))
#New Web Table
self.create_document('table')
self.assertEqual("Web Table", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Draft", self.selenium.get_text(
"//a[@name=\"document_state\"]"))
#First just see properties
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Table", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Web Table", self.selenium.get_value(
"//input[@id='name']"))
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.assertEqual("", self.selenium.get_value(
"//textarea[@id='keyword_list']"))
self.selenium.click("//span[@class=\"ui-icon ui-icon-closethick\"]")
#Than check and fill properties, without saving
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Table", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Web Table", self.selenium.get_value(
"//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Web Table")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Web Table")
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "002")
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "fr")
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "0")
self.assertEqual("", self.selenium.get_value(
"//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list", "Functional UNG Test\nUNG Test")
self.selenium.click("//span[@class=\"ui-icon ui-icon-closethick\"]")
#Than check and fill properties, saving
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Table", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Web Table", self.selenium.get_value(
"//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Web Table")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Web Table")
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "002")
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "fr")
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "1")
self.assertEqual("", self.selenium.get_value(
"//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list", "Functional UNG Test\nUNG Test")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/"
"span")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Tabl...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.refresh()
self.assertEqual("Functional UNG Test - Web Tabl...",
self.selenium.get_text("//a[@name='document_title']"))
#Finally, verify
self.open_ung_default_page('ung', wait_for_activities=1)
self.assertEqual("Functional UNG Test - Web Table",
self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]"))
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Tabl...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Web Table",
self.selenium.get_value("//input[@id='name']"))
self.assertEqual("Edit More Properties",
self.selenium.get_text("//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Web Table",
self.selenium.get_value("//input[@id='short_title']"))
self.assertEqual("002", self.selenium.get_value("//input[@id='version']"))
self.assertEqual("fr", self.selenium.get_value("//input[@id='language']"))
self.assertEqual("1", self.selenium.get_value("//input[@id='sort_index']"))
self.assertEqual("Functional UNG Test\nUNG Test",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.open_ung_default_page('ung', wait_for_activities=1)
self.selenium.type("//input[@name=\"field_your_search_text\"]",
"\"Functional UNG Test - Web Table\"")
self.selenium.click("//input[@value=\"Search Docs\"]")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No result."))
#Change to other
self.open_ung_default_page('ung')
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Tabl...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Web Tabl...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.assertEqual("", self.selenium.get_text("//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Renamed Web Table")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Web Table",
self.selenium.get_value("//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Renamed Web Table")
self.assertEqual("002", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "003")
self.assertEqual("fr", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "en")
self.assertEqual("1", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "2")
self.assertEqual("Functional UNG Test\nUNG Test",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list",
"Functional UNG Test Renamed\nUNG Test Renamed")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/"
"span")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.refresh()
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
#Verify changes
self.open_ung_default_page('ung', wait_for_activities=1)
self.assertEqual("Functional UNG Test - Renamed Web Table",
self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]"))
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document",
self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Renamed Web Table",
self.selenium.get_value("//input[@id='name']"))
self.assertEqual("Edit More Properties",
self.selenium.get_text("//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Renamed Web Table",
self.selenium.get_value("//input[@id='short_title']"))
self.assertEqual("003", self.selenium.get_value(
"//input[@id='version']"))
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.assertEqual("2", self.selenium.get_value(
"//input[@id='sort_index']"))
self.assertEqual("Functional UNG Test Renamed\nUNG Test Renamed",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.open_ung_default_page('ung', wait_for_activities=1)
self.selenium.type("//input[@name=\"field_your_search_text\"]",
"\"Functional UNG Test - Renamed Web Table\"")
self.selenium.click("//input[@value=\"Search Docs\"]")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No result."))
#New Web Page
self.create_document('page')
self.assertEqual("Web Page",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.assertEqual("Draft",
self.selenium.get_text("//a[@name=\"document_state\"]"))
#First just see properties
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document",
self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Page",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.assertEqual("Edit More Properties",
self.selenium.get_text("//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Web Page", self.selenium.get_value(
"//input[@id='name']"))
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.assertEqual("", self.selenium.get_value(
"//textarea[@id='keyword_list']"))
self.selenium.click("//span[@class=\"ui-icon ui-icon-closethick\"]")
#Than check and fill properties, without saving
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Page", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Web Page", self.selenium.get_value("//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Web Page")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Web Page")
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "002")
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "fr")
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "0")
self.assertEqual("", self.selenium.get_value(
"//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list", "Functional UNG Test\nUNG Test")
self.selenium.click("//span[@class=\"ui-icon ui-icon-closethick\"]")
#Than check and fill properties, saving
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Web Page", self.selenium.get_text(
"//a[@name=\"document_title\"]"))
self.assertEqual("Web Page", self.selenium.get_value(
"//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Web Page")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("", self.selenium.get_value(
"//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Web Page")
self.assertEqual("001", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "002")
self.assertEqual("en", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "fr")
self.assertEqual("", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "1")
self.assertEqual("", self.selenium.get_value(
"//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list", "Functional UNG Test\nUNG Test")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/"
"span")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Page",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.refresh()
self.assertEqual("Functional UNG Test - Web Page",
self.selenium.get_text("//a[@name=\"document_title\"]"))
#Finally, verify
self.open_ung_default_page('ung', wait_for_activities=1)
self.assertEqual("Functional UNG Test - Web Page",
self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]"))
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Page",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document",
self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Web Page",
self.selenium.get_value("//input[@id='name']"))
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Web Page",
self.selenium.get_value("//input[@id='short_title']"))
self.assertEqual("002", self.selenium.get_value(
"//input[@id='version']"))
self.assertEqual("fr", self.selenium.get_value(
"//input[@id='language']"))
self.assertEqual("1", self.selenium.get_value(
"//input[@id='sort_index']"))
self.assertEqual("Functional UNG Test\nUNG Test",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.open_ung_default_page('ung', wait_for_activities=1)
self.selenium.type("//input[@name=\"field_your_search_text\"]",
"\"Functional UNG Test - Web Page\"")
self.selenium.click("//input[@value=\"Search Docs\"]")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No result."))
#Change to other
self.open_ung_default_page('ung')
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Web Page",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Web Page",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.assertEqual("", self.selenium.get_text("//input[@id='name']"))
self.selenium.type("name", "Functional UNG Test - Renamed Web Page")
self.assertEqual("Edit More Properties", self.selenium.get_text(
"//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Web Page",
self.selenium.get_value("//input[@id='short_title']"))
self.selenium.type("short_title", "Func. UNG Test - Renamed Web Page")
self.assertEqual("002", self.selenium.get_value(
"//input[@id='version']"))
self.selenium.type("version", "003")
self.assertEqual("fr", self.selenium.get_value(
"//input[@id='language']"))
self.selenium.type("language", "en")
self.assertEqual("1", self.selenium.get_value(
"//input[@id='sort_index']"))
self.selenium.type("sort_index", "2")
self.assertEqual("Functional UNG Test\nUNG Test",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.selenium.type("keyword_list", "Functional UNG Test Renamed\n"
"UNG Test Renamed")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/span")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.refresh()
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
#Verify changes
self.open_ung_default_page('ung', wait_for_activities=1)
self.assertEqual("Functional UNG Test - Renamed Web Page",
self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]"))
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test - Renamed ...",
self.selenium.get_text("//a[@name=\"document_title\"]"))
self.selenium.click("//a[@name=\"document_title\"]")
self.assertEqual("Rename Document", self.selenium.get_text(
"//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Functional UNG Test - Renamed Web Page",
self.selenium.get_value("//input[@id='name']"))
self.assertEqual("Edit More Properties",
self.selenium.get_text("//p[@id=\"more_properties\"]"))
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("Func. UNG Test - Renamed Web Page",
self.selenium.get_value("//input[@id='short_title']"))
self.assertEqual("003", self.selenium.get_value("//input[@id='version']"))
self.assertEqual("en", self.selenium.get_value("//input[@id='language']"))
self.assertEqual("2", self.selenium.get_value("//input[@id='sort_index']"))
self.assertEqual("Functional UNG Test Renamed\nUNG Test Renamed",
self.selenium.get_value("//textarea[@id='keyword_list']"))
self.open_ung_default_page('ung', wait_for_activities=1)
self.selenium.type("//input[@name=\"field_your_search_text\"]",
"\"Functional UNG Test - Renamed Web Page\"")
self.selenium.click("//input[@value=\"Search Docs\"]")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No result."))
def test_subject_list(self):
"""test that:
- when filtering 'By Subject', it shows correct documents
- when changing old subjects to new ones, the old ones disappear on
the list"""
test_subject_time = int(unittest.time.time())
self.create_document('page', keywords="UNG Test Subject %d" % \
test_subject_time)
self.failUnless(self.selenium.is_element_present(
"//meta[@content='UNG Test Subject %d']" % test_subject_time))
self.open_ung_default_page('ung', clear_cache=1, wait_for_activities=1)
self.failIf(self.selenium.is_text_present(
"Ung test subject %d" % test_subject_time))
self.selenium.click("//button[@value='ung_domain/by_subject.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual("Ung test subject %d" % test_subject_time,
self.selenium.get_text("//button[@value='ung_domain/by_subject/"
"subject_UNG Test Subject %d.1']" % test_subject_time))
self.failUnless(self.selenium.is_element_present(
"//button[@value='ung_domain/by_subject/"
"subject_UNG Test Subject %d.1']" % test_subject_time))
self.selenium.click("//tr[@class='listbox-data-line-0 DataA']/td[3]/a")
self.selenium.wait_for_page_to_load('30000')
self.rename_document(keywords="UNG Test VPN %(time)d\n"
"UNG Test Cloudooo %(time)d" % {'time': test_subject_time})
self.open_ung_default_page('ung', clear_cache=1, wait_for_activities=1)
self.selenium.click("//button[@value='ung_domain/by_subject.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
#check that when renaming subjects, the old ones are not present anymore
self.failIf(self.selenium.is_element_present(
"//button[@value='ung_domain/by_subject/"
"subject_UNG Subject %d.1']" % test_subject_time))
self.failUnless(self.selenium.is_element_present(
"//button[@value='ung_domain/by_subject/subject_UNG"
" Test VPN %d.1']" % test_subject_time))
self.assertEqual("Ung test vpn %d" % test_subject_time,
self.selenium.get_text("//button[@value='ung_domain/by_subject/"
"subject_UNG Test VPN %d.1']" % test_subject_time))
self.failUnless(self.selenium.is_element_present(
"//button[@value='ung_domain/by_subject/"
"subject_UNG Test Cloudooo %d.1']" % test_subject_time))
self.assertEqual("Ung test cloudooo %d" % test_subject_time,
self.selenium.get_text("//button[@value='ung_domain/by_subject/"
"subject_UNG Test Cloudooo %d.1']" % test_subject_time))
self.create_document('table', keywords="UNG Test Web Table Subject %d"\
% test_subject_time)
self.open_ung_default_page('ung', clear_cache=1, wait_for_activities=1)
self.selenium.click("//button[@value='ung_domain/by_subject.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual("Ung test web table subject %d" % test_subject_time,
self.selenium.get_text("//button[@value='ung_domain/by_subject/"
"subject_UNG Test Web Table Subject %d.1']" % test_subject_time))
self.selenium.click("//button[@value='ung_domain/by_subject/"
"subject_UNG Test Web Table Subject %d.1']" % test_subject_time)
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.failUnless(self.selenium.is_element_present(
"//table[@class=\"listbox listbox listbox-table\"]/tbody"
"/tr[1]/td[1]/input"))
self.failUnless(self.selenium.is_element_present(
"//table[@class=\"listbox listbox listbox-table\"]/tbody"
"/tr[1]/td[2]/input"))
#assert only one element is present,
#because only one 'table' element was created
self.failIf(self.selenium.is_element_present(
"//table[@class=\"listbox listbox listbox-table\"]/tbody/"
"tr[2]/td[1]/input"))
def test_all_domain_tree_filters(self):
"""test Domain Tree on UNG Docs.
Domain Tree is the box where listbox is filtered by state, document
type. All Cases should be tested, including collapse and expand items
into the list."""
test_time = int(unittest.time.time())
#first, create a web illustration, a web page and a web table
web_illustration_name = "Functional UNG Test %d - Web Illustration" \
% test_time
web_illustration_keywords = "Ung test %d - web illustration" % test_time
web_illustration_url = self.create_document('illustration',
name=web_illustration_name,
keywords=web_illustration_keywords)
web_page_name = "Functional UNG Test %d - Web Page" % test_time
web_page_keywords = "Ung test %d - web page" % test_time
web_page_url = self.create_document('page',
name=web_page_name,
keywords=web_page_keywords)
web_table_name = "Functional UNG Test %d - Web Table" % test_time
web_table_keywords = "Ung test %d - web table" % test_time
web_table_url = self.create_document('table',
name=web_table_name,
keywords=web_table_keywords)
#test 'All Documents' filter
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
self.set_default_tree_view()
self.failUnless(self.selenium.is_text_present(web_table_name))
self.failUnless(self.selenium.is_text_present(web_page_name))
self.failUnless(self.selenium.is_text_present(web_illustration_name))
#test 'All Documents' / 'Web Illustration' filter
self.assertEqual("Web Illustration", self.selenium.get_text(
"//button[@value='ung_domain/all_documents/"
"web_illustration_domain.1']"))
self.selenium.click("//button[@value='ung_domain/all_documents/"
"web_illustration_domain.1']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual(web_illustration_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]/a"))
#test 'All Documents' / 'Web Page' filter
self.assertEqual("Web Page", self.selenium.get_text(
"//button[@value='ung_domain/all_documents/web_page_subdomain.1']"))
self.selenium.click("//button[@value='ung_domain/all_documents/"
"web_page_subdomain.1']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual(web_page_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]/a"))
#test 'All Documents' / 'Web Table' filter
self.assertEqual("Web Table", self.selenium.get_text(
"//button[@value='ung_domain/all_documents/"
"web_table_subdomain.1']"))
self.selenium.click("//button[@value='ung_domain/all_documents/"
"web_table_subdomain.1']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual(web_table_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]/a"))
#test collapsing 'All Documents' and testing all 3 documents are present
self.selenium.click("//button[@value='ung_domain/all_documents.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.failUnless(self.selenium.is_text_present(web_table_name))
self.failUnless(self.selenium.is_text_present(web_page_name))
self.failUnless(self.selenium.is_text_present(web_illustration_name))
#test 'By Subject' filter
self.open_ung_default_page(clear_cache=1)
self.set_default_tree_view()
self.selenium.click("//button[@value='ung_domain/by_subject.0']")
self.selenium.wait_for_page_to_load('30000')
self.wait_ung_listbox_to_load()
self.failUnless(self.selenium.is_text_present(
web_illustration_keywords))
self.failUnless(self.selenium.is_text_present(web_page_keywords))
self.failUnless(self.selenium.is_text_present(web_table_keywords))
#test 'By Subject' has web_illustration keywords
self.assertEqual(web_illustration_keywords, self.selenium.get_text(
"//button[@value='ung_domain/by_subject/subject_%s.1']" % \
web_illustration_keywords))
self.selenium.click("//button[@value='ung_domain/by_subject/"
"subject_%s.1']" % web_illustration_keywords)
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual(web_illustration_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]/a"))
#test 'By Subject' has web_page keywords
self.assertEqual(web_page_keywords, self.selenium.get_text(
"//button[@value='ung_domain/by_subject/subject_%s.1']" % \
web_page_keywords))
self.selenium.click("//button[@value='ung_domain/by_subject/"
"subject_%s.1']" % web_page_keywords)
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual(web_page_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]/a"))
#test 'By Subject' has web_table keywords
self.assertEqual(web_table_keywords, self.selenium.get_text(
"//button[@value='ung_domain/by_subject/subject_%s.1']" % \
web_table_keywords))
self.selenium.click("//button[@value='ung_domain/by_subject/"
"subject_%s.1']" % web_table_keywords)
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual(web_table_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]/a"))
#test collapsing 'By Subject' and testing all 3 documents are present
self.selenium.click("//button[@value='ung_domain/by_subject.0']")
self.selenium.wait_for_page_to_load('30000')
self.wait_ung_listbox_to_load()
self.failUnless(self.selenium.is_text_present(web_illustration_name))
self.failUnless(self.selenium.is_text_present(web_page_name))
self.failUnless(self.selenium.is_text_present(web_table_name))
#test 'Owner' filter
self.open_ung_default_page(clear_cache=1)
self.set_default_tree_view()
self.selenium.click("//button[@value='ung_domain/owner.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
#for web_table
self.assertEqual(web_table_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]/a"))
#for web_page
self.assertEqual(web_page_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-1 DataB']/td[3]/a"))
#for web_illustration
self.assertEqual(web_illustration_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-2 DataA']/td[3]/a"))
#test 'Recent' filter
self.open_ung_default_page(clear_cache=1)
self.set_default_tree_view()
self.selenium.click("//button[@value='ung_domain/owner.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
#for web_table
self.assertEqual(web_table_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-0 DataA']/td[3]/a"))
#for web_page
self.assertEqual(web_page_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-1 DataB']/td[3]/a"))
#for web_illustration
self.assertEqual(web_illustration_name, self.selenium.get_text(
"//tr[@class='listbox-data-line-2 DataA']/td[3]/a"))
#test 'Shared by me' filter
#share web_illustration
self.selenium.open(web_illustration_url)
self.selenium.click("//a[@id=\"share_document\"]")
self.selenium.wait_for_page_to_load("30000")
#check 'Shared by me' filter for web_illustration
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
self.set_default_tree_view()
self.selenium.click("//button[@value='ung_domain/shared.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No Result"))
self.assertEqual("Shared by me", self.selenium.get_text(
"//button[@class=\"tree-open\"]"))
self.failUnless(self.selenium.is_text_present(web_illustration_name))
self.failIf(self.selenium.is_text_present(web_page_name))
self.failIf(self.selenium.is_text_present(web_table_name))
#share web_page and web_table
self.selenium.open(web_page_url)
self.selenium.click("//a[@id=\"share_document\"]")
self.selenium.wait_for_page_to_load("30000")
self.selenium.open(web_table_url)
self.selenium.click("//a[@id=\"share_document\"]")
self.selenium.wait_for_page_to_load("30000")
#check 'Shared by me' filter for all 3 documents
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
self.set_default_tree_view()
self.selenium.click("//button[@value='ung_domain/shared.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.failIf(self.selenium.is_text_present("No Result"))
self.assertEqual("Shared by me", self.selenium.get_text(
"//button[@class=\"tree-open\"]"))
self.failUnless(self.selenium.is_text_present(web_illustration_name))
self.failUnless(self.selenium.is_text_present(web_page_name))
self.failUnless(self.selenium.is_text_present(web_table_name))
#test 'Hidden' filter
#to hide a document, it first have to be shared
#this is why 'Shared by me' filter is tested before Hidden filter
#so first, hide web_illustration
# this try/except is because page 'web_illustration_url + '/hide'
# doesn't trigger wait_for_page_to_load
self.selenium.set_timeout(1)
try:
self.selenium.open(web_illustration_url + '/hide')
self.selenium.wait_for_page_to_load("10000")
except:
pass
self.selenium.set_timeout(30000)
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
self.set_default_tree_view()
#check 'Hidden' filter for web_illustration
self.selenium.click("//button[@value='ung_domain/hidden.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual("Hidden", self.selenium.get_text(
"//button[@class=\"tree-open\"]"))
self.failUnless(self.selenium.is_text_present(web_illustration_name))
self.failIf(self.selenium.is_text_present(web_page_name))
self.failIf(self.selenium.is_text_present(web_table_name))
#hide web_page and web_table
self.selenium.set_timeout(1)
try:
self.selenium.open(web_page_url + '/hide')
self.selenium.wait_for_page_to_load("10000")
except:
pass
try:
self.selenium.open(web_table_url + '/hide')
self.selenium.wait_for_page_to_load("10000")
except:
pass
self.selenium.set_timeout(30000)
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
self.set_default_tree_view()
#check 'Hidden' filter for all 3 documents
self.selenium.click("//button[@value='ung_domain/hidden.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.assertEqual("Hidden", self.selenium.get_text(
"//button[@class=\"tree-open\"]"))
self.failUnless(self.selenium.is_text_present(web_illustration_name))
self.failUnless(self.selenium.is_text_present(web_page_name))
self.failUnless(self.selenium.is_text_present(web_table_name))
#test 'Trash' filter
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
self.wait_ung_listbox_to_load()
#open trash
self.selenium.click("//button[@value='ung_domain/trash.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
#check 'Trash' filter, so that none of the 3 documents are present
self.failIf(self.selenium.is_text_present(web_illustration_name))
self.failIf(self.selenium.is_text_present(web_page_name))
self.failIf(self.selenium.is_text_present(web_table_name))
#go back default tree and delete than
self.set_default_tree_view()
self.wait_ung_listbox_to_load()
for doc_index in range(3):
self.selenium.click("//tr[@class='listbox-data-line-%d Data%s']"
"/td[1]/input" % (doc_index, ('A', 'B')[doc_index % 2]))
self.selenium.click("//button[@class='delete']")
self.selenium.wait_for_page_to_load("30000")
self.wait_for_activities()
#test 'Trash' filter to see if all 3 documents are present
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
self.set_default_tree_view()
self.selenium.click("//button[@value='ung_domain/trash.0']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
self.failUnless(self.selenium.is_text_present(web_illustration_name))
self.failUnless(self.selenium.is_text_present(web_page_name))
self.failUnless(self.selenium.is_text_present(web_table_name))
#delete all 3 documents again
for doc_index in range(3):
self.selenium.click("//tr[@class='listbox-data-line-%d Data%s']"
"/td[1]/input" % (doc_index, ('A', 'B')[doc_index % 2]))
self.selenium.click("//button[@class='delete']")
self.selenium.wait_for_page_to_load("30000")
self.wait_for_activities()
#check 'Trash' filter, so that none of the 3 documents are present again
self.failIf(self.selenium.is_text_present(web_illustration_name))
self.failIf(self.selenium.is_text_present(web_page_name))
self.failIf(self.selenium.is_text_present(web_table_name))
#check 'Starred' filter
#XXX this is not implemented yet
raise NotImplementedError("Starred filter is not implemented yet")
def test_change_state_button(self):
"""test the possibility to change state of many documents
from the standard ung default interface, using 'Change State' button
- this test will change state from 'Draft' to 'Shared'"""
test_time = int(unittest.time.time())
#create 2 web_page
for doc_index in range(2):
self.create_document('page', name="Functional UNG Test %d - "
"Web Page %d" % (test_time, doc_index))
self.open_ung_default_page('ung', wait_for_activities=1)
#select the 2 documents created
for doc_index in range(1, 3):
self.selenium.click(
"//table[@class=\"listbox listbox listbox-table\"]/tbody/"
"tr[%d]/td[1]/input" % doc_index)
#try to change state of both documents
raise Exception("Need to fix permissions/behaviour when changing "
"the state.")
self.selenium.click("//button[@class=\"change_state\"]")
self.selenium.wait_for_condition(
"selenium.isTextPresent('Change State of Documents')")
def test_select_all_and_deselect_all(self):
"""test the button to select all documents and deselect all documents"""
test_time = int(unittest.time.time())
#create 3 documents
for doc_index in range(3):
web_page_name = "Functional UNG Test %d - Web Page %d" % (test_time,
doc_index)
self.create_document('page', name=web_page_name)
#assert no checkbox is checked
self.open_ung_default_page('ung')
self.failIf(self.selenium.is_checked("//tr[@class='listbox-data-line-0 DataA']/td[1]/input"))
self.failIf(self.selenium.is_checked("//tr[@class='listbox-data-line-1 DataB']/td[1]/input"))
self.failIf(self.selenium.is_checked("//tr[@class='listbox-data-line-2 DataA']/td[1]/input"))
#click button to check all
self.selenium.click("//input[@name='listbox_checkAll:method']")
#check all checkboxes are selected
self.failUnless(self.selenium.is_checked("//tr[@class='listbox-data-line-0 DataA']/td[1]/input"))
self.failUnless(self.selenium.is_checked("//tr[@class='listbox-data-line-1 DataB']/td[1]/input"))
self.failUnless(self.selenium.is_checked("//tr[@class='listbox-data-line-2 DataA']/td[1]/input"))
#click button to deselect all
self.selenium.click("//input[@name='listbox_uncheckAll:method']")
#check all cheboxes are deselected
self.failIf(self.selenium.is_checked("//tr[@class='listbox-data-line-0 DataA']/td[1]/input"))
self.failIf(self.selenium.is_checked("//tr[@class='listbox-data-line-1 DataB']/td[1]/input"))
self.failIf(self.selenium.is_checked("//tr[@class='listbox-data-line-2 DataA']/td[1]/input"))
def test_pagination_with_many_documents(self):
"""UNG Docs should paginate when many documents are present.
Test that paginate will work, given that many documents are present."""
# #XXX this test needs an empty instance to test 'Last page'
test_time = int(unittest.time.time())
page_title = "Functional UNG Test %d - Web Page " % test_time
#add many documents to ensure that it has to paginate
# quickly renaming
for doc_index in range(1, 101):
page_url = self.create_document('page', wait_for_activities=False)
name = page_title + str(doc_index)
try:
self.selenium.set_timeout(1)
self.selenium.open(page_url + '/setTitle?value=' + name)
except:
pass
finally:
self.selenium.set_timeout(30000)
self.wait_for_activities()
self.open_ung_default_page('ung')
#assert first and last (relative) documents on first page
self.assertEqual('1', self.selenium.get_value(
"//input[@name='listbox_page_start']"))
self.assertTrue(self.selenium.is_text_present(page_title + '100'))
self.assertTrue(self.selenium.is_text_present(page_title + '84'))
#NEXT BUTTON
# assert first and last (relative) documents on third page
for next_page in range(2):
self.selenium.click("//button[@name='nextPage']")
self.wait_ung_listbox_to_load()
self.assertEqual('3', self.selenium.get_value(
"//input[@name='listbox_page_start']"))
self.assertTrue(self.selenium.is_text_present(page_title + '66'))
self.assertTrue(self.selenium.is_text_present(page_title + '50'))
#PREVIOUS BUTTON
# assert first and last (relative) documents on second page
self.selenium.click("//button[@name='previousPage']")
self.wait_ung_listbox_to_load()
self.assertEqual('2', self.selenium.get_value(
"//input[@name='listbox_page_start']"))
self.assertTrue(self.selenium.is_text_present(page_title + '83'))
self.assertTrue(self.selenium.is_text_present(page_title + '67'))
#TEXT INPUT
# assert that entering a number at input and pressing enter will
# go to that page
self.selenium.type("//input[@name='listbox_page_start']", '4')
self.selenium.key_press("//input[@name='listbox_page_start']", '\\13')
self.wait_ung_listbox_to_load()
self.assertEqual('4', self.selenium.get_value(
"//input[@name='listbox_page_start']"))
self.assertTrue(self.selenium.is_text_present(page_title + '49'))
self.assertTrue(self.selenium.is_text_present(page_title + '33'))
#LAST BUTTON
# assert first and last (relative) documents on last page
last_page_number = self.selenium.get_text("//div[@class='listbox-navigation']").split('/')[1].strip()
self.selenium.click("//button[@name='lastPage']")
self.wait_ung_listbox_to_load()
self.assertEqual(last_page_number,
self.selenium.get_value("//input[@name='listbox_page_start']"))
self.assertTrue(self.selenium.is_text_present(page_title + '15'))
self.assertTrue(self.selenium.is_text_present(page_title + '1'))
#FIRST BUTTON
# assert first and last (relative) documents on first page
self.selenium.click("//button[@name='firstPage']")
self.wait_ung_listbox_to_load()
self.assertEqual('1', self.selenium.get_value(
"//input[@name='listbox_page_start']"))
self.assertTrue(self.selenium.is_text_present(page_title + '100'))
self.assertTrue(self.selenium.is_text_present(page_title + '84'))
if __name__ == "__main__":
unittest.main()
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.rename_document(name='Document Shared',
version='002',
language='pt-br',
keywords="My Subject")
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")
self.selenium.wait_for_condition("selenium.isElementPresent(\"//button[@value='ung_domain/shared.0']\")", "30000")
self.selenium.click("//button[@value='ung_domain/shared.0']")
self.selenium.wait_for_page_to_load("30000")
self.failIf(self.selenium.is_text_present("No Result"))
self.selenium.wait_for_condition("selenium.isElementPresent(\"//button[@class='tree-open']\")", "30000")
self.assertEqual("Shared by me", self.selenium.get_text("//button[@class='tree-open']"))
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[@value='Login']")
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.rename_document(name='Document Shared Updated', version='003')
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.login_as_default_user()
self.selenium.wait_for_condition("selenium.isElementPresent(\"//table[@class='listbox listbox listbox-table']\")", "30000")
self.selenium.click("//table[@class='listbox listbox 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.assertEqual("Document Shared Updated", self.selenium.get_value("//input[@id=\"name\"]"))
self.assertEqual("003", 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.rename_document(version='004')
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("004", 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\"]")
for page_reload in range(2):
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('ung', 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='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
try:
self.failUnless('<img align="LEFT" width="122" height="30" border="0"'
' name="ung_docs-logo" src="image_module/' in web_page_content)
except AssertionError:
raise NotImplementedError("This should fail until implement "
"correct behaviour of images. They should be put under "
"image_module, instead of just a 'tmp' file. \n"
"XXX: Please refactor this try/except code if this"
" functionality is already implemented.")
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('ung', 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='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.wait_add_gadgets_dialog_to_load()
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.wait_add_gadgets_dialog_to_load()
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")
# ung listbox, now a gadget, have this element until it's fully
# loaded, and then its removed from listbox
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_two_gadgets(self):
"""test that its possible to add more than just 1 gadget"""
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_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.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):
"""test that different users have different 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_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[@value='Login']")
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.wait_add_gadgets_dialog_to_load()
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[@value='Login']")
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.wait_add_gadgets_dialog_to_load()
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 !"))
self.clear_user_gadgets()
self.clear_user_gadgets('ung_user2', '1234')
self.clear_user_gadgets('zope', 'zope')
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 'test_user'
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[@value='Login']")
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]"))
def test_login_using_enter_key(self):
"""try to login, submitting login form using 'enter' key (code 13)"""
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load(5000)
self.selenium.type("__ac_name", "ung_user2")
self.selenium.type("__ac_password", "1234")
self.selenium.key_press("//input[@value='Login']", '\\13')
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\']\")",
"30000")
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\']\")",
"30000")
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\']\")",
"30000")
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\']\")",
"30000")
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[@value='Login']")
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\']\")",
"30000")
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\']\")",
"30000")
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\']\")",
"30000")
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\']\")",
"30000")
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[@value='Login']")
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\']\")",
"30000")
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()
from selenium import selenium
import unittest
from selenium import selenium
import urllib2
import os
ERP5_URL = "http://localhost:18080/erp5/"
ERP5_ACTIVITIES_URL = ERP5_URL + \
'portal_activities/getMessageList?include_processing=1'
UNG_URL = ERP5_URL + "web_site_module/ung/"
class UNGTestMixin(unittest.TestCase):
"""Base class for selenium UNG tests, containing useful methods."""
def setUp(self):
......@@ -21,14 +24,15 @@ class UNGTestMixin(unittest.TestCase):
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.selenium.open('')
self.selenium.wait_for_page_to_load(30000)
self.login_as_default_user()
self.wait_for_activities()
self.open_ung_default_page(clear_cache=1, wait_for_activities=1)
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
# <tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/
# macros/delete-all-documents"/>
# but it was omitted since it was not permited to delete objects
def login_as_default_user(self):
"""login as default user 'test_user'"""
......@@ -40,14 +44,55 @@ class UNGTestMixin(unittest.TestCase):
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.wait_ung_listbox_to_load()
if not self.selenium.is_element_present("//button[@class='tree-open']"):
self.selenium.click("//table[@class='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")
elif not "All Documents" == self.selenium.get_text("//button[@class='tree-open']"):
self.selenium.click("//table[@class='listbox-table-domain-tree']/tbody/tr[1]/td/button")
self.selenium.wait_for_page_to_load("30000")
def wait_ung_listbox_to_load(self, waiting_time="30000"):
"""wait until UNG listbox is fully loaded"""
self.selenium.wait_for_condition("selenium.isElementPresent(\""
"//table[@class='listbox-table-domain-tree']\")",
waiting_time)
self.selenium.wait_for_condition("selenium.browserbot"
".getCurrentWindow().$('#knowledge_pad_module_ung_knowledge_pad"
"_ung_docs_listbox_content').css('opacity') == '1'",
waiting_time)
def wait_ung_calendar_to_load(self, waiting_time="30000"):
"""wait until UNG calendar is fully loaded"""
self.selenium.wait_for_condition("selenium.browserbot"
".findElementOrNull('loadingpannel').style.display == 'none'",
waiting_time)
def wait_add_gadgets_dialog_to_load(self, waiting_time="30000"):
"""wait until UNG gadgets dialog is fully loaded"""
self.selenium.wait_for_condition("selenium.browserbot"
".getCurrentWindow().$('div.gadget-listbox table#gadget-table')"
".children().length > 0",
waiting_time)
def clear_user_gadgets(self, user=None, password=None):
"""remove all gadgets from given user
if no user is given, then just remove all gadgets"""
if user:
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load("30000")
self.selenium.type("__ac_name", user)
self.selenium.type("__ac_password", password)
self.selenium.click("//input[@value='Login']")
self.selenium.wait_for_page_to_load("30000")
self.wait_ung_listbox_to_load()
while self.selenium.is_element_present("//a[@class='clickable-block"
" block-remove']"):
self.selenium.click("//a[@class=\"clickable-block block-remove\"]")
self.selenium.get_confirmation()
self.open_ung_default_page('ung')
def clear_cache(self):
"""call method 'Base_clearCache' of bt5 erp5_ui_test, that orders
portal_catalog to clear all allocated cache"""
......@@ -57,15 +102,15 @@ class UNGTestMixin(unittest.TestCase):
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')
activities = urllib2.urlopen(ERP5_ACTIVITIES_URL)
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
#give time to selenium to recompose page when refresh
unittest.time.sleep(2)
def open_ung_default_page(self, page="", clear_cache=0, wait_for_activities=0):
def open_ung_default_page(self, page='ung', 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'
......@@ -76,8 +121,10 @@ class UNGTestMixin(unittest.TestCase):
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");
if page == 'ung':
self.wait_ung_listbox_to_load()
elif page == "calendar":
self.wait_ung_calendar_to_load()
def get_file_path(self, filename):
"""returns the absolute path to a test file given a 'filename'"""
......@@ -89,23 +136,44 @@ class UNGTestMixin(unittest.TestCase):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
def create_document(self, portal_type, name=None, keywords=None):
def create_document(self, portal_type, keywords=None,
wait_for_activities=True, **kw):
"""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.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 or kw:
self.rename_document(keywords=keywords,
wait_for_activities=wait_for_activities, **kw)
elif wait_for_activities:
self.wait_for_activities()
return self.selenium.get_eval("selenium.browserbot."
"getCurrentWindow().location").split('?')[0]
def rename_document(self, url=None, keywords=None, stop_try=False,
wait_for_activities=True, **kw):
"""Change document attributes. At the end, check if rename was
successfull and, if not, repeat steps.
url - visit url of document, case given
keywords - list of keywords to put under keyword_list
**kw - dict of locator:value to type as document attributes"""
if url:
self.selenium.open(url)
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("//a[@name='document_title']")
self.selenium.click("//p[@id='more_properties']")
for locator, value in kw.items():
self.selenium.type(locator, value)
if keywords:
self.selenium.type("//textarea[@id=\"keyword_list\"]", keywords)
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
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")
if wait_for_activities:
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,
......@@ -115,11 +183,11 @@ class UNGTestMixin(unittest.TestCase):
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)
self.selenium.click("//span[@class='addcal']")
self.selenium.wait_for_condition("selenium.isElementPresent('portal_type')", "10000")
self.wait_ung_calendar_to_load()
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)
......@@ -162,7 +230,7 @@ class UNGTestMixin(unittest.TestCase):
#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");
self.wait_ung_calendar_to_load()
if self.selenium.is_text_present(name):
break
else:
......
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGCalendar(UNGTestMixin):
""" Tests related to UNG Calendar
"""
......@@ -17,10 +18,14 @@ class TestUNGCalendar(UNGTestMixin):
test_subject_time = int(unittest.time.time())
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.assertEqual("Refresh", self.selenium.get_text("//span[@class='showdayflash']"))
self.assertEqual("Su", self.selenium.get_text("//span[@title='Sunday']"))
self.assertEqual("Refresh", self.selenium.get_text(
"//span[@class='showdayflash']"))
self.assertEqual("Su", self.selenium.get_text(
"//span[@title='Sunday']"))
self.selenium.click("//span[@class='showmonthview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull"
"('loadingpannel').style.display == 'none'",
"10000");
self.selenium.click("//span[@class='showdayview']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
self.selenium.type("//input[@name='searchable-text']", "My Event %d" % test_subject_time)
......@@ -40,14 +45,13 @@ class TestUNGCalendar(UNGTestMixin):
self.selenium.type("//input[@name=\"start_date_hour\"]", unittest.time.localtime().tm_hour + 1)
self.selenium.type("//input[@name=\"stop_date_hour\"]", unittest.time.localtime().tm_hour + 1)
self.selenium.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
#XXX handle this behaviour differently: activities is called twice
# because sometimes its passing through method even with some present
# activities
#XXX handle this behaviour differently: wait_for_activities is called
# twice because sometimes its passing through method even with some
# remaining activities
self.wait_for_activities()
self.clear_cache()
self.wait_for_activities()
self.selenium.open("calendar")
self.selenium.wait_for_page_to_load("30000")
self.open_ung_default_page("calendar")
self.selenium.wait_for_condition("selenium.isTextPresent('My Event %d')" % test_subject_time, "10000")
self.failUnless(self.selenium.is_text_present("My Event %d" % test_subject_time))
self.selenium.type("//input[@name='searchable-text']", "My Event %d" % test_subject_time)
......@@ -548,6 +552,7 @@ class TestUNGCalendar(UNGTestMixin):
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#XXX due to interface delay again, try two times
# on second, sleeping 3 seconds before refreshing page again
#XXX: this part needs the 'Other##' workaround when many events are present
try:
for event_index in range(len(dates)):
self.assertTrue(self.selenium.is_text_present(event_name % (test_time, event_index)))
......@@ -611,7 +616,7 @@ class TestUNGCalendar(UNGTestMixin):
#assert event is present
self.assertTrue(self.selenium.is_text_present(event_name))
#click refresh button 10 times
for _refresh in range(5):
for _refresh in range(10):
self.selenium.click("//div/span[@title='Refresh view']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#assert only 1 event is present
......@@ -848,6 +853,11 @@ class TestUNGCalendar(UNGTestMixin):
#click Today button
self.selenium.click("//span[@class='showtoday']")
self.selenium.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
#in cases when there are many events on same day, the 'month' view
# group them, only showing them after clicking on 'Others##'
if self.selenium.is_element_present("//td[@abbr='%s'][@ch='more']" % current_date):
self.selenium.click("//td[@abbr='%s'][@ch='more']" % current_date)
self.selenium.wait_for_condition("selenium.isTextPresent('%s')" % event_name, 30000)
self.assertTrue(self.selenium.is_text_present(event_name))
#check button for week view
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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.rename_document(name='Document Shared',
version='002',
language='pt-br',
keywords="My Subject")
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", self.selenium.get_value("//input[@id=\"version\"]"))
......@@ -28,12 +26,13 @@ class TestUNGDocsSharing(UNGTestMixin):
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_condition("selenium.isElementPresent(\"//button[@value='ung_domain/shared.0']\")", "30000")
self.selenium.click("//button[@value='ung_domain/shared.0']")
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_condition("selenium.isElementPresent(\"//button[@class='tree-open']\")", "30000")
self.assertEqual("Shared by me", self.selenium.get_text("//button[@class='tree-open']"))
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\"]")
......@@ -47,7 +46,7 @@ class TestUNGDocsSharing(UNGTestMixin):
# 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.click("//input[@value='Login']")
self.selenium.wait_for_page_to_load("30000")
self.selenium.open(document_url)
self.selenium.wait_for_page_to_load("30000")
......@@ -59,19 +58,25 @@ class TestUNGDocsSharing(UNGTestMixin):
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.rename_document(name='Document Shared Updated', version='003')
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_condition("selenium.isElementPresent(\"//table[@class='listbox listbox listbox-table']\")", "30000")
self.selenium.click("//table[@class='listbox listbox 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.assertEqual("Document Shared Updated", self.selenium.get_value("//input[@id=\"name\"]"))
self.assertEqual("003", 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.rename_document(version='004')
self.selenium.click("//a[@name=\"document_title\"]")
self.selenium.click("//p[@id=\"more_properties\"]")
self.assertEqual("003", self.selenium.get_value("//input[@id=\"version\"]"))
self.assertEqual("004", self.selenium.get_value("//input[@id=\"version\"]"))
#XXX this test delete all documents here
# but it won't be done
......
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
......@@ -15,6 +16,7 @@ class TestUNGDocsTableEditor(UNGTestMixin):
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\"]")
for page_reload in range(2):
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']"))
......
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):
......@@ -28,9 +29,9 @@ class TestUNGDocsTextEditor(UNGTestMixin):
#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)
self.open_ung_default_page('ung', 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.click("//tr[@class='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")
......@@ -70,12 +71,17 @@ class TestUNGDocsTextEditor(UNGTestMixin):
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)
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
try:
self.failUnless('<img align="LEFT" width="122" height="30" border="0"'
' name="ung_docs-logo" src="image_module/' in web_page_content)
except AssertionError:
raise NotImplementedError("This should fail until implement "
"correct behaviour of images. They should be put under "
"image_module, instead of just a 'tmp' file. \n"
"XXX: Please refactor this try/except code if this"
" functionality is already implemented.")
def test_select_xinha_as_preferred_text_editor(self):
"""test that its possible to select Xinha instead of FCKeditor
......@@ -127,9 +133,9 @@ class TestUNGDocsTextEditor(UNGTestMixin):
#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)
self.open_ung_default_page('ung', 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.click("//tr[@class='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")
......
......@@ -3,6 +3,7 @@ import unittest
import re
class TestUNGGadgets(UNGTestMixin):
"""tests related to gadgets on UNG"""
def test_add_and_delete_gadget(self):
......@@ -11,39 +12,58 @@ class TestUNGGadgets(UNGTestMixin):
- 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.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.failIf(self.selenium.is_element_present("//a[@class="
"'clickable-block block-remove']"))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.wait_add_gadgets_dialog_to_load()
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.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.assertEqual("Add gadgets", self.selenium.get_text(
"//a[@id=\"add-gadgets\"]/span"))
self.selenium.click("//a[@id=\"add-gadgets\"]")
self.wait_add_gadgets_dialog_to_load()
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.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\"]"))
# ung listbox, now a gadget, have this element until it's fully
# loaded, and then its removed from listbox
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_two_gadgets(self):
"""test that its possible to add more than just 1 gadget"""
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_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
......@@ -57,16 +77,19 @@ class TestUNGGadgets(UNGTestMixin):
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.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\"]"))
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):
"""test that different users have different 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_rss\"]")
self.selenium.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
......@@ -86,11 +109,12 @@ class TestUNGGadgets(UNGTestMixin):
# 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.click("//input[@value='Login']")
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.wait_add_gadgets_dialog_to_load()
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")
......@@ -105,15 +129,16 @@ class TestUNGGadgets(UNGTestMixin):
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.click("//input[@value='Login']")
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.wait_add_gadgets_dialog_to_load()
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.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")
......@@ -122,11 +147,10 @@ class TestUNGGadgets(UNGTestMixin):
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.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__":
unittest.main()
......
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGLogin(UNGTestMixin):
"""tests related to login on UNG"""
......@@ -16,7 +17,7 @@ class TestUNGLogin(UNGTestMixin):
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'
#XXX: the user used on test's instance is 'test_user'
self.failUnless(self.selenium.is_text_present("test_user"))
self.selenium.click("link=Sign out")
self.selenium.wait_for_page_to_load(5000)
......@@ -28,7 +29,17 @@ class TestUNGLogin(UNGTestMixin):
#<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.click("//input[@value='Login']")
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]"))
def test_login_using_enter_key(self):
"""try to login, submitting login form using 'enter' key (code 13)"""
self.selenium.open("WebSite_logout")
self.selenium.wait_for_page_to_load(5000)
self.selenium.type("__ac_name", "ung_user2")
self.selenium.type("__ac_password", "1234")
self.selenium.key_press("//input[@value='Login']", '\\13')
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]"))
......
from UNGTestMixin import UNGTestMixin
import unittest
class TestUNGSettings(UNGTestMixin):
"""tests related to UNG settings"""
def test_saving_settings_even_on_different_users(self):
......@@ -11,7 +12,9 @@ class TestUNGSettings(UNGTestMixin):
"""
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.selenium.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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\']")
......@@ -19,19 +22,29 @@ class TestUNGSettings(UNGTestMixin):
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.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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)
......@@ -50,36 +63,50 @@ class TestUNGSettings(UNGTestMixin):
# 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.click("//input[@value='Login']")
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.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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.click("//input[@value='Login']")
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"))
self.selenium.wait_for_condition("selenium.isElementPresent(\"//input"
"[@name=\'field_my_preferred_text_editor\']\")",
"30000")
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__":
......
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