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

2011-05-16 gabriel.oliveira

* Convert tests from zelenium to selenium
parent fb1ed8e8
from base import BaseUNGTest
import unittest
from time import localtime
class TestUNGCalendar(BaseUNGTest):
def test_ung_calendar(self):
sel = self.selenium
self.init()
self.login_as_default_user()
sel.open("calendar")
sel.wait_for_page_to_load("30000")
self.assertEqual("Refresh", sel.get_text("//span[@class='showdayflash']"))
self.assertEqual("Su", sel.get_text("//span[@title='Sunday']"))
sel.click("//span[@class='showmonthview']")
sel.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
sel.click("//span[@class='showdayview']")
sel.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
sel.type("//input[@name='searchable-text']", "UNG Event")
sel.click("//input[@id='submit-search']")
sel.wait_for_condition("selenium.isElementPresent('//div[@id=\"blank-result\"]')", "1000")
self.assertEqual("Results: 0 to UNG Event", sel.get_text("//td[@id=\"resultview\"]"))
self.failUnless(sel.is_text_present("No Results"))
sel.click("//a[@id=\"back-calendar\"]")
sel.wait_for_page_to_load("30000")
sel.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
sel.click("//span[@class=\"addcal\"]")
sel.wait_for_condition("selenium.isElementPresent(\"portal_type\")", "10000")
sel.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
sel.select("//select[@name=\"portal_type\"]", "Note")
sel.type("//input[@name=\"title\"]", "My Event")
sel.type("//textarea[@name=\"event_text_content\"]", "Text of Event")
sel.type("//input[@name=\"start_date_hour\"]", localtime().tm_hour + 1)
sel.type("//input[@name=\"stop_date_hour\"]", localtime().tm_hour + 1)
sel.click("//div[@aria-labelledby='ui-dialog-title-new_event_dialog']//button")
self.wait_for_activities()
sel.open("calendar")
sel.wait_for_page_to_load("30000")
sel.wait_for_condition("selenium.isTextPresent('My Event')", "10000")
self.failUnless(sel.is_text_present("My Event"))
sel.type("//input[@name='searchable-text']", "My Event")
sel.click("//input[@id='submit-search']")
sel.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "4000")
self.failUnless(sel.is_element_present("//td[@id=\"event-date\"]"))
sel.open("calendar")
sel.wait_for_page_to_load("30000")
sel.click("//span[@class=\"addcal\"]")
sel.wait_for_condition("selenium.isElementPresent(\"portal_type\")", "10000")
sel.select("//select[@name=\"portal_type\"]", "Note")
sel.type("//input[@name=\"title\"]", "My Second Event")
sel.type("//textarea[@name=\"event_text_content\"]", "Second Event")
sel.type("//input[@name=\"start_date_hour\"]",localtime().tm_hour + 1)
sel.type("//input[@name=\"stop_date_hour\"]", localtime().tm_hour + 1)
sel.key_press("//input[@name=\"stop_date_hour\"]", "\\13")
self.wait_for_activities()
sel.open("calendar")
sel.wait_for_page_to_load("30000")
sel.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
sel.type("//input[@name='searchable-text']", "My Second Event")
sel.click("//input[@id='submit-search']")
sel.wait_for_condition("selenium.browserbot.findElementOrNull('loadingpannel').style.display == 'none'", "10000");
sel.wait_for_condition("selenium.isElementPresent('//td[@id=\"event-date\"]')", "2000")
self.failUnless(sel.is_element_present("//td[@id=\"event-date\"]"))
sel.open("calendar")
sel.wait_for_page_to_load("30000")
sel.type("//input[@name='searchable-text']", "My Second Event")
sel.key_press("//input[@name='searchable-text']", "\\13")
self.failIf(sel.is_text_present("No Results"))
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
import urllib2
from time import sleep
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(BaseUNGTest):
def test_ung_docs(self):
#XXX when gadgets are enabled, this test may fail
# due to delay loading gadgets on every load of a page
#XXX the action of rename a document, clicking on 'document-title'
# may fail. I think, due to delay on animation when clicking to
# rename the document, and then clicking it again
# because selenium can do it really fast
sel = self.selenium
#XXX may slowing down the speed it may test pass every time it's runned
#sel.set_speed(1000)
#XXX even slowing down steps, the action of rename a document
# still fails saving the new name, and the 'document-title' remains
# showing the last one ('Web Page')
self.init()
self.login_as_default_user()
#set default tree view as All Documents (tree opened or not)
self.set_default_tree_view()
sel.open("ERP5Site_createNewWebDocument?template=web_illustration_template")
sel.wait_for_page_to_load("30000")
url = sel.get_eval('selenium.browserbot.getCurrentWindow().location').split('?')[0]
try:
sel.set_timeout(1)
sel.open(url + "/setTextContent?value=%s" % SVG_CONTENT)
except:
pass
finally:
sel.set_timeout(30000)
sel.open(url + "/WebIllustration_viewEditor?editable_mode:int=1")
sel.wait_for_page_to_load("30000")
#XXX had to change
#sel.wait_for_condition("selenium.isElementPresent(\"//ellipse[@id='svg_1']\")", "9000")
sel.select_frame("//iframe[@id='svgframe']")
sel.wait_for_condition("window.document.getElementById('svg_1')", "1000")
self.assertEqual("46", sel.get_eval("window.document.getElementById('svg_1').ry.baseVal.value"))
sel.select_window('null')
self.assertEqual("Web Illustration", sel.get_text("//a[@name=\"document_title\"]"))
self.assertEqual("Draft", sel.get_text("//a[@name=\"document_state\"]"))
sel.click("//a[@name=\"document_title\"]")
sleep(2)
self.assertEqual("Rename Document", sel.get_text("//span[@id=\"ui-dialog-title-edit_document\"]"))
self.assertEqual("Edit More Properties", sel.get_text("//p[@id=\"more_properties\"]"))
sel.click("//p[@id=\"more_properties\"]")
sleep(2)
#XXX the "popup" is not complete handled when selenium closes window
#so, needs to wait window to complete close before openning it again
#maybe its a BUG
sel.click("//span[@class=\"ui-icon ui-icon-closethick\"]")
sleep(2)
sel.click("//a[@name=\"document_title\"]")
sleep(2)
sel.type("//input[@id=\"name\"]", "Functional UNG Test")
#XXX same behaviour as before, maybe it's also a bug
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/span")
sel.wait_for_page_to_load("30000")
self.assertEqual("Functional UNG Test", sel.get_text("//a[@name=\"document_title\"]"))
self.failIf(sel.is_text_present("All Documents"))
sel.click("//a[@class=\"ung_docs\"]")
sel.wait_for_page_to_load("30000")
self.assertEqual("All Documents", sel.get_text("//button[@class=\"tree-open\"]"))
self.go_home(wait_for_activities=1)
sel.type("//input[@name=\"field_your_search_text\"]", "Functional UNG Test")
sel.click("//input[@value=\"Search Docs\"]")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_text_present("No result."))
sel.open("ERP5Site_createNewWebDocument?template=web_table_template")
sel.wait_for_page_to_load("30000")
self.assertEqual("Web Table", sel.get_text("//a[@name=\"document_title\"]"))
self.failUnless(sel.is_element_present("//td[@id='0_table0_cell_c0_r1']"))
self.failUnless(sel.is_element_present("//td[@id='0_table0_cell_c1_r1']"))
self.assertEqual("Spreadsheet Playground", sel.get_text("//td[@id=\"jSheetTitle_0\"]"))
self.assertEqual("MENU", sel.get_text("//td[@id=\"jSheetMenu_0\"]/span[@class=\"rootVoice\"]"))
sel.run_script("$(\"#0_table0_cell_c0_r0\").html(\"Gabriel\")")
sel.run_script("$(\"#0_table0_cell_c1_r1\").html(\"Monnerat\")")
sel.click("//button[@class=\"save\"]")
sel.wait_for_page_to_load("30000")
self.assertEqual("Gabriel", sel.get_text("//td[@id='0_table0_cell_c0_r0']"))
self.assertEqual("Monnerat", sel.get_text("//td[@id='0_table0_cell_c1_r1']"))
sel.open("ERP5Site_createNewWebDocument?template=web_page_template")
sel.wait_for_page_to_load("30000")
self.assertEqual("Web Page", sel.get_text("//a[@name=\"document_title\"]"))
sel.click("//div[@class=\"action_menu\"]/li/ul/li[1]/a")
sel.wait_for_page_to_load("30000")
self.assertEqual("Cancelled", sel.get_text("//a[@name=\"document_state\"]"))
sel.click("//a[@class=\"ung_docs\"]")
sel.wait_for_page_to_load("30000")
self.assertEqual("All Documents", sel.get_text("//button[@class='tree-open']"))
sel.click("//div[@class=\"favorite\"]/a[2]")
sel.wait_for_page_to_load("30000")
self.assertEqual("All Documents", sel.get_text("//button[@class='tree-open']"))
sel.click("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr[1]/td[1]/input")
sel.click("//button[@class=\"delete\"]")
sel.wait_for_page_to_load("30000")
self.go_home(clear_cache=1, wait_for_activities=1)
sel.click("//table[@class=\"your_listbox-table-domain-tree\"]/tbody/tr[11]/td/button")
sel.wait_for_page_to_load("30000")
sel.set_timeout("30000")
self.failIf(sel.is_text_present("No result."))
self.assertEqual("Deleted", sel.get_text("//table/tbody/tr[1]/td[4]"))
sel.click("//input[@title='Check All']")
sel.click("//button[@class=\"delete\"]")
sel.wait_for_page_to_load("30000")
self.assertEqual("No result.", sel.get_text("//td[@class=\"listbox-table-no-result-row\"]/span"))
self.assertEqual("Trash", sel.get_text("//button[@class='tree-open']"))
sel.click("//table[@class=\"your_listbox-table-domain-tree\"]/tbody/tr[3]/td/button")
sel.wait_for_page_to_load("30000")
self.assertEqual("No result.", sel.get_text("//td[@class=\"listbox-table-no-result-row\"]/span"))
self.assertEqual("Hidden", sel.get_text("//button[@class='tree-open']"))
# Test the abbreviation of the title
sel.open("ERP5Site_createNewWebDocument?template=web_page_template")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sleep(2)
sel.type("//input[@id=\"name\"]", "Add a Big Title to Test the abbreviation")
sleep(1)
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/span")
sel.wait_for_page_to_load("30000")
sleep(1)
self.assertEqual("Add a Big Title to Test the ab...", sel.get_text("//a[@name=\"document_title\"]"))
sel.click("//a[@name=\"document_title\"]")
sleep(2)
self.assertEqual("Add a Big Title to Test the abbreviation", sel.get_value("//input[@id=\"name\"]"))
sel.open("")
sel.wait_for_page_to_load("30000")
sel.click("//div[@id=\"select_language\"]/li/ul/li/span[@id=\"fr\"]")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present("Aide"))
sel.click("//div[@id=\"select_language\"]/li/ul/li/span[@id=\"en\"]")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present("Help"))
#XXX this is done because of a XXX note made below code of file uploads
self.set_default_tree_view()
#find path file
test_file_path = self.get_test_file_path("tiolive-ERP5.Freedom.TioLive.Spreadsheet-001-en.ods")
for index in range(2):
sel.click("//a[@class=\"ung_docs\"]")
sel.wait_for_page_to_load("30000")
sel.click("//input[@id=\"upload\"]")
sel.select("//select[@name=\"portal_type\"]", "Web Table")
sel.click("//input[@id=\"submit_document\"]")
self.assertEqual("Please input a file", sel.get_text("//span[@id='no-input-file']"))
self.failUnless(sel.is_text_present("Loading..."))
self.failUnless(sel.is_element_present("//input[@id=\"upload-file\"]"))
sel.type("//input[@id=\"upload-file\"]", test_file_path)
sel.click("//input[@id=\"submit_document\"]")
sel.wait_for_page_to_load("30000")
sel.wait_for_condition("selenium.isTextPresent(\"Opening\")", "30000")
sel.wait_for_page_to_load("30000")
#XXX needs to enable a System Preference with Cloudooo
sel.wait_for_condition("selenium.isElementPresent(\"//a[@name='document_title']\")", "30000")
self.failUnless(sel.is_text_present("TioLive Spreadsheet"))
self.assertEqual("1", sel.get_attribute("//td[@id='0_table0_cell_c0_r1']@sdval"))
self.assertEqual("2", sel.get_attribute("//td[@id='0_table0_cell_c1_r1']@sdval"))
sel.click("//a[@class=\"ung_docs\"]")
sel.wait_for_page_to_load("30000")
sel.click("//input[@id=\"upload\"]")
sel.select("//select[@name=\"portal_type\"]", "Web Page")
sel.type("//input[@id=\"upload-file\"]", test_file_path)
sel.click("//input[@id=\"submit_document\"]")
sel.wait_for_page_to_load("30000")
sel.wait_for_condition("selenium.isTextPresent(\"Opening\")", "30000")
sel.wait_for_page_to_load("30000")
sel.wait_for_condition("selenium.isElementPresent(\"//a[@name='document_title']\")", "30000")
self.failUnless(sel.is_text_present("TioLive Spreadsheet"))
sel.click("//a[@class=\"ung_docs\"]")
sel.wait_for_page_to_load("30000")
sel.open("ERP5Site_createNewWebDocument?template=web_page_template")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sleep(2)
sel.type("//input[@id=\"name\"]", "Cancelled Document")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]/span")
sel.wait_for_page_to_load("30000")
sleep(1)
sel.click("//div[@class=\"action_menu\"]/li/ul/li[1]/a")
sel.wait_for_page_to_load("30000")
sel.click("//a[@class=\"ung_docs\"]")
sel.wait_for_page_to_load("30000")
#XXX needs to click 'All Documents' tree again -- selecting it before
#uploading the first file
sel.click("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr[1]/td[1]/input")
sel.click("//button[@class=\"delete\"]")
sel.wait_for_page_to_load("30000")
self.go_home(wait_for_activities=1)
sel.click("//table[@class=\"your_listbox-table-domain-tree\"]/tbody/tr[11]/td/button") #Trash
sel.wait_for_page_to_load("30000")
self.assertEqual("Cancelled Document", sel.get_text("//table/tbody/tr[1]/td[3]"))
sel.click("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr[1]/td[1]/input")
sel.click("//button[@class=\"delete\"]")
sel.wait_for_page_to_load("30000")
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
import re
class TestUNGGadgetInUNGDocs(BaseUNGTest):
def test_ung_gadget_in_ung_docs(self):
sel = self.selenium
self.init()
self.login_as_default_user()
self.failUnless(sel.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.assertEqual("Add gadgets", sel.get_text("//a[@id=\"add-gadgets\"]/span"))
self.failIf(sel.is_text_present("Join ERP5 Network !"))
self.failIf(sel.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
sel.click("//a[@id=\"add-gadgets\"]")
self.failUnless(sel.is_text_present("Add Gadget"))
sel.click("//input[@id=\"erp5_documentation\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
self.failUnless(sel.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
self.failIf(sel.is_element_present("//div[@id=\"page_wrapper\"]/div[1]/h4"))
sel.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]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
self.assertEqual("Add gadgets", sel.get_text("//a[@id=\"add-gadgets\"]/span"))
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_rss\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.assertEqual("Feed Reader", sel.get_text("//span[@class=\"gadget_title\"]"))
sel.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]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
# Test add two gadgets
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_documentation\"]")
sel.click("//input[@id=\"erp5_rss\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.assertEqual("Feed Reader", sel.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
sel.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]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_element_present("//div[@id=\"portal-column-0\"]/div[2]/h3/span/a[@title=\"Remove\"]"))
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
sel.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]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("?reset:int=1")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_element_present("//a[@class=\"clickable-block block-remove\"]"))
# Test gadget with different users
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_documentation\"]")
sel.click("//input[@id=\"erp5_rss\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.wait_for_activities()
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
#XXX user already created
# sel.click("//td[@id=\"new-account-form\"]")
# sel.type("//input[@name=\"firstname\"]", "Another")
# sel.type("//input[@name=\"lastname\"]", "User")
# sel.type("//input[@name=\"email\"]", "example2@example.com")
# sel.type("//input[@name=\"login_name\"]", "ung_user2")
# sel.type("//input[@name=\"password\"]", "1234")
# sel.type("//input[@name=\"confirm\"]", "1234")
# sel.click("//input[@value=\"Create Account\"]")
# sel.wait_for_page_to_load("30000")
sel.type("__ac_name", "ung_user2")
sel.type("__ac_password", "1234")
sel.click("//input[@type=\"submit\"]")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
self.failIf(sel.is_text_present("Join ERP5 Network !"))
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_worklists\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", sel.get_text("//span[@class=\"gadget_title\"]"))
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
self.login_as_default_user()
self.assertNotEqual("ERP5 Worklists", sel.get_text("//span[@class=\"gadget_title\"]"))
self.assertEqual("Feed Reader", sel.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
sel.type("__ac_name", "zope")
sel.type("__ac_password", "zope")
sel.click("//input[@type=\"submit\"]")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_text_present("Please use link (Add gadgets) to prepare it yourself."))
sel.click("//a[@id=\"add-gadgets\"]")
sel.click("//input[@id=\"erp5_worklists\"]")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.assertEqual("ERP5 Worklists", sel.get_text("//span[@class=\"gadget_title\"]"))
sel.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]$", sel.get_confirmation()))
self.wait_for_activities()
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
self.login_as_default_user()
self.assertNotEqual("ERP5 Worklists", sel.get_text("//span[@class=\"gadget_title\"]"))
self.assertEqual("Feed Reader", sel.get_text("//span[@class=\"gadget_title\"]"))
self.failUnless(sel.is_text_present("Join ERP5 Network !"))
#XXX clean gadgets from all users after test
# maybe using KnowledgePad tool
# url: http://localhost:18080/erp5/portal_skins/erp5_web_ung_theme/WebSection_viewMenuWidget/pt_editForm
# starting at <div class="front_pad">
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
class TestUNGLogin(BaseUNGTest):
def test_ung_login(self):
sel = self.selenium
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", sel.get_text("//button[@class='tree-open']"))
self.assertEqual("Settings", sel.get_text("//a[@id='settings']"))
self.failUnless(sel.is_text_present("Web Illustration"))
self.failUnless(sel.is_text_present("Web Page"))
self.failUnless(sel.is_text_present("Web Table"))
#XXX: the user used on test's instance is 'nsi'
self.failUnless(sel.is_text_present("test_user"))
sel.click("link=Sign out")
sel.wait_for_page_to_load(5000)
self.failUnless(sel.is_text_present("Welcome to UNG Web Office"))
self.failUnless(sel.is_text_present("Create an account now"))
sel.click("//td[@id='new-account-form']")
sel.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" />
# sel.type("__ac_name", "ung_user")
# sel.type("__ac_password", "1234")
# sel.click("//input[@type='submit']")
# sel.wait_for_page_to_load(5000)
# try: self.assertEqual("ung_user", sel.get_text("//div[@class=\' navigation-right\']/fieldset/div[2]/div/div/a[2]"))
# except AssertionError, e: self.verificationErrors.append(str(e))
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
#from tr to sel.
#search: \<tr\>.*\n.*\<td\>(.*)\<\/td\>.*\n.*\<td\>(.*)\<\/td\>.*\n.*\<td\>(.*)\<\/td\>.*\n.*\<\/tr\>
#replace: sel.\1(\2, \3)
#from sel.verifyTextNotPresent to sel.failIf
#search: sel.verifyTextNotPresent\((.*)\)
#replace: self.failIf(sel.is_text_present(\1))
#from sel.verifyTextPresent to sel.failUnless
#search: sel.verifyTextPresent\((.*), \"\"\)
#replace: self.failUnless(sel.is_text_present(\1))
#search: waitForCondition
#replace: wait_for_condition
#attention here to the '?' after .*, making the regular expression un-greedy
#search: sel.is_element_present\((.*?)\)
#replace: str(str(sel.is_element_present(\1)).lower()).lower()
#search: sel.verifyAttribute\((.*), (.*)\)
#replace: try: self.assertEqual(\2, sel.get_attribute(\1))
# except AssertionError, e: self.verificationErrors.append(str(e))
#search: self.assertEqual("checked",
#replace: self.assertEqual(u'true',
#search: sel.openAndWait\((.*), \"\"\)
#replace: sel.open(\1)\n sel.wait_for_page_to_load(5000)
#no search para wait_for_condition(
#replace o " de dentro do elemento por \"
class TestUNGSettings(BaseUNGTest):
def test_ung_settings(self):
sel = self.selenium
self.login_as_default_user()
#<tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/init" />
#<tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/login" />
self.failIf(sel.is_text_present('Text Format'))
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.failUnless(sel.is_text_present("Text Format"))
self.failUnless(sel.is_text_present("FCK Editor"))
sel.check("//input[@value=\'fck_editor\']")
sel.check("//input[@value=\'text/html\']")
sel.click("//html/body/div[3]/div[11]/div/button[1]")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'fck_editor\']@checked"))
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text/html\']@checked"))
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
sel.check("//input[@value=\'text_area\']")
sel.check("//input[@value=\'text/plain\']")
sel.click("//html/body/div[3]/div[11]/div/button[1]")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text/plain\']@checked"))
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text_area\']@checked"))
sel.click("//span[@class=\'ui-icon ui-icon-closethick\']")
sel.open("WebSite_logout")
sel.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 t#o be created once a time
# next ones, just login
## sel.click("//td[@id='new-account-form']")
# # sel.type("//input[@name='firstname']", "Another")
# sel#.type("//input[@name='lastname']", "User")
# sel.type(#"//input[@name='email']", "example2@example.com")
# # sel.type("//input[@name='login_name']", "ung_use#r2")
# sel.type("//input[@name='password']", "1#234")
# sel.type("//input[@name='confirm']", "1234")
# sel.click("//input[@value='Create Account']")
# sel.wait_for_page_to_load(30000)
sel.type("__ac_name", "ung_user2")
sel.type("__ac_password", "1234")
sel.click("//input[@type='submit']")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
sel.check("//input[@value=\'fck_editor\']")
sel.check("//input[@value=\'text/html\']")
sel.click("//html/body/div[3]/div[11]/div/button[1]")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
sel.check("//input[@value=\'fck_editor\']")
sel.check("//input[@value=\'text/html\']")
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
sel.click("//html/body/div[3]/div[11]/div/button[1]")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'fck_editor\']@checked"))
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text/html\']@checked"))
sel.open("WebSite_logout")
sel.wait_for_page_to_load(5000)
sel.type("__ac_name", "test_user")
sel.type("__ac_password", "test_user")
sel.click("//input[@type='submit']")
sel.wait_for_page_to_load(5000)
sel.click("//a[@id='settings']")
sel.wait_for_condition("selenium.isElementPresent(\"//input[@name=\'field_my_preferred_text_editor\']\")", "3000")
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text_area\']@checked"))
self.assertEqual(u'true', sel.get_attribute("//input[@value=\'text/plain\']@checked"))
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
class TestUNGShareDocumentInUNGDocs(BaseUNGTest):
def test_ung_share_document_in_ung_docs(self):
sel = self.selenium
self.init()
self.login_as_default_user()
self.set_default_tree_view()
sel.open("ERP5Site_createNewWebDocument?template=web_page_template")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.type("//input[@id=\"name\"]", "Document Shared")
sel.click("//p[@id=\"more_properties\"]")
sel.type("//input[@id=\"version\"]", "002")
sel.type("//input[@id=\"language\"]", "pt-br")
sel.type("//textarea[@id=\"keyword_list\"]", "My Subject")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", sel.get_value("//input[@id=\"version\"]"))
self.assertEqual("pt-br", sel.get_value("//input[@id=\"language\"]"))
self.assertEqual("My Subject", sel.get_value("//textarea[@id=\"keyword_list\"]"))
self.assertEqual("Document Shared", sel.get_value("//input[@id=\"name\"]"))
sel.click("//a[@id=\"share_document\"]")
sel.wait_for_page_to_load("30000")
self.assertEqual("Shared", sel.get_text("//a[@name=\"document_state\"]"))
document_url = sel.get_text("//span[@id=\"sharing_url\"]")
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
#XXX this could be changed (for a generic approach) to //button[@value='ung_domain/shared.0']
sel.click("//table[@class=\"your_listbox-table-domain-tree\"]/tbody/tr[9]/td/button")
sel.wait_for_page_to_load("30000")
self.failIf(sel.is_text_present("No Result"))
self.assertEqual("Shared by me", sel.get_text("//button[@class=\"tree-open\"]"))
sel.click("//div[@id='wrapper_navigation']/div[2]/fieldset/div[2]/div/div/a[5]")
sel.wait_for_page_to_load("30000")
#XXX user already created
# sel.click("//td[@id=\"new-account-form\"]")
# sel.type("//input[@name=\"firstname\"]", "Another")
# sel.type("//input[@name=\"lastname\"]", "User")
# sel.type("//input[@name=\"email\"]", "example2@example.com")
# sel.type("//input[@name=\"login_name\"]", "ung_user2")
# sel.type("//input[@name=\"password\"]", "1234")
# sel.type("//input[@name=\"confirm\"]", "1234")
# sel.click("//input[@value=\"Create Account\"]")
# sel.wait_for_page_to_load("30000")
sel.type("__ac_name", "ung_user2")
sel.type("__ac_password", "1234")
sel.click("//input[@type=\"submit\"]")
sel.wait_for_page_to_load("30000")
sel.open(document_url)
sel.wait_for_page_to_load("30000")
self.assertEqual("Document Shared", sel.get_text("//a[@name=\"document_title\"]"))
sel.click("//a[@name=\"document_title\"]")
sel.click("//p[@id=\"more_properties\"]")
self.assertEqual("002", sel.get_value("//input[@id=\"version\"]"))
self.assertEqual("pt-br", sel.get_value("//input[@id=\"language\"]"))
self.assertEqual("My Subject", sel.get_value("//textarea[@id=\"keyword_list\"]"))
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
sel.open("WebSite_logout")
sel.wait_for_page_to_load("30000")
self.login_as_default_user()
sel.click("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr/td[3]/a")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.click("//p[@id=\"more_properties\"]")
sel.type("//input[@id=\"version\"]", "003")
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.click("//p[@id=\"more_properties\"]")
self.assertEqual("003", sel.get_value("//input[@id=\"version\"]"))
#XXX this test delete all documents here
# but it won't be done
if __name__ == "__main__":
unittest.main()
from base import BaseUNGTest
import unittest
import time
class TestUNGSubjectList(BaseUNGTest):
def test_ung_subject_list(self):
sel = self.selenium
# <tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/init" />
self.init()
#XXX: by orders, can't create user on test's instance. So, using default user
# <tal:block metal:use-macro="here/Zuite_CommonTemplateForUNG/macros/create-user" />
self.login_as_default_user()
#XXX should catalog handle selections with float points?
# because searches (from subjects) like 1231423.453 and 3454353.4234 return same results"
# that I think are all results searched discarding the float number
test_subject_time = int(time.time())
#FIXME: sometimes, when selenium leave last browser opened on Subject sections, when browser open again,
#the subject list is opened by default, instead of the "All documents", different from what occurs on a normal browser
#where All documents is always listed by default on a new page
#set default tree view as All Documents (tree opened or not)
self.set_default_tree_view()
sel.open("ERP5Site_createNewWebDocument?template=web_page_template")
sel.wait_for_page_to_load('30000')
sel.click("//a[@name='document_title']")
sel.click("//p[@id='more_properties']") #"Edit More Properties"
sel.type("//textarea[@id='keyword_list']", "UNG Test Subject %d" % test_subject_time)
sel.click("//div[@class='ui-dialog-buttonset']/button[1]")
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_element_present("//meta[@content='UNG Test Subject %d']" % test_subject_time))
self.go_home(clear_cache=1)
self.failIf(sel.is_text_present("Ung test subject %d" % test_subject_time))
self.go_home(clear_cache=1, wait_for_activities=1)
self.set_default_tree_view()
sel.click("//button[@value='ung_domain/by_subject.0']")
sel.wait_for_page_to_load('30000')
#XXX precisa dessa condition? ela esta falhando sempre sem pdb, faca o que eu fizer
# sel.wait_for_condition("selenium.isTextPresent(\"Ung test subject %d\")" % test_subject_time, "30000")
self.assertEqual("Ung test subject %d" % test_subject_time, sel.get_text("//button[@value='ung_domain/by_subject/subject_UNG Test Subject %d.1']" % test_subject_time))
self.failUnless(sel.is_element_present("//button[@value='ung_domain/by_subject/subject_UNG Test Subject %d.1']" % test_subject_time))
sel.click("//tr[@class='your_listbox-data-line-0 DataA']/td[3]/a")
sel.wait_for_page_to_load('30000')
sel.click("//a[@name='document_title']")
sel.click("//p[@id='more_properties']") #"Edit More Properties"
sel.run_script("document.getElementById('keyword_list').value = 'UNG Test VPN %(time)d\\nUNG Test Cloudooo %(time)d'" % {'time' : test_subject_time})
sel.click("//div[@class='ui-dialog-buttonset']/button[1]")
sel.wait_for_page_to_load('30000')
self.go_home(clear_cache=1)
#XXX it's already opened
#sel.click("//button[@value='ung_domain/by_subject.0']")
# sel.wait_for_page_to_load('30000')
#assert that when changing subjects, the old subjects (existing anymore) are not presented anymore
self.failIf(sel.is_element_present("//button[@value='ung_domain/by_subject/subject_UNG Subject %d.1']" % test_subject_time))
self.failUnless(sel.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, sel.get_text("//button[@value='ung_domain/by_subject/subject_UNG Test VPN %d.1']" % test_subject_time))
self.failUnless(sel.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, sel.get_text("//button[@value='ung_domain/by_subject/subject_UNG Test Cloudooo %d.1']" % test_subject_time))
sel.open("ERP5Site_createNewWebDocument?template=web_table_template")
sel.wait_for_page_to_load("30000")
sel.click("//a[@name=\"document_title\"]")
sel.type("//input[@id=\"name\"]", "Document Sample")
sel.click("//p[@id=\"more_properties\"]")
sel.type("//textarea[@id=\"keyword_list\"]", "UNG Test Web Table Subject %d" % test_subject_time)
sel.click("//div[@class=\"ui-dialog-buttonset\"]/button[1]")
sel.wait_for_page_to_load("30000")
self.clear_cache()
self.wait_for_activities()
sel.open("")
sel.wait_for_page_to_load("30000")
#XXX by_subject is already selected -- i think it's not correct
#TODO: find if this is correct behaviour (by_subject already selected)
#sel.click("//button[@value='ung_domain/by_subject.0']")
#sel.wait_for_page_to_load(3000)
#XXX precisa dessa condition? ela esta falhando sempre sem pdb, faca o que eu fizer
# tinha a condition aqui para o elemento que pega-se texto logo abaixo, basta recriar a linha
#import ipdb; ipdb.set_trace()
self.assertEqual("Ung test web table subject %d" % test_subject_time, sel.get_text("//button[@value='ung_domain/by_subject/subject_UNG Test Web Table Subject %d.1']" % test_subject_time))
sel.click("//button[@value='ung_domain/by_subject/subject_UNG Test Web Table Subject %d.1']" % test_subject_time)
sel.wait_for_page_to_load("30000")
self.failUnless(sel.is_element_present("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr[1]/td[1]/input"))
self.failUnless(sel.is_element_present("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr[1]/td[2]/input"))
#assert only one element is present, because only one 'table' element was created
self.failIf(sel.is_element_present("//table[@class=\"listbox your_listbox your_listbox-table\"]/tbody/tr[2]/td[1]/input"))
if __name__ == "__main__":
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment