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()
This diff is collapsed.
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