1:附上部分test_page包web
from test_locator.add_address_locator import AddAddressLocator from test_page.base_page import BasePage class AddAddressPage(BasePage): def unite_add_address(self,province_value="25",city_value="321",town_value="2706", detail_address="test",contact_value="zqc",contact_information="18273569617", postal_code="430224"): self.wait_element_visible(AddAddressLocator.add_address_text_loc) self.select_down_element(AddAddressLocator.province_loc,province_value) self.wait_presence_element(AddAddressLocator.shang_hai_loc) self.select_down_element(AddAddressLocator.city_loc,city_value) self.wait_presence_element(AddAddressLocator.xu_hui_loc) self.select_down_element(AddAddressLocator.town_loc,town_value) self.clear_text(AddAddressLocator.detail_address_loc) self.send_value(AddAddressLocator.detail_address_loc,detail_address) self.clear_text(AddAddressLocator.contact_loc) self.send_value(AddAddressLocator.contact_loc,contact_value) self.clear_text(AddAddressLocator.contact_information_loc) self.send_value(AddAddressLocator.contact_information_loc,contact_information) self.clear_text(AddAddressLocator.postal_code_loc) self.send_value(AddAddressLocator.postal_code_loc,postal_code) if self.is_selected(AddAddressLocator.default_address_loc): self.click_element(AddAddressLocator.submit_loc) else: self.click_element(AddAddressLocator.default_address_loc) self.click_element(AddAddressLocator.submit_loc) def query_error_add_address(self,province_value,city_value,town_value, detail_address,contact_value,contact_information, postal_code): self.wait_element_visible(AddAddressLocator.add_address_text_loc) self.select_down_element(AddAddressLocator.province_loc, province_value) self.wait_presence_element(AddAddressLocator.shang_hai_loc) self.select_down_element(AddAddressLocator.city_loc, city_value) self.wait_presence_element(AddAddressLocator.xu_hui_loc) self.select_down_element(AddAddressLocator.town_loc, town_value) self.clear_text(AddAddressLocator.detail_address_loc) self.send_value(AddAddressLocator.detail_address_loc,detail_address) self.clear_text(AddAddressLocator.contact_loc) self.send_value(AddAddressLocator.contact_loc,contact_value) self.clear_text(AddAddressLocator.contact_information_loc) self.send_value(AddAddressLocator.contact_information_loc,contact_information) self.clear_text(AddAddressLocator.postal_code_loc) self.send_value(AddAddressLocator.postal_code_loc, postal_code) if self.is_selected(AddAddressLocator.default_address_loc): self.click_element(AddAddressLocator.submit_loc) else: self.click_element(AddAddressLocator.default_address_loc) self.click_element(AddAddressLocator.submit_loc) self.alter_is_present() return self.deal_alter() def success_query(self,province_value,city_value,town_value, detail_address,contact_value,contact_information, postal_code): self.wait_element_visible(AddAddressLocator.add_address_text_loc) self.select_down_element(AddAddressLocator.province_loc, province_value) self.wait_presence_element(AddAddressLocator.shang_hai_loc) self.select_down_element(AddAddressLocator.city_loc, city_value) self.wait_presence_element(AddAddressLocator.xu_hui_loc) self.select_down_element(AddAddressLocator.town_loc, town_value) self.clear_text(AddAddressLocator.detail_address_loc) self.send_value(AddAddressLocator.detail_address_loc,detail_address) self.clear_text(AddAddressLocator.contact_loc) self.send_value(AddAddressLocator.contact_loc,contact_value) self.clear_text(AddAddressLocator.contact_information_loc) self.send_value(AddAddressLocator.contact_information_loc,contact_information) self.clear_text(AddAddressLocator.postal_code_loc) self.send_value(AddAddressLocator.postal_code_loc, postal_code) if self.is_selected(AddAddressLocator.default_address_loc): self.click_element(AddAddressLocator.submit_loc) else: self.click_element(AddAddressLocator.default_address_loc) self.click_element(AddAddressLocator.submit_loc) self.wait_element_visible(AddAddressLocator.success_query_loc,frequency=0.02) return self.get_element_text(AddAddressLocator.success_query_loc)
from test_locator.address_manage_locator import AddressManageLocator from test_page.base_page import BasePage from test_page.add_address_page import AddAddressPage from selenium.webdriver.common.by import By class AddressManagePage(BasePage): def delete_address(self,value): self.wait_element_visible(AddressManageLocator.add_new_address_loc) act=self.find_elements_back_length(AddressManageLocator.column_loc) delete_loc=(By.XPATH,"//img[@src='/Public/Home/Default/images/shanchu.png']") index=self.find_elements_back_length(AddressManageLocator.column_loc)-2 self.click_elements(delete_loc,index) self.alter_is_present() if value=="1": self.deal_alter(value) self.wait_element_visible(AddressManageLocator.add_new_address_loc) exp=self.find_elements_back_length(AddressManageLocator.column_loc) return act==exp+1 else: self.deal_alter(value) self.wait_element_visible(AddressManageLocator.add_new_address_loc) exp=self.find_elements_back_length(AddressManageLocator.column_loc) return act==exp def modify_address(self,name,detail_address,mobile,post_code): self.wait_element_visible(AddressManageLocator.add_new_address_loc) self.click_elements(AddressManageLocator.modify_address_loc,0) self.wait_element_visible(AddressManageLocator.receipt_address_text_loc) self.wait_presence_element(AddressManageLocator.xu_hui_loc) self.select_down_element(AddressManageLocator.town_loc, "2706") self.clear_text(AddressManageLocator.receipt_person_loc) self.send_value(AddressManageLocator.receipt_person_loc,name) self.clear_text(AddressManageLocator.detail_address_loc) self.send_value(AddressManageLocator.detail_address_loc,detail_address) self.clear_text(AddressManageLocator.contact_mobile_loc) self.send_value(AddressManageLocator.contact_mobile_loc,mobile) self.clear_text(AddressManageLocator.post_code_loc) self.send_value(AddressManageLocator.post_code_loc,post_code) self.click_element(AddressManageLocator.save_address_loc) self.wait_element_visible(AddressManageLocator.detail_address_text_loc) return self.get_element_text(AddressManageLocator.detail_address_text_loc),self.get_element_text(AddressManageLocator.post_code_text_loc),\ self.get_element_text(AddressManageLocator.receipt_person_text_loc),self.get_element_text(AddressManageLocator.contact_mobile_text_loc) def clear_address(self): delete_loc = (By.XPATH, "//img[@src='/Public/Home/Default/images/shanchu.png']") index=self.find_elements_back_length(delete_loc)-1 self.click_elements(delete_loc,index) self.alter_is_present() self.deal_alter() self.wait_element_visible(AddressManageLocator.add_new_address_loc)