def input( self, course_title=None, target_class=None, course_desc=None, course_comment=None, random=False, update=True, ): t = self.xtest if course_title is not None: if random: course_title += "_" + rc.randomCrap(4) self.course_title = t.fillElementByName("course_title", course_title) if target_class is not None: self.target_class = t.fillElementByName("target_class", target_class) if course_desc is not None: course_desc += " " + rc.randomCrap(10, ["multiline"]) self.course_desc = t.fillElementByName("course_desc", course_desc) if course_comment is not None: course_comment += " " + rc.randomCrap(10, ["multiline"]) self.course_comment = t.fillElementByName("course_comment", course_comment) if update: t.clickElementByName("update-course")
def input( self, course_title=None, target_class=None, course_desc=None, course_comment=None, random=False, update=True, ): t = self.xtest if course_title is not None: if random: course_title += "_" + rc.randomCrap(4) self.course_title = t.fillElementByName("course_title", course_title) if target_class is not None: self.target_class = t.fillElementByName("target_class", target_class) if course_desc is not None: course_desc += " " + rc.randomCrap(10, ["multiline"]) self.course_desc = t.fillElementByName("course_desc", course_desc) if course_comment is not None: course_comment += " " + rc.randomCrap(10, ["multiline"]) self.course_comment = t.fillElementByName("course_comment", course_comment) if update: t.clickElementByName("update-course")
def run(self): self.ensure_logged_off() self.perform_login_as_admin() self.gotoAdminPanel() self.m_parentPage = u"Главная" self.gotoUrlByLinkText(self.m_parentPage) self.gotoCreatePage() inpPageDir = "dollar_page_" + random_crap.random_text(6) inpMenuTitle = "dollar_title_" + random_crap.random_text(6) inpPageHeader = "dollar_header_" + random_crap.random_text(6) inpAlias = "dollar/plugin/page/" + random_crap.random_text(6) inpPageDir = self.fillElementById("create-name-input", inpPageDir) inpMenuTitle = self.fillElementById("menu-title-input", inpMenuTitle) inpPageHeader = self.fillElementById("header-input", inpPageHeader) inpAlias = self.fillElementById("alias-input", inpAlias) defaultPageType = self.getOptionValueById("create-pagetype-selector") #if defaultPageType != "content": #self.failTest("Default selected page type is not 'content': " + defaultPageType) self.logAdd("Submitting new page") self.clickElementById("create-page-submit") self.wait(1) # edit page - click on menu self.gotoUrlByLinkText(inpMenuTitle) plugin_param = u'complete-bullshit"\\/&' crap1 = random_crap.randomCrap(3) crap2 = random_crap.randomCrap(3) page_text = crap1 + " " + u'${phone:' + slashify( plugin_param) + '}' + " " + crap2 print "Generated page text: '" + page_text + "'" page_text = self.fillAceEditorElement(page_text) print "After ins page text: '" + page_text + "'" self.clickElementById("commit-submit") self.gotoCloseEditor() expected_text = u"{c1} {dp} {c2}".format(c1=crap1, dp=plugin_param, c2=crap2) self.assertElementTextById("content-text", expected_text, "page text does not match expected text. ")
def run(self): self.ensure_logged_off() self.perform_login_as_manager() self.goto_xsm() self.goto_xsm_active() self.goto_xsm_add_person() person = xsm.Person(self) person.input( last_name=u"Статусов", first_name=u"Иннокентий", patronymic=u"Петрович", random=True, ) person.back_to_person_view() self.assertElementTextById("anketa_status-span", u"Активный") self.goto_xsm_change_person_status() self.setOptionValueByIdAndValue("anketa_status-selector", "discuss") comment_text = u"Комментарий к смене статуса " + random_crap.randomCrap(5) comment_text = self.fillElementById("comment_text-text", comment_text) self.clickElementById("update-person_comment-submit") self.goto_back_to_person_view() self.assertBodyTextPresent(u"Статус Активный изменён на Обсуждается") self.assertBodyTextPresent(comment_text)
def run(self): self.ensure_logged_off() self.perform_login_as_editor() self.gotoAdminPanel() self.gotoCreatePage() page = xpage.Page(self) page.input( page_dir="topLevelPage", menu_title="topMenuTitle", header="topPageHeader", alias="top/level/page", global_page=True, ) # edit page - click on menu self.gotoUrlByLinkText(page.menu_title) page_text = random_crap.randomCrap(6) self.logAdd("Generated page text: '" + page_text + "'") page_text = self.fillAceEditorElement(page_text) self.logAdd("Page text after edit: '" + page_text + "'") self.clickElementById("commit-submit") self.gotoCloseEditor() # click on some other menu to change active menu item self.goto_contacts() self.logAdd("Clicking on some other menu item. ") self.logAdd("Clicking on new top-level page menu item, it should be visible") self.gotoUrlByLinkText(page.menu_title, attribute=self.CONTENT) self.assertElementTextById("content-text", page_text, "page text does not match entered text. ") self.assert_page_header(page.header)
def run(self): self.ensure_logged_off() self.perform_login_as_manager() self.goto_xsm() self.goto_xsm_active() self.goto_xsm_add_person() person = xsm.Person(self) person.input( last_name=u"Статусов", first_name=u"Иннокентий", patronymic=u"Петрович", random=True, ) person.back_to_person_view() self.assertElementTextById("anketa_status-span", u"Активный") self.goto_xsm_change_person_status() self.setOptionValueByIdAndValue("anketa_status-selector", "discuss") comment_text = u"Комментарий к смене статуса " + random_crap.randomCrap( 5) comment_text = self.fillElementById("comment_text-text", comment_text) self.clickElementById("update-person_comment-submit") self.goto_back_to_person_view() self.assertBodyTextPresent(u"Статус Активный изменён на Обсуждается") self.assertBodyTextPresent(comment_text)
def run(self): self.ensure_logged_off() self.perform_login_as_editor() self.gotoAdminPanel() self.m_parentPage = u"Главная" self.gotoUrlByLinkText(self.m_parentPage) self.gotoCreatePage() inpPageDir = "hiddenPage_" + random_crap.random_text(6) inpMenuTitle = "hiddenMenuTitle_" + random_crap.random_text(6) inpPageHeader = "hiddenPageHeader_" + random_crap.random_text(6) inpAlias = "hidden/secret/page/" + random_crap.random_text(6) inpPageDir = self.fillElementById("create-name-input", inpPageDir) inpMenuTitle = self.fillElementById("menu-title-input", inpMenuTitle) inpPageHeader = self.fillElementById("header-input", inpPageHeader) inpAlias = self.fillElementById("alias-input", inpAlias) self.clickElementById("menu-hidden-checkbox") defaultPageType = self.getOptionValueById("create-pagetype-selector") if defaultPageType != "content": self.failTest("Default selected page type is not 'content': " + defaultPageType) self.clickElementById("create-page-submit") # edit page - click on menu self.gotoUrlByLinkText(inpMenuTitle) pageText = u"Секретный Скрытый Текст" + random_crap.randomCrap(6) pageText = self.fillAceEditorElement(pageText) self.clickElementById("commit-submit") self.gotoCloseEditor() self.performLogout() # click on some other menu to change active menu item self.logAdd("Clicking on parent menu item. ") self.gotoUrlByLinkText(self.m_parentPage, attribute=self.CONTENT) self.logAdd("Checking new page menu item, it should NOT be visible") self.assertUrlNotPresent(inpMenuTitle) self.logAdd("Alias should work fine") self.gotoPage("/" + inpAlias) self.logAdd("We should see page text") self.assertElementTextById("content-text", pageText, "page text does not match entered text. ") self.assert_page_header( inpPageHeader, reason="Page header does not match entered header. ")
def run(self): self.ensure_logged_off() self.perform_login_as_editor() self.gotoAdminPanel() self.m_parentPage = u"Главная" self.gotoUrlByLinkText(self.m_parentPage) self.gotoCreatePage() inpPageDir = "hiddenPage_" + random_crap.random_text(6) inpMenuTitle = "hiddenMenuTitle_" + random_crap.random_text(6) inpPageHeader = "hiddenPageHeader_" + random_crap.random_text(6) inpAlias = "hidden/secret/page/" + random_crap.random_text(6) inpPageDir = self.fillElementById("create-name-input", inpPageDir) inpMenuTitle = self.fillElementById("menu-title-input", inpMenuTitle) inpPageHeader = self.fillElementById("header-input", inpPageHeader) inpAlias = self.fillElementById("alias-input", inpAlias) self.clickElementById("menu-hidden-checkbox") defaultPageType = self.getOptionValueById("create-pagetype-selector") if defaultPageType != "content": self.failTest("Default selected page type is not 'content': " + defaultPageType) self.clickElementById("create-page-submit") # edit page - click on menu self.gotoUrlByLinkText(inpMenuTitle) pageText = u"Секретный Скрытый Текст" + random_crap.randomCrap(6) pageText = self.fillAceEditorElement(pageText) self.clickElementById("commit-submit") self.gotoCloseEditor() self.performLogout() # click on some other menu to change active menu item self.logAdd("Clicking on parent menu item. ") self.gotoUrlByLinkText(self.m_parentPage, attribute=self.CONTENT) self.logAdd("Checking new page menu item, it should NOT be visible") self.assertUrlNotPresent(inpMenuTitle) self.logAdd("Alias should work fine") self.gotoPage("/" + inpAlias) self.logAdd("We should see page text") self.assertElementTextById("content-text", pageText, "page text does not match entered text. ") self.assert_page_header(inpPageHeader, reason="Page header does not match entered header. ")
def change_status(self, person): self.goto_xsm() self.goto_xsm_anketas() self.gotoUrlByLinkText(person.short_alias()) self.goto_xsm_change_person_status() self.setOptionValueByIdAndValue("anketa_status-selector", "nextyear") comment_text = u"Меняем статус первой анкете: " + random_crap.randomCrap(5) comment_text = self.fillElementById("comment_text-text", comment_text) self.clickElementById("update-person_comment-submit") self.goto_back_to_person_view() new_state = u"Отложен" self.assertBodyTextPresent(u"Статус Новый изменён на {0}".format(new_state)) self.assertBodyTextPresent(comment_text)
def change_status(self, person): self.goto_xsm() self.goto_xsm_anketas() self.gotoUrlByLinkText(person.short_alias()) self.goto_xsm_change_person_status() self.setOptionValueByIdAndValue("anketa_status-selector", "nextyear") comment_text = u"Меняем статус первой анкете: " + random_crap.randomCrap( 5) comment_text = self.fillElementById("comment_text-text", comment_text) self.clickElementById("update-person_comment-submit") self.goto_back_to_person_view() new_state = u"Отложен" self.assertBodyTextPresent( u"Статус Новый изменён на {0}".format(new_state)) self.assertBodyTextPresent(comment_text)
def run(self): self.ensure_logged_off() self.perform_login_as_editor() self.gotoAdminPanel() self.gotoCreatePage() page = xpage.Page(self) page.input( page_dir="topLevelPage", menu_title="topMenuTitle", header="topPageHeader", alias="top/level/page", global_page=True, ) # edit page - click on menu self.gotoUrlByLinkText(page.menu_title) page_text = random_crap.randomCrap(6) self.logAdd("Generated page text: '" + page_text + "'") page_text = self.fillAceEditorElement(page_text) self.logAdd("Page text after edit: '" + page_text + "'") self.clickElementById("commit-submit") self.gotoCloseEditor() # click on some other menu to change active menu item self.goto_contacts() self.logAdd("Clicking on some other menu item. ") self.logAdd( "Clicking on new top-level page menu item, it should be visible") self.gotoUrlByLinkText(page.menu_title, attribute=self.CONTENT) self.assertElementTextById("content-text", page_text, "page text does not match entered text. ") self.assert_page_header(page.header)
def run(self): self.ensure_logged_off() self.perform_login_as_editor() self.gotoAdminPanel() parent_page = u"Главная" self.gotoUrlByLinkText(parent_page) self.gotoCreatePage() page = xpage.Page(self) page.input( page_dir="authPage", menu_title="authMenuTitle", header="authPageHeader", alias="authorized/only/page/", random=True, permissions=["view_#all", "view_#registered"], ) # edit page - click on menu self.gotoUrlByLinkText(page.menu_title) page_text = u"Текст Только Для Авторизованных " + random_crap.randomCrap( 6) page_text = self.fillAceEditorElement(page_text) self.clickElementById("commit-submit") self.gotoCloseEditor() self.performLogout() # click on some other menu to change active menu item self.logAdd("Clicking on parent menu item. ") self.gotoUrlByLinkText(parent_page, attribute=self.CONTENT) self.logAdd("Checking new page menu item, it should NOT be visible") self.assertUrlNotPresent(page.menu_title) self.logAdd( "Alias should NOT work too, we should see access denied page") self.gotoPage("/" + page.alias) self.logAdd("We should NOT see page text at all") self.assertSourceTextNotPresent( page_text, "we should not see page text without authorization. ") self.assertSourceTextNotPresent( page.header, "we should not see page header without authorization. ") self.assertSourceTextPresent(self.STOP_PHRASES, "we should see auth page") inp_login = "******" inp_name = u"Убер Уполномоченный " u = user.User(self) u.create_new_user( login=inp_login, name=inp_name, random=True, ) if not self.perform_login(u.login, u.password): self.failTest("Cannot login as auth-page-test user. ") self.logAdd("Clicking on parent menu item. ") self.gotoUrlByLinkText(parent_page, attribute=self.CONTENT) self.logAdd("Checking new page menu item, it should be visible") self.gotoUrlByLinkText(page.menu_title, attribute=self.CONTENT) self.assertElementTextById( "content-text", page_text, "menu check: page text does not match entered text (under auth). ") self.assert_page_header(page.header) self.logAdd("Clicking on some other menu item. ") self.goto_contacts() self.logAdd( "Alias should work now, and we should NOT see access denied page") self.gotoPage("/" + page.alias) self.assertElementTextById( "content-text", page_text, "alias check: page text does not match entered text (under auth). " ) self.assert_page_header( page.header, reason= "Alias check: page header does not match entered header (under auth). " ) self.assertSourceTextNotPresent(self.STOP_PHRASES)
def run(self): self.ensure_logged_off() # anketa fill positive test: # all fields are filled with correct values. self.goto_root() self.goto_anketa() person = xsm.Person(self) person.input( last_name=u"Чапаев", first_name=u"Василий", patronymic=u"Иваныч", birth_date=random_crap.date(), school=u"Тестовая школа им. В.Е.Бдрайвера №", school_city=u"Школа находится в /var/opt/" + random_crap.random_text(5), ank_class=random_crap.randomDigits(1) + u" Гэ", cellular="+7" + random_crap.randomDigits(9), phone="+7" + random_crap.randomDigits(9), email=random_crap.random_text(10) + "@" + random_crap.random_text(6) + ".ru", skype=random_crap.random_text(12), social_profile=random_crap.randomVkontakte(), favourites=random_crap.randomCrap(20, ["multiline"]), achievements=random_crap.randomCrap(15, ["multiline"]), hobby=random_crap.randomCrap(10, ["multiline"]), lesh_ref=random_crap.randomCrap(10, ["multiline"]), control_question=u"ампер", ank_mode=True, random=True, ) self.assertBodyTextPresent(self.get_anketa_success_submit_message()) inp_social_show = bawlib.cut_http(person.social_profile) self.anketa_drilldown(person) full_alias = person.full_alias() # just check text is on the page. logging.info("Checking that all filled fields are displayed on the page") self.checkPersonAliasInPersonView(full_alias) # TODO(mvel): Extract common checks to module self.assertBodyTextPresent(person.birth_date) self.assertBodyTextPresent(person.school) self.assertBodyTextPresent(person.school_city) self.assertBodyTextPresent(person.ank_class) self.assertBodyTextPresent(person.phone) self.assertBodyTextPresent(person.cellular) self.assertBodyTextPresent(person.email) self.assertBodyTextPresent(person.skype) self.assertBodyTextPresent(inp_social_show) self.clickElementById("show-extra-person-info") self.wait(1) self.assertElementSubTextById("extra-person-info", person.favourites) self.assertElementSubTextById("extra-person-info", person.achievements) self.assertElementSubTextById("extra-person-info", person.hobby) self.assertElementSubTextById("extra-person-info", person.lesh_ref) self.add_comments_to_person(person) # now, let's change anketa status to "Ждет собеседования" self.gotoEditPerson() # first, check that values in opened form match entered in anketa. self.assertElementValueById("last_name-input", person.last_name) self.assertElementValueById("first_name-input", person.first_name) self.assertElementValueById("patronymic-input", person.patronymic) self.assertElementValueById("birth_date-input", person.birth_date) self.assertElementValueById("school-input", person.school) self.assertElementValueById("school_city-input", person.school_city) self.assertElementValueById("ank_class-input", person.ank_class) # current_class should now be equal to ank_class (fresh anketa) self.assertElementValueById("current_class-input", person.ank_class) self.assertElementValueById("phone-input", person.phone) self.assertElementValueById("cellular-input", person.cellular) self.assertElementValueById("email-input", person.email) self.assertElementValueById("skype-input", person.skype) self.assertElementValueById("social_profile-input", person.social_profile) self.assertElementValueById("favourites-text", person.favourites) self.assertElementValueById("achievements-text", person.achievements) self.assertElementValueById("hobby-text", person.hobby) self.assertElementValueById("lesh_ref-text", person.lesh_ref) self.assertElementValueById("anketa_status-selector", "new") # change anketa status and save it. self.setOptionValueByIdAndValue("anketa_status-selector", "progress") self.clickElementById("update-person-submit") self.assertBodyTextPresent(u"Участник успешно сохранён") self.goto_back_to_anketa_view() self.assertElementTextById("anketa_status-span", u"Ждёт собес.")
def run(self): self.ensure_logged_off() # anketa fill positive test: # all fields are filled with correct values. self.goto_root() self.goto_anketa_teacher() person = xsm.Person(self) person.input( last_name=u"Учитель", first_name=u"Алексей", patronymic=u"Иваныч", birth_date=random_crap.date(), school=u"Тестовый ВУЗ им. В.Е.Бдрайвера №", cellular="+7" + random_crap.randomDigits(9), email=random_crap.random_text(10) + "@" + random_crap.random_text(6) + ".ru", social_profile=random_crap.randomVkontakte(), # опыт преподавания achievements=random_crap.randomCrap(15, ["multiline"]), control_question=u"пять", ank_mode=True, random=True, ) self.assertBodyTextPresent(self.get_anketa_teacher_success_submit_message()) inp_social_show = bawlib.cut_http(person.social_profile) self.anketa_drilldown(person) full_alias = person.full_alias() # just check text is on the page. logging.info("Checking that all filled fields are displayed on the page") self.checkPersonAliasInPersonView(full_alias) # TODO(mvel): Extract common checks to module self.assertBodyTextPresent(person.birth_date) self.assertBodyTextPresent(person.school) self.assertBodyTextPresent(person.cellular) self.assertBodyTextPresent(person.email) self.assertBodyTextPresent(inp_social_show) self.clickElementById("show-extra-person-info") self.wait(1) self.assertElementSubTextById("extra-person-info", person.achievements) self.add_comments_to_person(person) # now, let's change anketa status to "Ждет собеседования" self.gotoEditPerson() # first, check that values in opened form match entered in anketa. self.assertElementValueById("last_name-input", person.last_name) self.assertElementValueById("first_name-input", person.first_name) self.assertElementValueById("patronymic-input", person.patronymic) self.assertElementValueById("birth_date-input", person.birth_date) self.assertElementValueById("school-input", person.school) self.assertElementValueById("cellular-input", person.cellular) self.assertElementValueById("email-input", person.email) self.assertElementValueById("social_profile-input", person.social_profile) self.assertElementValueById("anketa_status-selector", "new") # change anketa status and save it. self.setOptionValueByIdAndValue("anketa_status-selector", "progress") self.clickElementById("update-person-submit") self.assertBodyTextPresent(u"Участник успешно сохранён") self.goto_back_to_anketa_view() self.assertElementTextById("anketa_status-span", u"Ждёт собес.")
def run(self): self.ensure_logged_off() self.perform_login_as_editor() self.gotoAdminPanel() parent_page = u"Главная" self.gotoUrlByLinkText(parent_page) self.gotoCreatePage() page = xpage.Page(self) page.input( page_dir="authPage", menu_title="authMenuTitle", header="authPageHeader", alias="authorized/only/page/", random=True, permissions=["view_#all", "view_#registered"], ) # edit page - click on menu self.gotoUrlByLinkText(page.menu_title) page_text = u"Текст Только Для Авторизованных " + random_crap.randomCrap(6) page_text = self.fillAceEditorElement(page_text) self.clickElementById("commit-submit") self.gotoCloseEditor() self.performLogout() # click on some other menu to change active menu item self.logAdd("Clicking on parent menu item. ") self.gotoUrlByLinkText(parent_page, attribute=self.CONTENT) self.logAdd("Checking new page menu item, it should NOT be visible") self.assertUrlNotPresent(page.menu_title) self.logAdd("Alias should NOT work too, we should see access denied page") self.gotoPage("/" + page.alias) self.logAdd("We should NOT see page text at all") self.assertSourceTextNotPresent(page_text, "we should not see page text without authorization. ") self.assertSourceTextNotPresent(page.header, "we should not see page header without authorization. ") self.assertSourceTextPresent(self.STOP_PHRASES, "we should see auth page") inp_login = "******" inp_name = u"Убер Уполномоченный " u = user.User(self) u.create_new_user( login=inp_login, name=inp_name, random=True, ) if not self.perform_login(u.login, u.password): self.failTest("Cannot login as auth-page-test user. ") self.logAdd("Clicking on parent menu item. ") self.gotoUrlByLinkText(parent_page, attribute=self.CONTENT) self.logAdd("Checking new page menu item, it should be visible") self.gotoUrlByLinkText(page.menu_title, attribute=self.CONTENT) self.assertElementTextById( "content-text", page_text, "menu check: page text does not match entered text (under auth). " ) self.assert_page_header(page.header) self.logAdd("Clicking on some other menu item. ") self.goto_contacts() self.logAdd("Alias should work now, and we should NOT see access denied page") self.gotoPage("/" + page.alias) self.assertElementTextById( "content-text", page_text, "alias check: page text does not match entered text (under auth). " ) self.assert_page_header( page.header, reason="Alias check: page header does not match entered header (under auth). " ) self.assertSourceTextNotPresent(self.STOP_PHRASES)
def run(self): self.ensure_logged_off() self.perform_login_as_editor() self.gotoAdminPanel() self.parent_page = u"Главная" self.gotoUrlByLinkText(self.parent_page) self.gotoCreatePage() page = xpage.Page(self) page.input( page_dir="phoenix_", menu_title="phoenix_menu_title_", header="phoenix_header_", alias="removed/phoenix/alias/", random=True, ) # edit page - click on menu self.gotoUrlByLinkText(page.menu_title) pageText = random_crap.randomCrap(10) pageText = self.fillAceEditorElement(pageText) self.clickElementById("commit-submit") self.gotoCloseEditor() self.gotoAdminPanel() self.gotoUrlByLinkText(self.parent_page) self.gotoUrlByLinkText(page.menu_title) self.gotoRemovePage() self.assertBodyTextPresent(u"Удаление страницы") self.clickElementById("delete_page-submit") self.gotoCloseEditor() self.gotoUrlByLinkText(self.parent_page, attribute=self.CONTENT) if self.get_url_by_link_data(page.menu_title, attribute=self.CONTENT, fail=False) is not None: self.failTest("Page should be removed") # create same page again self.gotoAdminPanel() self.gotoUrlByLinkText(self.parent_page) self.gotoCreatePage() page.input( page_dir=page.page_dir, menu_title=page.menu_title, header=page.header, alias=page.alias, ) self.gotoUrlByLinkText(page.menu_title) newPageText = random_crap.randomCrap(10) newPageText = self.fillAceEditorElement(pageText) self.clickElementById("commit-submit") self.gotoCloseEditor() self.gotoUrlByLinkText(self.parent_page, attribute=self.CONTENT) self.gotoUrlByLinkText(page.menu_title, attribute=self.CONTENT) self.assertElementTextById( "content-text", newPageText, "new page text should appear after page reincarnation. ") self.goto_alias(page.alias)
def run(self): self.ensure_logged_off() self.perform_login_as_admin() self.gotoAdminPanel() self.m_parentPage = u"Главная" self.gotoUrlByLinkText(self.m_parentPage) self.gotoCreatePage() inpPageDir = "contlist_dir_" + random_crap.random_text(5) inpMenuTitle = "contlist_mt_" + random_crap.random_text(5) inpPageHeader = "contlist_ph_" + random_crap.random_text(5) inpAlias = "cont/list/page" + random_crap.random_text(5) inpPageDir = self.fillElementById("create-name-input", inpPageDir) inpMenuTitle = self.fillElementById("menu-title-input", inpMenuTitle) inpPageHeader = self.fillElementById("header-input", inpPageHeader) inpAlias = self.fillElementById("alias-input", inpAlias) self.m_pageAlias = inpAlias self.setOptionValueByIdAndValue("create-pagetype-selector", "contlist") pageDate = datetime.datetime.now() self.clickElementById("create-page-submit") # edit page - click on menu self.gotoUrlByLinkText(inpMenuTitle) blockTitle = "block_title_" + random_crap.random_text(5) blockContent = random_crap.randomCrap(10, crapOptions=["multiline"]) blockTitle = self.fillElementById("header-input", blockTitle) blockContent = self.fillElementById("content", blockContent) self.clickElementById("contlist-create-submit") self.wait(3) # we are still on admin page. # get generated alias. blockAlias = self.getElementTextById("edit-alias") self.logAdd("Alias: {0}".format(blockAlias)) self.gotoCloseEditor() self.gotoUrlByLinkText(inpMenuTitle, attribute=self.CONTENT) dateStr = pageDate.strftime("%d.%m.%Y") self.assertElementSubTextById("content-text", dateStr, "Contlist timestamp not found") self.assertElementSubTextById("content-text", blockTitle, "Block title not found in rendered cont-list. ") blockContentForCheck = blockContent.replace("\n", " ").replace(" ", " ") print self.getElementTextById("content-text") print blockContentForCheck self.assertElementSubTextById( "content-text", blockContentForCheck, "Block content not found in rendered cont-list. " ) # check alias # expected: displayed one block with title self.goto_alias(blockAlias) # FIXME(mvel): content-header is not supported in new design? # self.assertElementSubTextById("content-header", blockTitle, "Block title not found after clicking by alias. ") self.assertElementSubTextById( "content-text", blockContentForCheck, "Block content not found after clicking by alias. " )
def testBaseEditing(self): self.perform_login_as_admin() self.gotoAdminPanel() self.m_parentPage = u"Главная" self.gotoUrlByLinkText(self.m_parentPage) self.gotoCreatePage() page = xpage.Page(self) page.input( page_dir="test_page", menu_title="menu_title", header="page_header", alias="new/page/alias/", random=True, ) self.page = page # edit page - click on menu self.gotoUrlByLinkText(page.menu_title) page_text = random_crap.randomCrap(10, self.wordOptions, specialChars=self.specChars) + " " + timestamp() print "Generated page text: '" + page_text + "'" page_text = self.fillAceEditorElement(page_text) print "After ins page text: '" + page_text + "'" self.clickElementById("commit-submit") self.clickElementById("preview-submit") preview_element = "content-text-preview" self.assertElementTextById(preview_element, page_text, "preview text does not match entered page text. ") # add second line new_page_text = ( page_text + "\n" + random_crap.randomCrap(10, self.wordOptions, specialChars=self.specChars) + " " + timestamp() ) new_page_text = self.fillAceEditorElement(new_page_text) print "Generated 2-line page text: '" + new_page_text + "'" self.clickElementById("commit-submit") self.clickElementById("preview-submit") new_page_text_for_check = ( new_page_text .replace("\n", " ") .replace(" ", " ") .replace(">>", u"»") .replace("<<", u"«") .strip() ) self.assertElementTextById( preview_element, new_page_text_for_check, "preview text on text change does not match entered text. " ) self.gotoCloseEditor() self.getElementById("cabinet") # click on menu. self.logAdd("Clicking on parent menu item. ") self.gotoUrlByLinkText(self.m_parentPage, attribute=self.CONTENT) self.logAdd("Clicking on new page menu item. ") self.gotoUrlByLinkText(page.menu_title, attribute=self.CONTENT) self.assertElementTextById( "content-text", new_page_text_for_check, "page text after reopening editor does not match entered text. " ) self.assert_page_header(page.header, reason="Page header does not match entered header. ")
def run(self): self.ensure_logged_off() # anketa fill positive test: # all fields are filled with correct values. self.goto_root() self.goto_anketa_teacher() person = xsm.Person(self) person.input( last_name=u"Учитель", first_name=u"Алексей", patronymic=u"Иваныч", birth_date=random_crap.date(), school=u"Тестовый ВУЗ им. В.Е.Бдрайвера №", cellular="+7" + random_crap.randomDigits(9), email=random_crap.random_text(10) + "@" + random_crap.random_text(6) + ".ru", social_profile=random_crap.randomVkontakte(), # опыт преподавания achievements=random_crap.randomCrap(15, ["multiline"]), control_question=u"пять", ank_mode=True, random=True, ) self.assertBodyTextPresent( self.get_anketa_teacher_success_submit_message()) inp_social_show = bawlib.cut_http(person.social_profile) self.anketa_drilldown(person) full_alias = person.full_alias() # just check text is on the page. logging.info( "Checking that all filled fields are displayed on the page") self.checkPersonAliasInPersonView(full_alias) # TODO(mvel): Extract common checks to module self.assertBodyTextPresent(person.birth_date) self.assertBodyTextPresent(person.school) self.assertBodyTextPresent(person.cellular) self.assertBodyTextPresent(person.email) self.assertBodyTextPresent(inp_social_show) self.clickElementById("show-extra-person-info") self.wait(1) self.assertElementSubTextById("extra-person-info", person.achievements) self.add_comments_to_person(person) # now, let's change anketa status to "Ждет собеседования" self.gotoEditPerson() # first, check that values in opened form match entered in anketa. self.assertElementValueById("last_name-input", person.last_name) self.assertElementValueById("first_name-input", person.first_name) self.assertElementValueById("patronymic-input", person.patronymic) self.assertElementValueById("birth_date-input", person.birth_date) self.assertElementValueById("school-input", person.school) self.assertElementValueById("cellular-input", person.cellular) self.assertElementValueById("email-input", person.email) self.assertElementValueById("social_profile-input", person.social_profile) self.assertElementValueById("anketa_status-selector", "new") # change anketa status and save it. self.setOptionValueByIdAndValue("anketa_status-selector", "progress") self.clickElementById("update-person-submit") self.assertBodyTextPresent(u"Участник успешно сохранён") self.goto_back_to_anketa_view() self.assertElementTextById("anketa_status-span", u"Ждёт собес.")
def run(self): self.ensure_logged_off() self.goto_root() self.goto_anketa() person = xsm.Person(self) # try to submit empty form. person.input(ank_mode=True) self.ensure_not_submitted("Empty form should not be submitted. ") last_name_too_short = u"Поле 'Фамилия' слишком короткое" self.assertBodyTextPresent(last_name_too_short) # generate some text person.last_name = u"Криворучкин" + random_crap.random_text(5) person.first_name = u"Хакер" + random_crap.random_text(3) person.patronymic = u"Ламерович" + random_crap.random_text(3) person.birth_date = random_crap.date() person.school = u"Хакерская школа им. К.Митника №" + random_crap.randomDigits(4) person.school_city = u"Школа находится в /dev/brain/" + random_crap.random_text(5) person.ank_class = random_crap.randomDigits(1) + u"Х" person.phone = random_crap.phone() person.cellular = random_crap.phone() person.email = random_crap.email() person.skype = random_crap.random_text(12) person.social_profile = random_crap.randomVkontakte() social_profile_show = bawlib.cut_http(person.social_profile) favourites = random_crap.randomCrap(20, ["multiline"]) achievements = random_crap.randomCrap(15, ["multiline"]) hobby = random_crap.randomCrap(10, ["multiline"]) # try fill only surname person.input(last_name=person.last_name, ank_mode=True) self.ensure_not_submitted("Only Last name was filled. ") self.assertBodyTextPresent(u"Поле 'Имя' слишком короткое") person.input(first_name=person.first_name, ank_mode=True) self.ensure_not_submitted("Only Last name and First name was filled. ") self.assertBodyTextPresent(u"Поле 'Отчество' слишком короткое") person.input(patronymic=person.patronymic, ank_mode=True) self.ensure_not_submitted("Only FIO values were filled. ") self.assertBodyTextPresent(u"Класс не указан") person.input( birth_date=person.birth_date, school=person.school, school_city=person.school_city, ank_class=person.ank_class, ank_mode=True, ) self.ensure_not_submitted("Phone fields were not filled. ") self.assertBodyTextPresent(u"Укажите правильно хотя бы один из телефонов") person.input( phone=person.phone, cellular=person.cellular, email=person.email, skype=person.skype, social_profile=person.social_profile, ank_mode=True, ) self.ensure_not_submitted("Invalid control question answer. ") self.assertBodyTextPresent(u"Неправильный ответ на контрольный вопрос") person.input(control_question=u"ампер", ank_mode=True) self.ensure_not_submitted("Favourites were not filled") are_you_sure = u"Если Вы уверены, что не хотите указывать эту информацию" self.assertBodyTextPresent(are_you_sure) person.input(favourites=favourites, ank_mode=True) self.ensure_not_submitted("Achievements were not filled") self.assertBodyTextPresent(are_you_sure) person.input(achievements=achievements, ank_mode=True) self.ensure_not_submitted("Hobbies were not filled") self.assertBodyTextPresent(are_you_sure) # and now fill last optional field and erase one of very important fields. person.input( last_name="", hobby=hobby, ank_mode=True, ) self.ensure_not_submitted("Empty last name is not allowed. ") self.assertBodyTextPresent(last_name_too_short) # fill it again. person.input( last_name=u"НаученныйГорькимОпытом" + random_crap.random_text(5), hobby="", ank_mode=True, ) self.ensure_not_submitted("Hobbies were erased") self.assertBodyTextPresent(are_you_sure) # now erase achievements. person.input( achievements="", ank_mode=True, ) self.ensure_not_submitted( "Enter confirmation mode with erased field 'A' " "and remove another field 'B'. Revalidation check after bug #529" ) person.input( hobby=hobby, achievements=achievements, ank_mode=True, ) self.anketa_drilldown(person) # just check text is on the page. logging.info("Checking that all filled fields are displayed on the page. ") self.checkPersonAliasInPersonView(person.full_alias()) self.assertBodyTextPresent(person.birth_date) self.assertBodyTextPresent(person.school) self.assertBodyTextPresent(person.school_city) self.assertBodyTextPresent(person.ank_class) self.assertBodyTextPresent(person.phone) self.assertBodyTextPresent(person.cellular) self.assertBodyTextPresent(person.email) self.assertBodyTextPresent(person.skype) self.assertBodyTextPresent(social_profile_show) self.clickElementById("show-extra-person-info") self.wait(1) self.assertElementSubTextById("extra-person-info", favourites) self.assertElementSubTextById("extra-person-info", achievements) self.assertElementSubTextById("extra-person-info", hobby)
def run(self): return # TODO(nata-skr): finish self.ensure_logged_off() # anketa fill positive test: # all fields are filled with correct values. self.goto_root() self.goto_anketa() person = xsm.Person(self) person.input( last_name=u"Ландау", first_name=u"Лев", patronymic=u"Давидович", birth_date=random_crap.date(), school=u"Тестовая школа им. В.Е.Бдрайвера №", school_city=u"Школа находится в /var/opt/" + random_crap.random_text(5), ank_class=random_crap.randomDigits(1) + u" Гэ", cellular="+7" + random_crap.randomDigits(9), phone="+7" + random_crap.randomDigits(9), email=random_crap.random_text(10) + "@" + random_crap.random_text(6) + ".ru", skype=random_crap.random_text(12), social_profile=random_crap.randomVkontakte(), favourites=random_crap.randomCrap(20, ["multiline"]), achievements=random_crap.randomCrap(15, ["multiline"]), hobby=random_crap.randomCrap(10, ["multiline"]), lesh_ref=random_crap.randomCrap(10, ["multiline"]), control_question=u"ампер", ank_mode=True, ) self.assertBodyTextPresent(self.get_anketa_success_submit_message()) # inp_social_show = bawlib.cut_http(person.social_profile) # now login as admin inp_last_name = person.last_name self.anketa_drilldown(person) # now, let's change anketa status to "Ждет собеседования" self.gotoEditPerson() # change anketa status and save it. self.setOptionValueByIdAndValue("anketa_status-selector", "progress") self.clickElementById("update-person-submit") self.assertBodyTextPresent(u"Участник успешно сохранён") self.gotoUrlByLinkText(u"Лес") # create new person """self.clickElementById("clear_forest-submit") self.gotoUrlByLinkText(u"Добавить участника") self.setOptionValueByIdAndValue("anketa_status-selector", "less") inp_first_name = u"Ричард" + random_crap.random_text(6) inp_last_name = u"Фейнман" + random_crap.random_text(6) inp_first_name = self.fillElementByName("first_name", inp_first_name) inp_last_name = self.fillElementByName("last_name", inp_last_name) self.setOptionValueByIdAndValue("forest_1-selector", "maybe") self.clickElementById("update-person-submit") self.assertBodyTextPresent(u"Участник успешно сохранён") self.gotoUrlByLinkText(u"Лес")""" self.filter_person(fio=inp_last_name) # self.assertBodyTextPresent(u"ХЗ") time.sleep(5) self.doubeClickElementById("p1-forest_1-span") val = selenium_test.get_value(self.getElementById("forest_1-selector")) if val != "undef": self.failTest("Incorrect value in forest selector") logging.info("Element value: {0}".format(val)) self.setOptionValueByIdAndValue("forest_1-selector", "no") self.assertBodyTextPresent(u"Не идёт") time.sleep(5) self.doubeClickElementById("p1-forest_1-span") val = selenium_test.get_value(self.getElementById("forest_1-selector")) if val != "no": self.failTest("Incorrect value in forest selector")
def run(self): self.ensure_logged_off() self.goto_root() self.goto_anketa() person = xsm.Person(self) # try to submit empty form. person.input(ank_mode=True) self.ensure_not_submitted("Empty form should not be submitted. ") last_name_too_short = u"Поле 'Фамилия' слишком короткое" self.assertBodyTextPresent(last_name_too_short) # generate some text person.last_name = u"Криворучкин" + random_crap.random_text(5) person.first_name = u"Хакер" + random_crap.random_text(3) person.patronymic = u"Ламерович" + random_crap.random_text(3) person.birth_date = random_crap.date() person.school = u"Хакерская школа им. К.Митника №" + random_crap.randomDigits( 4) person.school_city = u"Школа находится в /dev/brain/" + random_crap.random_text( 5) person.ank_class = random_crap.randomDigits(1) + u"Х" person.phone = random_crap.phone() person.cellular = random_crap.phone() person.email = random_crap.email() person.skype = random_crap.random_text(12) person.social_profile = random_crap.randomVkontakte() social_profile_show = bawlib.cut_http(person.social_profile) favourites = random_crap.randomCrap(20, ["multiline"]) achievements = random_crap.randomCrap(15, ["multiline"]) hobby = random_crap.randomCrap(10, ["multiline"]) # try fill only surname person.input(last_name=person.last_name, ank_mode=True) self.ensure_not_submitted("Only Last name was filled. ") self.assertBodyTextPresent(u"Поле 'Имя' слишком короткое") person.input(first_name=person.first_name, ank_mode=True) self.ensure_not_submitted("Only Last name and First name was filled. ") self.assertBodyTextPresent(u"Поле 'Отчество' слишком короткое") person.input(patronymic=person.patronymic, ank_mode=True) self.ensure_not_submitted("Only FIO values were filled. ") self.assertBodyTextPresent(u"Класс не указан") person.input( birth_date=person.birth_date, school=person.school, school_city=person.school_city, ank_class=person.ank_class, ank_mode=True, ) self.ensure_not_submitted("Phone fields were not filled. ") self.assertBodyTextPresent( u"Укажите правильно хотя бы один из телефонов") person.input( phone=person.phone, cellular=person.cellular, email=person.email, skype=person.skype, social_profile=person.social_profile, ank_mode=True, ) self.ensure_not_submitted("Invalid control question answer. ") self.assertBodyTextPresent(u"Неправильный ответ на контрольный вопрос") person.input(control_question=u"ампер", ank_mode=True) self.ensure_not_submitted("Favourites were not filled") are_you_sure = u"Если Вы уверены, что не хотите указывать эту информацию" self.assertBodyTextPresent(are_you_sure) person.input(favourites=favourites, ank_mode=True) self.ensure_not_submitted("Achievements were not filled") self.assertBodyTextPresent(are_you_sure) person.input(achievements=achievements, ank_mode=True) self.ensure_not_submitted("Hobbies were not filled") self.assertBodyTextPresent(are_you_sure) # and now fill last optional field and erase one of very important fields. person.input( last_name="", hobby=hobby, ank_mode=True, ) self.ensure_not_submitted("Empty last name is not allowed. ") self.assertBodyTextPresent(last_name_too_short) # fill it again. person.input( last_name=u"НаученныйГорькимОпытом" + random_crap.random_text(5), hobby="", ank_mode=True, ) self.ensure_not_submitted("Hobbies were erased") self.assertBodyTextPresent(are_you_sure) # now erase achievements. person.input( achievements="", ank_mode=True, ) self.ensure_not_submitted( "Enter confirmation mode with erased field 'A' " "and remove another field 'B'. Revalidation check after bug #529") person.input( hobby=hobby, achievements=achievements, ank_mode=True, ) self.anketa_drilldown(person) # just check text is on the page. logging.info( "Checking that all filled fields are displayed on the page. ") self.checkPersonAliasInPersonView(person.full_alias()) self.assertBodyTextPresent(person.birth_date) self.assertBodyTextPresent(person.school) self.assertBodyTextPresent(person.school_city) self.assertBodyTextPresent(person.ank_class) self.assertBodyTextPresent(person.phone) self.assertBodyTextPresent(person.cellular) self.assertBodyTextPresent(person.email) self.assertBodyTextPresent(person.skype) self.assertBodyTextPresent(social_profile_show) self.clickElementById("show-extra-person-info") self.wait(1) self.assertElementSubTextById("extra-person-info", favourites) self.assertElementSubTextById("extra-person-info", achievements) self.assertElementSubTextById("extra-person-info", hobby)
def testDiffAndLongText(self): self.logAdd("test diff engine. ") self.wait(2) self.gotoUrlByLinkText(self.m_parentPage, attribute=self.CONTENT) self.gotoUrlByLinkText(self.page.menu_title, attribute=self.CONTENT) self.gotoEditPageInPlace() wordNumber = 7 totalLines = 8 origLines = [ random_crap.randomCrap(wordNumber, self.wordOptions, specialChars=self.specChars) for _ in xrange(0, totalLines) ] pageText = linesToHtml(origLines) pageText = self.fillAceEditorElement(pageText) print "diff test page text original: " print pageText print "-" * 30 self.clickElementById("commit-submit") # insert one line insLine = random_crap.randomCrap(wordNumber, self.wordOptions, specialChars=self.specChars) # remove some lines inside newLines = origLines[:3] + [insLine] + origLines[3:5] + origLines[7:] pageText = linesToHtml(newLines) pageText = self.fillAceEditorElement(pageText) print "diff test page new text: " print pageText print "-" * 30 self.clickElementById("commit-submit") # cut last line newLines = newLines[:-1] pageText = linesToHtml(newLines) pageText = self.fillAceEditorElement(pageText) self.clickElementById("commit-submit") pageWords = (" ".join(newLines)).split() print "word count ", len(pageWords) sampleWords = pageWords[5:9] + pageWords[24:27] + pageWords[30:32] for sample in sampleWords: print "replacing word: ", sample replacement = random_crap.randomCrap(4, self.wordOptions, specialChars=self.specChars) print "replacement: ", replacement pageText = pageText.replace(sample, replacement) self.logAdd("diff test page new text after word-replacement: ") self.logAdd(pageText) self.logAdd("-" * 30) pageText = self.fillAceEditorElement(pageText) self.clickElementById("commit-submit") self.gotoCloseEditor() realPageText = ( pageText .replace("<p>", "") .replace("\n", " ") .replace("</p> ", "\n") .replace("</p>", "\n") .strip() ) self.logAdd("real page text: ") self.logAdd(realPageText) self.logAdd("-" * 30) self.assertElementTextById("content-text", realPageText, "real page text does not match entered text. ")
def run(self): self.ensure_logged_off() self.perform_login_as_editor() self.gotoAdminPanel() self.parent_page = u"Главная" self.gotoUrlByLinkText(self.parent_page) self.gotoCreatePage() page = xpage.Page(self) page.input( page_dir="phoenix_", menu_title="phoenix_menu_title_", header="phoenix_header_", alias="removed/phoenix/alias/", random=True, ) # edit page - click on menu self.gotoUrlByLinkText(page.menu_title) pageText = random_crap.randomCrap(10) pageText = self.fillAceEditorElement(pageText) self.clickElementById("commit-submit") self.gotoCloseEditor() self.gotoAdminPanel() self.gotoUrlByLinkText(self.parent_page) self.gotoUrlByLinkText(page.menu_title) self.gotoRemovePage() self.assertBodyTextPresent(u"Удаление страницы") self.clickElementById("delete_page-submit") self.gotoCloseEditor() self.gotoUrlByLinkText(self.parent_page, attribute=self.CONTENT) if self.get_url_by_link_data(page.menu_title, attribute=self.CONTENT, fail=False) is not None: self.failTest("Page should be removed") # create same page again self.gotoAdminPanel() self.gotoUrlByLinkText(self.parent_page) self.gotoCreatePage() page.input( page_dir=page.page_dir, menu_title=page.menu_title, header=page.header, alias=page.alias, ) self.gotoUrlByLinkText(page.menu_title) newPageText = random_crap.randomCrap(10) newPageText = self.fillAceEditorElement(pageText) self.clickElementById("commit-submit") self.gotoCloseEditor() self.gotoUrlByLinkText(self.parent_page, attribute=self.CONTENT) self.gotoUrlByLinkText(page.menu_title, attribute=self.CONTENT) self.assertElementTextById( "content-text", newPageText, "new page text should appear after page reincarnation. " ) self.goto_alias(page.alias)