def test_edit_address_by_index(init_driver, address, index=1): create_all_db_tables(DB_PRESET["user_addressbook"]) driver = init_driver driver.get(BASE_HOST) HomePage(driver)\ .goto_login()\ .input_email(BASE_USER_EMAIL)\ .input_password(BASE_USER_PASSWORD)\ .login()\ .goto_address_book_page() AddressBookPage(driver).\ goto_editaddress_page_by_index(index).\ fill_address_form(address) with pytest.allure.step( "Take information from edited address record from Add Address form." ): info_from_edited_address = AddressBookPage.get_content_info_from_form( address) with pytest.allure.step( "Take information about edited address on Address Book page."): updated_info_from_address_list = AddressBookPage( driver).get_content_info_by_index(index) with pytest.allure.step( "Retrieving info about successfully updated address."): assert AddressBookPage(driver).get_alert_message_text( ) == Returns.TEXT_SUCCESS_ADDRESS_UPDATED with pytest.allure.step("Compare info about edited address."): assert info_from_edited_address == updated_info_from_address_list HomePage(driver).logout()
def test_add_department_smoke(login_by_cookie): """ 冒烟测试:添加部门 1、首页点击通讯录 2、点击添加部门 3、输入部门名称 4、选择所属部门公司之下的著部门 断言:提示新建部门成功 、 通讯录页面存在该部门的文件夹 """ driver = login_by_cookie IndexPage(driver).click_tab_address_book().click_add_department().input_department_info("12223") address_book = AddressBookPage(driver) assert address_book.get_element_by_text("新建部门成功") assert "12223" in address_book.get_department_text_list
def test_add_member_smoke(login_by_cookie): """ 添加成员: 1、首页点击通讯录页签 2、点击添加成员按钮 3、输入信息 断言:提示保存成功 通讯录有该邮箱的信息 """ driver = login_by_cookie IndexPage(driver).click_tab_address_book().click_add_member_btn().\ add_member_by_email("test","8e898","*****@*****.**") address_book = AddressBookPage(driver) assert address_book.get_element_by_text("保存成功") assert "*****@*****.**" in address_book.get_member_email_list
def test_delete_address_by_index(init_user_db, init_driver, index=1): driver = init_driver AccountPage(driver)\ .goto_address_book_page() with pytest.allure.step( "Take the number of address book records on the page."): previous_address_list = AddressBookPage(driver).records_count() with pytest.allure.step("Delete address book record by index %d." % index): AddressBookPage(driver).delete_record_by_index(index) with pytest.allure.step( "Take len of address list after deleting the record"): updated_address_list = AddressBookPage(driver).records_count() with pytest.allure.step( "Compare the length of the list before and after deleting the record" ): assert previous_address_list - 1 == updated_address_list with pytest.allure.step("Collect id's list from db."): assert len(DbAddress.get_id_list_from_db()) == 1
def test_delete_address_by_index(init_driver, index=1): create_all_db_tables(DB_PRESET["user_addressbook"]) driver = init_driver driver.get(BASE_HOST) HomePage(driver)\ .goto_login()\ .input_email(BASE_USER_EMAIL)\ .input_password(BASE_USER_PASSWORD)\ .login()\ .goto_address_book_page() with pytest.allure.step("Take the number of address book records on the page."): previous_address_list = AddressBookPage(driver).records_count() with pytest.allure.step("Delete address book record by index %d." % index): AddressBookPage(driver).delete_record_by_index(index) with pytest.allure.step("Take len of address list after deleting the record"): updated_address_list = AddressBookPage(driver).records_count() with pytest.allure.step("Compare the length of the list before and after deleting the record"): assert previous_address_list - 1 == updated_address_list HomePage(driver).logout()
def test_edit_address_by_index(init_user_db, init_driver, address, index=1): driver = init_driver AccountPage(driver)\ .goto_address_book_page()\ .goto_editaddress_page_by_index(index)\ .fill_address_form(address) with pytest.allure.step( "Take information from edited address record from Add Address form." ): info_from_edited_address = AddressBookPage.get_content_info_from_form( address) with pytest.allure.step( "Take information about edited address on Address Book page."): updated_info_from_address_list = AddressBookPage( driver).get_content_info_by_index(index) with pytest.allure.step( "Retrieving info about successfully updated address."): assert AddressBookPage(driver).get_alert_message_text( ) == Returns.TEXT_SUCCESS_ADDRESS_UPDATED with pytest.allure.step("Compare info about edited address."): assert info_from_edited_address == updated_info_from_address_list
def test_add_correctly_address(init_driver, address_data): driver = init_driver driver.get(BASE_HOST) with pytest.allure.step("Go to Address Book page."): HomePage(driver)\ .goto_login()\ .input_email(BASE_USER_EMAIL)\ .input_password(BASE_USER_PASSWORD)\ .login()\ .goto_address_book_page() with pytest.allure.step( "Collect address book list from Address Book page."): previous_address_list = AddressBookPage( driver).get_content_info_from_list() with pytest.allure.step("Create new address book record."): AddressBookPage(driver)\ .goto_add_address_page()\ .fill_address_form(address_data) with pytest.allure.step( "Collect address book list from Address Book page with new record." ): updated_address_list = AddressBookPage( driver).get_content_info_from_list() with pytest.allure.step("Take information from new address record."): info_from_new_address = AddressBookPage( driver).get_content_info_from_form(address_data) with pytest.allure.step("Append info from new record into old list."): previous_address_list.append(info_from_new_address) with pytest.allure.step( "Retrieving info about successfully added address."): assert AddressBookPage(driver).get_alert_message_text( ) == Returns.TEXT_SUCCESS_ADDRESS_ADDED with pytest.allure.step("Compare old and new lists."): assert sorted(previous_address_list, key=attrgetter('content')) == sorted( updated_address_list, key=attrgetter('content')) HomePage(driver).logout()
def click_tab_address_book(self): """点击通讯录""" self.click_element(self.__tab_address_book) return AddressBookPage(self.driver)