def run(self): self.ensure_logged_off() # TODO(mvel): Add contest manager role self.perform_login_as_admin() self.gotoPage("/ctx") self.gotoUrlByLinkText(u"Добавить работу") inp_fio = u"Участник_Олимпиады_" + random_crap.random_text(6) inp_email = random_crap.randomEmail() inp_comment = random_crap.random_text(6) work_file = os.getcwd() + "/contest-work-sample.png" with open(work_file, 'w') as f: f.write('q' * 1024) inp_fio = self.fillElementByName("name", inp_fio) _ = self.fillElementByName("mail", inp_email) _ = self.fillElementByName("work", work_file, clear=False) # WTF??? Why 'status', not 'comment'? _ = self.fillElementByName("status", inp_comment) self.clickElementByName("ctx_add_or_edit_form_contestants_x") # check that work appears in the list self.gotoUrlByLinkText(u"Работы") self.assertBodyTextPresent(inp_fio)
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 = "spec_char_page_" + random_crap.random_text(8) inpMenuTitle = "spec_menu_title_" + random_crap.random_text(8) inpPageHeader = "spec_page_header_" + random_crap.random_text(8) inpAlias = "spec/char/page/alias/" + random_crap.random_text(8) 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 defaultPageType = self.getOptionValueById("create-pagetype-selector") if defaultPageType != "content": self.failTest("Default selected page type is not 'content': " + defaultPageType) self.clickElementById("create-page-submit") self.m_menuTitle = inpMenuTitle self.m_pageHeader = inpPageHeader # edit page - click on menu self.gotoUrlByLinkText(inpMenuTitle) pageText = "&<'" pageText = self.fillAceEditorElement(pageText) self.clickElementById("preview-submit") previewElement = "content-text-preview" pageRealText = "&<'" self.assertElementTextById(previewElement, pageRealText, "preview text does not match entered page text. ") self.clickElementById("commit-submit") 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(inpMenuTitle, attribute=self.CONTENT) self.assertElementTextById("content-text", pageRealText, "rendered page text does not match expacted text. ") self.gotoEditPageInPlace() self.assertAceEditorElementText(pageText, "page text after reopening editor does not match entered HTML 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 = "nested/path/page_" + random_crap.random_text(8) inpMenuTitle = "nested/path/page_" + random_crap.random_text(8) inpPageHeader = "nested/path/page_" + random_crap.random_text(8) inpAlias = "nested/path/page/alias" + random_crap.random_text(8) 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.clickElementById("create-page-submit") self.assertBodyTextPresent(u"Недопустимый физический путь страницы") self.closeAdminPanel() self.assertPageNotPresent( "/" + inpAlias, "Page should not be created due to wrong physical path. ")
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 = "../../hacked_page_" + random_crap.random_text(8) inpMenuTitle = "hacked_menu_title_" + random_crap.random_text(8) inpPageHeader = "hacked_header_" + random_crap.random_text(8) inpAlias = "hacked/page/alias/" + random_crap.random_text(8) 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("create-page-submit") self.assertBodyTextPresent(u"Недопустимый физический путь страницы") # ensure that page was not actually created. self.assertUrlNotPresent(inpMenuTitle)
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 = "nested/path/page_" + random_crap.random_text(8) inpMenuTitle = "nested/path/page_" + random_crap.random_text(8) inpPageHeader = "nested/path/page_" + random_crap.random_text(8) inpAlias = "nested/path/page/alias" + random_crap.random_text(8) 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.clickElementById("create-page-submit") self.assertBodyTextPresent(u"Недопустимый физический путь страницы") self.closeAdminPanel() self.assertPageNotPresent("/" + inpAlias, "Page should not be created due to wrong physical path. ")
def add_comment(self): t = self.xtest t.gotoUrlByLinkText(u"Добавить комментарий") comment_text = rc.random_text(40) + "\n" + rc.random_text(50) + "\n" + rc.random_text(30) comment_text = t.fillElementByName("comment_text", comment_text) t.clickElementByName("update-person_comment") t.assertBodyTextPresent(u"Комментарий успешно сохранён") t.goto_back_to_anketa_view() return comment_text
def editCommentToPerson(self, commentLinkId): self.gotoUrlByLinkId(commentLinkId) oldCommentText = self.getElementValueByName("comment_text") newCommentText = random_crap.random_text( 10) + "\n" + oldCommentText + "\n" + random_crap.random_text(6) newCommentText = self.fillElementByName("comment_text", newCommentText) self.clickElementByName("update-person_comment") self.assertBodyTextPresent(u"Комментарий успешно сохранён") self.goto_back_to_anketa_view() return newCommentText
def add_comment(self): t = self.xtest t.gotoUrlByLinkText(u"Добавить комментарий") comment_text = rc.random_text(40) + "\n" + rc.random_text( 50) + "\n" + rc.random_text(30) comment_text = t.fillElementByName("comment_text", comment_text) t.clickElementByName("update-person_comment") t.assertBodyTextPresent(u"Комментарий успешно сохранён") t.goto_back_to_anketa_view() return 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_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_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_admin() self.gotoAdminPanel() self.m_parentPage = u"Главная" self.gotoUrlByLinkText(self.m_parentPage) self.gotoCreatePage() inpPageDir = "test_page_" + random_crap.random_text(8) inpMenuTitle = "menu_title_" + random_crap.random_text(8) inpPageHeader = "page_header_" + random_crap.random_text(8) inpAlias = "new/page/alias/" + random_crap.random_text(8) 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 defaultPageType = self.getOptionValueById("create-pagetype-selector") if defaultPageType != "content": self.failTest("Default selected page type is not 'content': " + defaultPageType) self.clickElementById("create-page-submit") # self.logAdd("Opening editor again after redirection. ") # self.gotoEditPageInPlace() self.m_menuTitle = inpMenuTitle self.m_pageHeader = inpPageHeader # edit page - click on menu self.gotoUrlByLinkText(inpMenuTitle) self.gotoUrlByLinkText(u"Файлы") inpFileName = "SomeNameQQQ" + random_crap.random_text(8) inpFileName = self.fillElementById("attach_target-input", inpFileName) self.clickElementById("upload_attach-submit") self.assertPhpErrors() self.assertBodyTextPresent("No file selected")
def input( self, page_dir=None, menu_title=None, header=None, alias=None, permissions=[], global_page=False, random=False, ): t = self.xtest if page_dir is not None: if random: page_dir += random_crap.random_text(8) self.page_dir = t.fillElementById("create-name-input", page_dir) if menu_title is not None: if random: menu_title += random_crap.random_text(8) self.menu_title = t.fillElementById("menu-title-input", menu_title) if header is not None: if random: header += random_crap.random_text(8) self.header = t.fillElementById("header-input", header) if alias is not None: if random: alias += random_crap.random_text(8) self.alias = t.fillElementById("alias-input", alias) default_page_type = t.getOptionValueById("create-pagetype-selector") if default_page_type != "content": t.failTest("Default selected page type is not 'content': " + default_page_type) # default values t.assertCheckboxValueById("view_#all-checkbox", True) t.assertCheckboxValueById("view_#registered-checkbox", False) for permission in permissions: t.clickElementById("{}-checkbox".format(permission)) if global_page: t.clickElementById("global-checkbox") t.clickElementById("create-page-submit")
def run(self): self.ensure_logged_off() # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_email1 = random_crap.randomEmail() inp_email2 = random_crap.randomEmail() inp_pass1 = random_crap.random_text(10) inp_pass2 = random_crap.random_text(10) inp_name1 = u"Вася " + random_crap.random_text(6) inp_name2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inp_login, email=inp_email1, password=inp_pass1, name=inp_name1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inp_login, email=inp_email2, password=inp_pass2, name=inp_name2, random=False, validate=False, ) self.assertBodyTextNotPresent(u"Пользователь '" + inp_login + u"' успешно создан") self.performLogout() self.logAdd("logging as created first user. ") if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogout() logging.info("try logging as created second user.") if self.perform_login(u2.login, u2.password): self.failTest( "I am able to login as 'second' user with duplicate login and new password. " )
def run(self): self.ensure_logged_off() logging.info("send empty form") self._test_work_submit(file_size=-1, need_success=False, fill_work=False) logging.info("send non-existent file") self._test_work_submit(file_size=-1, need_success=False) logging.info("send small file") self._test_work_submit(file_size=10, need_success=False) logging.info("send large file") self._test_work_submit(file_size=25 * M, need_success=False) # send very large file (does not work) # self._test_work_submit(file_size=80*1000*1000, need_success=False) logging.info("Finally send normal file") self._test_work_submit(file_size=2 * M, need_success=True) # Send a link self.gotoUrlByLinkText(u"Отправить решение", attribute=self.CONTENT) inp_link = u"Бла-бла-бла" + random_crap.random_text(6) self.fillElementByName("fileexchange", inp_link) self.clickElementById("send-contest-submit") self.assertBodyTextPresent(u"Спасибо, Ваше решение принято!") self.assertPhpErrors()
def input_person_data(person): iteration = 0 fmt = u"iteration {0}_{1}" crap_params = 15, ["multiline"] crap_func = random_crap.randomCrap crap_end = " CRAP_END" fav = crap_func(*crap_params) + crap_end ach = crap_func(*crap_params) + crap_end hob = crap_func(*crap_params) + crap_end src = crap_func(*crap_params) + crap_end person.input( # const fields last_name=person.last_name, first_name=u"Пётр", patronymic=u"Сергеевич", birth_date=random_crap.date(), phone=person.phone, cellular=person.cellular, email=person.email, # random crap that can vary from submission to submission school=u"Школа дубликатов № " + random_crap.randomDigits(4), school_city=u"Дублёво-" + random_crap.randomDigits(2), ank_class=random_crap.randomDigits(1) + u" Жэ", skype=random_crap.random_text(8), social_profile=random_crap.randomVkontakte(), favourites=fmt.format(iteration, fav), achievements=fmt.format(iteration, ach), hobby=fmt.format(iteration, hob), lesh_ref=fmt.format(iteration, src), control_question=u"Ампер", ank_mode=True, )
def run(self): self.ensure_logged_off() # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_email1 = random_crap.randomEmail() inp_email2 = random_crap.randomEmail() inp_pass1 = random_crap.random_text(10) inp_pass2 = random_crap.random_text(10) inp_name1 = u"Вася " + random_crap.random_text(6) inp_name2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inp_login, email=inp_email1, password=inp_pass1, name=inp_name1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inp_login, email=inp_email2, password=inp_pass2, name=inp_name2, random=False, validate=False, ) self.assertBodyTextNotPresent(u"Пользователь '" + inp_login + u"' успешно создан") self.performLogout() self.logAdd("logging as created first user. ") if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogout() logging.info("try logging as created second user.") if self.perform_login(u2.login, u2.password): self.failTest("I am able to login as 'second' user with duplicate login and new password. ")
def editCommentToPerson(self, commentLinkId): self.gotoUrlByLinkId(commentLinkId) oldCommentText = self.getElementValueByName("comment_text") newCommentText = random_crap.random_text(10) + "\n" + oldCommentText + "\n" + random_crap.random_text(6) newCommentText = self.fillElementByName("comment_text", newCommentText) self.clickElementByName("update-person_comment") self.assertBodyTextPresent(u"Комментарий успешно сохранён") self.goto_back_to_anketa_view() return newCommentText
def run(self): self.ensure_logged_off() self.goto_root() inp_email = self.m_conf.getValidEmail(1) self.removePreviousUsersWithTestEmail(inp_email) # create new user with ruined memory inp_login = "******" + random_crap.random_text(6) inp_pass = random_crap.random_text(10) inp_name = u"Ruined_Memory_" + random_crap.random_text(6) u = user.User(self) u.create_new_user( login=inp_login, email=inp_email, password=inp_pass, name=inp_name, random=False, ) print "logging as created user. " if not self.perform_login(u.login, u.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogoutFromSite() # we navigate to root page, and see auth panel! self.logAdd("login again and press 'forgot password' button ") self.gotoAuthLink() self.fillElementById("reset-email-input", u.email) self.fillElementById("question-input", self.m_conf.getForgottenPasswordCaptcha()) self.clickElementById("reset_password-submit") if self.perform_login(u.login, u.password): self.failTest("Password was not reset. Old password works fine. ") # set random email to user to avoid problems with duplicate email (may occur only if test fails) self.setUserEmailByAdmin(u.login, random_crap.randomEmail())
def run(self): self.ensure_logged_off() inp_login = "******" + rc.random_text(4) inp_name = u"XSM-Юзер-" u = user.User(self) u.create_new_user( login=inp_login, name=inp_name, random=True, logout_admin=False, manager_rights=True, ) self.closeAdminPanel() 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"Ламерович", email=u.email, random=True, ) self.goto_root() self.performLogoutFromSite() if not self.perform_login(u.login, u.password): self.failTest("Cannot login as newly created user. ") self.gotoCabinet() self.assertBodyTextPresent("XSM") card_caption = u"Карточка участника в XSM" self.assertBodyTextPresent(card_caption) xsm_url_text = person.short_alias() self.gotoUrlByLinkText(xsm_url_text) self.assertBodyTextPresent(person.full_alias(), "We should get into our XSM person card. ") self.goto_root() self.performLogoutFromSite() self.perform_login_as_admin() self.gotoAdminPanel() self.gotoUserList() self.gotoUrlByPartialLinkText(inp_login, "Click on user name in the list") self.assertBodyTextPresent(card_caption, "We should see XSM card link. ") self.gotoUrlByLinkText(person.short_alias(), "Click on XSM card link")
def run(self): self.ensure_logged_off() self.goto_root() inpEMail = self.m_conf.getValidEmail('mail.ru') self.removePreviousUsersWithTestEmail(inpEMail) # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_name = u"Вася Пупкин" + random_crap.random_text(6) u = user.User(self) u.create_new_user( login=inp_login, name=inp_name, random=True, ) print "logging as created user. " if not self.perform_login(u.login, u.password): self.failTest("Cannot login as newly created user. ")
def set_exam_passed(self, exam_line_list): for examLine in exam_line_list: # <a><span>Прослушан</span></a> self.gotoIndexedUrlByLinkText(self.listened_status, examLine, "span") self.setOptionValueByIdAndValue("exam_status-selector", "passed") exam_comment = u"Коммент к сданному зачёту: " + random_crap.random_text( 6) self.fillElementByName("exam_comment", exam_comment) self.clickElementByName("update-exam") self.goto_back_to_person_view() self.assertBodyTextPresent(u"Сдан")
def testAlias(self): self.getElementById("cabinet") self.gotoUrlByLinkText(self.m_parentPage, attribute=self.CONTENT) self.gotoUrlByLinkText(self.page.menu_title, attribute=self.CONTENT) self.gotoEditPageInPlace() # edit alias self.gotoUrlByLinkText(self.page.alias) self.page.input_alias("changed/newpage/alias/" + random_crap.random_text(8)) self.updateAliases() self.wait(3, "wait for redirection") self.goto_alias(self.page.alias) self.assert_page_header(self.page.header, reason="Page header does not match entered header. ")
def testBadAlias(self): self.logAdd("test bad aliases") self.gotoEditPageInPlace() self.gotoUrlByLinkText(self.page.alias) self.page.input_alias("../root/alias~") self.updateAliases(expected_state=u"Alias может содержать только символы") self.page.input_alias("/good/alias/" + random_crap.random_text(6)) self.updateAliases() self.wait(3, "wait for redirection after fixing alias") self.gotoCloseEditor() self.gotoAdminPanel() self.gotoCreatePage( reason="We should successfully enter admin panel, but we cannot see button to create new subpage. " )
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() inpPageDir1 = "nested_alias1_" + random_crap.random_text(4) inpMenuTitle1 = "nested_alias_mt1_" + random_crap.random_text(4) inpPageHeader1 = "nested_alias1_" + random_crap.random_text(4) inpAlias1 = "nested_alias_" + random_crap.random_text(4) + "/level1" inpAlias2 = inpAlias1 + "/level2/" inpPageDir1 = self.fillElementById("create-name-input", inpPageDir1) inpMenuTitle1 = self.fillElementById("menu-title-input", inpMenuTitle1) inpPageHeader1 = self.fillElementById("header-input", inpPageHeader1) inpAlias1 = self.fillElementById("alias-input", inpAlias1) self.clickElementById("create-page-submit") self.gotoUrlByLinkText(self.m_parentPage) self.gotoCreatePage() inpPageDir2 = "nested_alias2_" + random_crap.random_text(4) inpMenuTitle2 = "nested_alias_mt2_" + random_crap.random_text(4) inpPageHeader2 = "nested_alias2_" + random_crap.random_text(4) inpPageDir2 = self.fillElementById("create-name-input", inpPageDir2) inpMenuTitle2 = self.fillElementById("menu-title-input", inpMenuTitle2) inpPageHeader2 = self.fillElementById("header-input", inpPageHeader2) inpAlias2 = self.fillElementById("alias-input", inpAlias2) self.clickElementById("create-page-submit") self.closeAdminPanel() self.goto_alias(inpAlias1) self.assert_page_header(inpPageHeader1) self.goto_alias(inpAlias2) self.assert_page_header(inpPageHeader2)
def run(self): self.ensure_logged_off() person = xsm.Person(self) person.last_name = u"Дубликатов" + random_crap.random_text(5) person.phone = random_crap.phone() person.cellular = random_crap.phone() person.email = random_crap.email() self.add_anketa(person) self.assertBodyTextPresent(self.get_anketa_success_submit_message()) self.add_anketa(person) self.assertBodyTextNotPresent(self.get_anketa_success_submit_message()) self.assertBodyTextPresent(self.get_anketa_duplicate_submit_message()) self.anketa_drilldown(person, jump_into=False) self.change_status(person) self.add_anketa(person) self.assertBodyTextNotPresent(self.get_anketa_success_submit_message()) self.assertBodyTextPresent(self.get_anketa_duplicate_submit_message()) self.check_status(person)
def run(self): self.ensure_logged_off() inp_login1 = "dup_email_" + random_crap.random_text(8) inp_login2 = "dup_email_" + random_crap.random_text(8) inp_email = random_crap.randomEmail() inp_pass1 = random_crap.random_text(10) inp_pass2 = random_crap.random_text(10) inp_name1 = u"Вася " + random_crap.random_text(6) inp_name2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inp_login1, email=inp_email, password=inp_pass1, name=inp_name1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inp_login2, email=inp_email, password=inp_pass2, name=inp_name2, random=False, validate=False, ) self.assertBodyTextNotPresent( u"Пользователь '{}' успешно создан".format(u2.login), "We should get error about duplicate e-mails. ", ) self.performLogout() print "logging as first created user. " if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created first user. ") self.performLogout() print "try logging as second created user. " if self.perform_login(u2.login, u2.password): self.failTest("I was able to login as second user with duplicate e-mail. ")
def input_person_data(person, iteration, random=False): fmt = u"iteration {0}_{1}" if not random: fav = "my_favourites" ach = "some_achievements" hob = "different_hobbies" src = "wtf_source" else: crap_params = 15, ["multiline"] crap_func = random_crap.randomCrap crap_end = " CRAP_END" fav = crap_func(*crap_params) + crap_end ach = crap_func(*crap_params) + crap_end hob = crap_func(*crap_params) + crap_end src = crap_func(*crap_params) + crap_end person.input( # const fields last_name=person.last_name, first_name=u"Егор", patronymic=u"Фёдорович", birth_date=random_crap.date(), phone=person.phone, cellular=person.cellular, email=person.email, # random crap that can vary from submission to submission school=u"Школа спамеров №", school_city=u"Спамерово", ank_class=random_crap.randomDigits(1) + u" Жэ", skype=random_crap.random_text(8), social_profile=random_crap.randomVkontakte(), favourites=fmt.format(iteration, fav), achievements=fmt.format(iteration, ach), hobby=fmt.format(iteration, hob), lesh_ref=fmt.format(iteration, src), control_question=u"Ампер", ank_mode=True, )
def run(self): self.ensure_logged_off() self.goto_root() # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_name = u"Вася Пупкин" + random_crap.random_text(6) u = user.User(self) u.create_new_user( login=inp_login, name=inp_name, random=True, ) logging.info("logging as created user. ") if not self.perform_login(u.login, u.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogoutFromSite() # test wrong auth logging.info("logging in as created user with incorrect password ") if self.perform_login(u.login, "wrong_pass" + u.password): self.failTest("I'm able to login with incorrect password. Auth is broken. ") # and now, test bug with remaining cookies: # we navigate to root page, and see auth panel! logging.info("logging in again as created user. ") if not self.perform_login(u.login, u.password): self.failTest("Cannot login again as newly created user. ") self.gotoCabinet() # let's try to change password. self.gotoUrlByLinkText(u"Сменить пароль") new_pass = u.password + "_new" self.fillElementById("old_passwd-input", u.password) new_pass1 = self.fillElementById("new_passwd-input", new_pass) new_pass2 = self.fillElementById("new_passwd_confirm-input", new_pass) if new_pass1 != new_pass2: raise RuntimeError("Unpredicted input behavior on password change") new_pass = new_pass1 self.clickElementByName("change_my_password") self.assertBodyTextPresent(u"Пароль успешно изменён") self.performLogoutFromAdminPanel() print "logging again as created user with new password" if not self.perform_login(u.login, new_pass): self.failTest("Cannot login again as newly created user with changed password. ") # logout self self.performLogoutFromSite() # and now let's edit user profile. print "now let's edit profile. Logging 3-rd time with new password" if not self.perform_login(u.login, new_pass): self.failTest("Cannot login again for profile info change. ") self.gotoCabinet() # navigate to user profile which is just user login # TODO: BUG, make separate links self.gotoUrlByPartialLinkText(u.login) self.assertBodyTextPresent(self.getWelcomeMessage(u.login)) name_ele = "name-input" email_ele = "email-input" currentDisplayName = self.getElementValueById(name_ele) self.assert_equal( currentDisplayName, u.name, "Display name in user profile does not match name entered on user creation. " ) currentEMail = self.getElementValueById(email_ele) self.assert_equal( currentEMail, u.email, "User e-mail in user profile does not match e-mail entered on user creation. " ) newName = u"Петя Иванов" + random_crap.random_text(6) newEMail = random_crap.randomEmail() newName = self.fillElementById(name_ele, newName) print "New user display name is ", newName newEMail = self.fillElementById(email_ele, newEMail) print "New user e-mail is ", newEMail self.clickElementById("update_me-submit") self.performLogoutFromAdminPanel() print "now let's login again and see updated profile." if not self.perform_login(u.login, new_pass): self.failTest("Cannot login after profile info change. ") self.gotoCabinet() # navigate to user profile which is just user login self.gotoUrlByLinkText(u.login) self.assertBodyTextPresent(u"Привет, " + u.login) currentDisplayName = self.getElementValueById(name_ele) self.assert_equal( currentDisplayName, newName, "Display name in user profile does not match changed user name. " ) currentEMail = self.getElementValueById(email_ele) self.assert_equal(currentEMail, newEMail, "User e-mail in user profile does not match changed user e-mail. ")
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): self.ensure_logged_off() self.goto_root() # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_name = u"Вася Пупкин" + random_crap.random_text(6) u = user.User(self) u.create_new_user( login=inp_login, name=inp_name, random=True, ) logging.info("logging as created user. ") if not self.perform_login(u.login, u.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogoutFromSite() # test wrong auth logging.info("logging in as created user with incorrect password ") if self.perform_login(u.login, "wrong_pass" + u.password): self.failTest( "I'm able to login with incorrect password. Auth is broken. ") # and now, test bug with remaining cookies: # we navigate to root page, and see auth panel! logging.info("logging in again as created user. ") if not self.perform_login(u.login, u.password): self.failTest("Cannot login again as newly created user. ") self.gotoCabinet() # let's try to change password. self.gotoUrlByLinkText(u"Сменить пароль") new_pass = u.password + "_new" self.fillElementById("old_passwd-input", u.password) new_pass1 = self.fillElementById("new_passwd-input", new_pass) new_pass2 = self.fillElementById("new_passwd_confirm-input", new_pass) if new_pass1 != new_pass2: raise RuntimeError("Unpredicted input behavior on password change") new_pass = new_pass1 self.clickElementByName("change_my_password") self.assertBodyTextPresent(u"Пароль успешно изменён") self.performLogoutFromAdminPanel() print "logging again as created user with new password" if not self.perform_login(u.login, new_pass): self.failTest( "Cannot login again as newly created user with changed password. " ) # logout self self.performLogoutFromSite() # and now let's edit user profile. print "now let's edit profile. Logging 3-rd time with new password" if not self.perform_login(u.login, new_pass): self.failTest("Cannot login again for profile info change. ") self.gotoCabinet() # navigate to user profile which is just user login # TODO: BUG, make separate links self.gotoUrlByPartialLinkText(u.login) self.assertBodyTextPresent(self.getWelcomeMessage(u.login)) name_ele = "name-input" email_ele = "email-input" currentDisplayName = self.getElementValueById(name_ele) self.assert_equal( currentDisplayName, u.name, "Display name in user profile does not match name entered on user creation. " ) currentEMail = self.getElementValueById(email_ele) self.assert_equal( currentEMail, u.email, "User e-mail in user profile does not match e-mail entered on user creation. " ) newName = u"Петя Иванов" + random_crap.random_text(6) newEMail = random_crap.randomEmail() newName = self.fillElementById(name_ele, newName) print "New user display name is ", newName newEMail = self.fillElementById(email_ele, newEMail) print "New user e-mail is ", newEMail self.clickElementById("update_me-submit") self.performLogoutFromAdminPanel() print "now let's login again and see updated profile." if not self.perform_login(u.login, new_pass): self.failTest("Cannot login after profile info change. ") self.gotoCabinet() # navigate to user profile which is just user login self.gotoUrlByLinkText(u.login) self.assertBodyTextPresent(u"Привет, " + u.login) currentDisplayName = self.getElementValueById(name_ele) self.assert_equal( currentDisplayName, newName, "Display name in user profile does not match changed user name. ") currentEMail = self.getElementValueById(email_ele) self.assert_equal( currentEMail, newEMail, "User e-mail in user profile does not match changed user e-mail. ")
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() #positive cases inp_login = "******" + ".user." u = user.User(self) u.create_new_user( login=inp_login, random=True, ) logging.info("Created a new user: "******".user" inp_email = random_crap.randomEmail() inp_name = random_crap.random_text(8) inp_pass = random_crap.random_text(8) u.create_new_user( login=inp_login, email=inp_email, password=inp_pass, name=inp_name, random=False, ) logging.info("Created a new user: "******"user." u.create_new_user( login=inp_login, random=True, ) logging.info("Created a new user: "******"Reached negative cases") inp_login = "******" u.create_new_user( login=inp_login, random=True, validate=False, ) self.assertBodyTextPresent(u"Имя пользователя должно начинаться с буквы или цифры") logging.info("Failed to create a new user: "******"@user" u.create_new_user( login=inp_login, random=True, validate=False, ) self.assertBodyTextPresent(u"Имя пользователя должно начинаться с буквы или цифры") logging.info("Failed to create a new user: "******"../usr/login" inp_email = random_crap.randomEmail() inp_name = random_crap.random_text(8) inp_pass = random_crap.random_text(8) u.create_new_user( login=inp_login, email=inp_email, password=inp_pass, name=inp_name, random=False, validate=False, ) self.assertBodyTextPresent(u"Имя пользователя должно начинаться с буквы или цифры") logging.info("Failed to create a new user: " + u.name) self.performLogout()
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): 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 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 = "spec_char_page_" + random_crap.random_text(8) inpMenuTitle = "spec_menu_title_" + random_crap.random_text(8) inpPageHeader = "spec_page_header_" + random_crap.random_text(8) inpAlias = "spec/char/page/alias/" + random_crap.random_text(8) 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 defaultPageType = self.getOptionValueById("create-pagetype-selector") if defaultPageType != "content": self.failTest("Default selected page type is not 'content': " + defaultPageType) self.clickElementById("create-page-submit") self.m_menuTitle = inpMenuTitle self.m_pageHeader = inpPageHeader # edit page - click on menu self.gotoUrlByLinkText(inpMenuTitle) pageText = "&<'" pageText = self.fillAceEditorElement(pageText) self.clickElementById("preview-submit") previewElement = "content-text-preview" pageRealText = "&<'" self.assertElementTextById( previewElement, pageRealText, "preview text does not match entered page text. ") self.clickElementById("commit-submit") 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(inpMenuTitle, attribute=self.CONTENT) self.assertElementTextById( "content-text", pageRealText, "rendered page text does not match expacted text. ") self.gotoEditPageInPlace() self.assertAceEditorElementText( pageText, "page text after reopening editor does not match entered HTML text. " )
def run(self): self.ensure_logged_off() # anketa fill/edit positive test: # 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"Какая-то школа №" + random_crap.randomDigits(4), school_city=u"Магадан-" + random_crap.random_text(5), ank_class=random_crap.randomDigits(1) + u" В", phone=random_crap.phone(), cellular=random_crap.phone(), email=random_crap.email(), control_question=u"ампер", ank_mode=True, random=True, ) # we will be warned about unfilled fields self.assertBodyTextPresent(u"ещё раз") self.clickElementById("submit_anketa-submit") self.assertBodyTextPresent(self.get_anketa_success_submit_message()) self.anketa_drilldown(person) # just check text is on the page. print "Checking that 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) # now, let's edit anketa. 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("anketa_status-selector", "new") # change anketa field and save it. person.input( skype=random_crap.random_text(8), ) self.assertBodyTextPresent(u"Участник успешно сохранён") self.goto_back_to_anketa_view() # check bug self.assertElementTextById("anketa_status-span", u"Новый") self.anketa_drilldown(person, do_login=False)
def run(self): self.ensure_logged_off() inpLogin1 = "cab_email_" + random_crap.random_text(6) inpLogin2 = "cab_email_" + random_crap.random_text(6) inpEMail1 = random_crap.randomEmail() inpEMail2 = random_crap.randomEmail() inpPass1 = random_crap.random_text(10) inpPass2 = random_crap.random_text(10) inpName1 = u"Вася " + random_crap.random_text(6) inpName2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inpLogin1, email=inpEMail1, password=inpPass1, name=inpName1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inpLogin2, email=inpEMail2, password=inpPass2, name=inpName2, random=False, ) print "logging as first created user. " if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created first user. ") self.gotoCabinet() print "test good email" newGoodEMail = self.m_conf.getValidEmail(2) self.fillElementById("email-input", newGoodEMail) self.clickElementById("update_me-submit") badMailMsg = u"пользователь с такой почтой" dataUpdatedMsg = u"Данные обновлены успешно" self.assertBodyTextNotPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextPresent(dataUpdatedMsg) print "Ok. Please check your mailbox for notification. " print "test another good random email" newGoodEMail = random_crap.randomEmail() newGoodEMail = self.fillElementById("email-input", newGoodEMail) self.clickElementById("update_me-submit") self.assertBodyTextNotPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextPresent(dataUpdatedMsg) print "And now test bad e-mail. " newBadEMail = u2.email self.fillElementById("email-input", newBadEMail) self.clickElementById("update_me-submit") self.assertBodyTextPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextNotPresent(dataUpdatedMsg) self.performLogoutFromAdminPanel() print "logging as first created user again. " if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login again as newly created first user. ") self.gotoCabinet() self.assertElementValueById("email-input", newGoodEMail, "Email should remain unchanged after 1st change") self.performLogoutFromAdminPanel() print "logging as second created user. " if not self.perform_login(u2.login, u2.password): self.failTest("I was not able to login as second user. ")
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 create_new_user( self, login=str(), email=str(), password=str(), name=str(), random=False, validate=True, manager_rights=False, login_as_admin=True, logout_admin=True, ): if random: login += "_" + rc.random_text(6) email += "_" + rc.randomEmail() password += "_" + rc.random_text(6) name += "_" + rc.random_text(6) logging.info( "createNewUser(login: '******', email: '%s', password: '******', name: '%s')", login, email, password, name ) if login_as_admin: self.xtest.perform_login_as_admin() self.xtest.gotoAdminPanel() self.xtest.gotoUserList() self.xtest.gotoUrlByLinkText(["Create user", u"Создать пользователя"]) inp_login = self.xtest.fillElementById("login-input", login) logging.info("login = '******'") if inp_login == "": raise RuntimeError("Filled login value is empty!") inpEMail = self.xtest.fillElementById("email-input", email) inpPass1 = self.xtest.fillElementById("password-input", password) logging.info("original pass: '******'".format(password)) inpPass2 = self.xtest.fillElementById("password_confirm-input", password) if inpPass1 != inpPass2: raise RuntimeError("Unpredicted input behavior on password entering") inpPass = inpPass1 logging.info("actual pass: '******'") inpName = self.xtest.fillElementById("name-input", name) # set notify checkbox. # self.clickElementById("notify_user-checkbox") # send form if manager_rights: logging.info("Setting manager rights for user. ") # set manager access level self.xtest.clickElementById("group_ank-checkbox") self.xtest.clickElementByName("create_user") self.login = inp_login self.email = inpEMail self.name = inpName self.password = inpPass if not validate: logging.info("not validating created user, just click create button and shut up. ") return inp_login, inpEMail, inpPass, inpName logging.info("user created, going to user list again to refresh. ") self.xtest.assertBodyTextPresent(u"Пользователь '" + inp_login + u"' успешно создан") # refresh user list (re-navigate to user list) self.xtest.gotoUserList() # enter user profile logging.info("entering user profile. ") profileLink = inp_login # TODO, SITE BUG: make two separate links self.xtest.gotoUrlByPartialLinkText(profileLink) self.xtest.assertBodyTextPresent(u"Учётные данные") self.xtest.assertBodyTextPresent(u"Привилегии") # temporary check method # test user login self.xtest.assertTextPresent("//div[@class='user-ops']", inp_login) # test user creator (root) self.xtest.assertTextPresent("//div[@class='user-ops']", self.xtest.m_conf.get_admin_login()) self.xtest.assertElementValueById("name-input", inpName) self.xtest.assertElementValueById("email-input", inpEMail) # logoff root if logout_admin: self.xtest.performLogout() return inp_login, inpEMail, inpPass, inpName
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")