def test_join_action(self): """ 企业账号报名活动 """ index = ("text", "首页") my_org = ("id", "com.fs.wawh:id/logo") action = ("id", "com.fs.wawh:id/action_item_logo") apply = ("id", "com.fs.wawh:id/tv_release") name = ("id", "com.fs.wawh:id/et_name") phone = ("id", "com.fs.wawh:id/et_phone") apply_join = ("id", "com.fs.wawh:id/tv_join") find_element(self.driver, index).click() find_element(self.driver, my_org).click() find_element(self.driver, action).click() find_element(self.driver, apply).click() find_element(self.driver, name).send_keys("林生") find_element(self.driver, phone).send_keys("13427906733") find_element(self.driver, apply_join).click() # 判断是否成功报名活动 succeed = ("text", "已报名活动") assert assert_element_exist(self.driver, succeed) == True sleep(3) self.driver.close_app() print("已报名活动")
def test_logout(self): """ 退出登录 """ mine = ("text", "我的") setting = ("text", "设置") logout = ("id", "com.fs.wawh:id/btn_login") logout_sure = ("id", "com.fs.wawh:id/btn_right") find_element(self.driver, mine).click() # 滑动页面至设置 sleep(1) swipeUp(self.driver, 500, 1) find_element(self.driver, setting).click() find_element(self.driver, logout).click() find_element(self.driver, logout_sure).click() # 滑动页面至登录/注册 sleep(2) swipeDown(self.driver, 500, 1) # 判断是否已退出登录 login_regist_bot = ("text", "登录/注册") assert assert_element_exist(self.driver, login_regist_bot) == True sleep(3) #self.driver.close_app() print("退出登录成功") self.driver.quit()
def test_add_address(self): """ 新增地址 """ mine = ("text", "我的") address_manage = ("text", "地址管理") add_address = ("id", "com.fs.wawh:id/my_address_add_button") address_name = ("id", "com.fs.wawh:id/add_address_name_edit") address_phone = ("id", "com.fs.wawh:id/add_address_phone_edit") address_postal_code = ("id", "com.fs.wawh:id/add_address_postal_code_text") address_area = ("id", "com.fs.wawh:id/add_address_address_show_text") area_sure = ("id", "com.fs.wawh:id/btn_sure") address_detailed = ("id", "com.fs.wawh:id/add_address_detailed_address_edit") address_save = ("id", "com.fs.wawh:id/add_address_save_button") find_element(self.driver, mine).click() # 我的 # 滑动页面至地址管理 sleep(1) swipeUp(self.driver, 500, 1) find_element(self.driver, address_manage).click() # 地址管理 find_element(self.driver, add_address).click() # 新增收货地址 add_address_name = 'huang' find_element(self.driver, address_name).send_keys(add_address_name) # 姓名 find_element(self.driver, address_phone).send_keys('13700001010') # 联系电话 find_element(self.driver, address_postal_code).send_keys('518000') # 邮政编码 find_element(self.driver, address_area).click() # 所在区域 find_element(self.driver, area_sure).click() # 确认区域 find_element(self.driver, address_detailed).send_keys( '天安数码城天吉大厦CD座4楼4D1、4D2室') # 详细地址 find_element(self.driver, address_save).click() # 保存 # 判断是否新增成功 list_address_name = ("text", add_address_name) assert assert_element_exist(self.driver, list_address_name) == True self.driver.close_app() print("新增地址成功")
def test_01_login_org(self): """ 组织账户登录 """ mine = ("text", "我的") login_regist_bot = ("text", "登录/注册") login_tpye_password = ("id", "com.fs.wawh:id/tv_login_type") username = ("id", "com.fs.wawh:id/user_login_id") password = ("id", "com.fs.wawh:id/user_login_password") login_bot = ("id", "com.fs.wawh:id/btn_login") search_key = ("text", "惠州市社会组织总会") sleep(3) find_element(self.driver, mine).click() find_element(self.driver, login_regist_bot).click() find_element(self.driver, login_tpye_password).click() find_element(self.driver, username).clear() find_element(self.driver, username).send_keys("13700001010") find_element(self.driver, password).send_keys("qwe123456") find_element(self.driver, login_bot).click() assert assert_element_exist(self.driver, search_key) == True sleep(3) self.driver.close_app() print("登录成功")
def test_add_news(self): """ 组织账号发布资讯 """ # 获取设备分辨率,此设备为 1080*1920 size = self.driver.get_window_size() x = (size['width']) y = (size['height']) # 获取实时发布时间作为标题 time = datetime.datetime.now().strftime news_dt = time('%Y-%m-%d %H:%M:%S') news_title_text = "发布资讯测试" + news_dt mine = ("text", "我的") home_page_bot = ("id", "com.fs.wawh:id/btn_home_page") fab_up = ("id", "com.fs.wawh:id/fab_up") release_news_bot = ("id", "com.fs.wawh:id/btn_release_actions") news_title = ("id", "com.fs.wawh:id/et_register_content") find_element(self.driver, mine).click() find_element(self.driver, home_page_bot).click() find_element(self.driver, fab_up).click() find_element(self.driver, release_news_bot).click() find_element(self.driver, news_title).send_keys(news_title_text) # 资讯类型 700 447 1030 510 sleep(1) self.driver.tap([(x * 0.65, y * 0.24), (x * 0.95, y * 0.26)], 100) sleep(1) # 955 1230 1020 1260 self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100) sleep(1) # 分类 700 597 1030 660 self.driver.tap([(x * 0.65, y * 0.32), (x * 0.95, y * 0.34)], 100) sleep(1) self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100) # 资讯图片 add_photo = ("id", "com.fs.wawh:id/add_photo") image = ("id", "com.fs.wawh:id/image_view_album_image") image_select = ("id", "com.fs.wawh:id/image_view_image_select") add_image = ("id", "com.fs.wawh:id/menu_item_add_image") find_element(self.driver, add_photo).click() find_element(self.driver, image).click() find_element(self.driver, image_select).click() find_element(self.driver, add_image).click() # 资讯介绍 news_content = ("id", "com.fs.wawh:id/et_info") find_element(self.driver, news_content).send_keys( "利用生活实践经验引入教学生活处处有数学。教学时,在观察中讲理旦罚测核爻姑诧太超咖论,从实践中引入概念,增加学生对概念的理解和兴趣。" ) # 发布资讯 release_news = ("id", "com.fs.wawh:id/tv_commit") find_element(self.driver, release_news).click() # 判断是否发布成功 succeed = ("text", "提交成功") assert assert_element_exist(self.driver, succeed) == True self.driver.close_app() print("发布资讯成功")
def test_02_add_ation(self): """ 组织账号发布活动 """ # 获取设备分辨率,此设备为 1080*1920 size = self.driver.get_window_size() x = (size['width']) y = (size['height']) # 获取实时发布时间作为标题 time = datetime.datetime.now().strftime action_dt = time('%Y-%m-%d %H:%M:%S') ation_title_text = "发布活动测试" + action_dt mine = ("text", "我的") home_page_bot = ("id", "com.fs.wawh:id/btn_home_page") fab_up = ("id", "com.fs.wawh:id/fab_up") release_ations_bot = ("id", "com.fs.wawh:id/btn_release_news") ation_title = ("id", "com.fs.wawh:id/et_register_content") find_element(self.driver, mine).click() find_element(self.driver, home_page_bot).click() find_element(self.driver, fab_up).click() find_element(self.driver, release_ations_bot).click() find_element(self.driver, ation_title).send_keys(ation_title_text) join_time = ("id", "com.fs.wawh:id/tv_join_time") time_int = int(time('%d')) time_str = str(time_int) join_start_time = ("text", time_str) start_time_ok = ("id", "com.fs.wawh:id/tv_ok") ation_time = ("id", "com.fs.wawh:id/tv_activity_time") ation_start_time = ("text", time_str) # 报名时间 find_element(self.driver, join_time).click() find_element(self.driver, join_start_time).click() sleep(1) self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100) sleep(1) swipeUp(self.driver, 1000, 1) sleep(1) find_element(self.driver, join_start_time).click() sleep(1) self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100) sleep(1) find_element(self.driver, start_time_ok).click() # 活动时间 find_element(self.driver, ation_time).click() find_element(self.driver, ation_start_time).click() sleep(1) self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100) sleep(1) swipeUp(self.driver, 1000, 1) sleep(1) find_element(self.driver, ation_start_time).click() sleep(1) self.driver.tap([(x * 0.88, y * 0.64), (x * 0.93, y * 0.65)], 100) sleep(1) find_element(self.driver, start_time_ok).click() action_locate_sure = ("id", "com.fs.wawh:id/btn_sure") action_locate_detail = ("id", "com.fs.wawh:id/et_locate_detail") host_unit = ("text", "请输入举办单位") action_cost = ("text", "请输入活动费用") action_num = ("text", "请输入报名人数") join_limit_num = ("text", "请输入报名限制人数") # 活动地点 sleep(1) self.driver.tap([(x * 0.65, y * 0.46), (x * 0.95, y * 0.47)], 100) find_element(self.driver, action_locate_sure).click() # 详细地址 find_element(self.driver, action_locate_detail).send_keys("香密湖街道办天安数码城天吉大厦") # 举办单位 find_element(self.driver, host_unit).send_keys("深圳市壹办公科技股份有限公司") # 活动费用 find_element(self.driver, action_cost).send_keys("80") # 活动人数 find_element(self.driver, action_num).send_keys("50") # 滑动页面 sleep(1) swipeUp(self.driver, 500, 1) # 报名限制人数 find_element(self.driver, join_limit_num).send_keys("3") # 活动图片 add_photo = ("id", "com.fs.wawh:id/add_photo") image = ("id", "com.fs.wawh:id/image_view_album_image") image_select = ("id", "com.fs.wawh:id/image_view_image_select") add_image = ("id", "com.fs.wawh:id/menu_item_add_image") find_element(self.driver, add_photo).click() find_element(self.driver, image).click() find_element(self.driver, image_select).click() find_element(self.driver, add_image).click() # 活动介绍 action_content = ("id", "com.fs.wawh:id/et_activity_content") find_element(self.driver, action_content).send_keys( "利用生活实践经验引入教学生活处处有数学。教学时,在观察中讲理旦罚测核爻姑诧太超咖论,从实践中引入概念,增加学生对概念的理解和兴趣。" ) # 发布活动 release_action = ("id", "com.fs.wawh:id/tv_commit") find_element(self.driver, release_action).click() # 判断是否发布成功 succeed = ("text", "提交成功") assert assert_element_exist(self.driver, succeed) == True self.driver.close_app() print("发布活动成功")