def test_01_login(self): '''登录''' LoginPage.LoginPage().wait_page() self.set_fastinput_ime() LoginPage.login(self.test_data['user_name'], self.test_data['password']) print('登录成功')
def test_b_search(self): try: if self.d(resourceId="com.lietou.mishu:id/v_hidden").wait( timeout=6): self.d(resourceId="com.lietou.mishu:id/v_hidden").click() else: print('正常') if self.d(text="您的账号已在其他设备登录,请重新登录").wait(timeout=3): time.sleep(5) self.d(text="确定").click() elif self.d(text="我要招人").wait(timeout=3): self.d(text="我要招人").click() self.d(text="完成").click() elif self.d(resourceId="com.lietou.mishu:id/iv_close").wait( timeout=3): self.d(resourceId="com.lietou.mishu:id/iv_close").click() if self.d(text="跳过,暂时不想填写").wait(timeout=3): self.d(text="跳过,暂时不想填写").click() if self.d(resourceId="com.lietou.mishu:id/iv_to_recruit" ).wait(timeout=5): self.d(resourceId="com.lietou.mishu:id/iv_to_recruit" ).click() if LoginPage.LoginPage().wait_page("密码登录"): self.d(text="密码登录").click() self.d.set_fastinput_ime(True) LoginPage.login() self.d.set_fastinput_ime(False) if self.d(text="我要招人").wait(timeout=5): self.d(text="我要招人").click() self.d(text="完成").click() elif self.d(resourceId="com.lietou.mishu:id/iv_close").wait( timeout=3): self.d(resourceId="com.lietou.mishu:id/iv_close").click() if self.d(text="跳过,暂时不想填写").wait(timeout=3): self.d(text="跳过,暂时不想填写").click() if self.d( resourceId="com.lietou.mishu:id/rl_resume_root" ).wait(timeout=10): self.d( resourceId="com.lietou.mishu:id/iv_to_recruit" ).click() if self.d(text="请选择性别").wait(timeout=3): self.d(resourceId="com.lietou.mishu:id/select_man").click() self.d(text="确认").click() if self.d(resourceId="com.lietou.mishu:id/search").wait( timeout=20): time.sleep(3) # 获取设备系统版本 get_version = self.d.device_info['version'] # get_num = self.get_post_num() post_list = {'HR': 'HRBP', 'UI': 'UI设计师', '市场': '市场专员'} time.sleep(2) # 系统版本兼容 # if get_version < '5.1.1': # if self.d.xpath("//android.view.View/android.widget.ImageView").wait(timeout=5): # self.d.xpath("//android.view.View/android.widget.ImageView").click() # else: # if self.d.xpath("//android.view.ViewGroup/android.widget.ImageView").wait(timeout=5): # self.d.xpath("//android.view.ViewGroup/android.widget.ImageView").click() if self.d(resourceId="com.lietou.mishu:id/search").wait( timeout=3): self.d(resourceId="com.lietou.mishu:id/search").click() for text_name in post_list.keys(): if self.d(text="按职位搜索").wait(timeout=3): self.d(text="请输入关键词多个词请用空格隔开").set_text(text_name) if get_version < '5.1.1': self.d.xpath( "//android.widget.ScrollView/android.view.View" "/android.view.View[contains(@index, 0)]" ).click() else: self.d.xpath( "//android.widget.ScrollView/android.view.ViewGroup" "/android.view.ViewGroup[contains(@index, 0)]" ).click() tmp = 0 while tmp < 5: time.sleep(3) get_version = self.d.device_info['version'] if get_version < '5.1.1': self.d.xpath( "//android.widget.ScrollView/android.view.View" "/android.view.View").click() else: self.d.xpath( "//android.widget.ScrollView/android.view.ViewGroup" "/android.view.ViewGroup").click() if self.d(text="立即沟通").wait(timeout=5): self.d(text="立即沟通").click() if self.d(resourceId= "com.lietou.mishu:id/header_title").wait( timeout=3): print(post_list[text_name]) self.d(text=post_list[text_name]).click() self.d(text="确定").click() time.sleep(2) self.d(resourceId= "com.lietou.mishu:id/rl_multi_and_send" ).click() if self.d(text="发送职位").wait(timeout=5): self.d(text="发送职位").click() # 当职位list增多时,需要考虑弹框显示不全的情况,滑动找控件,只执行5次 post_num = 0 while post_num < 3: if self.d(text=post_list[text_name]): self.d(text=post_list[text_name]).click() self.d(text="确认").click() self.d.set_fastinput_ime(False) self.d( resourceId="com.lietou.mishu:id/rl_input" ).click() self.d( resourceId="com.lietou.mishu:id/et_chat" ).set_text( "您好,我们在为知名互联网公司招聘**岗位,工作地点在北京/上海/深圳,觉得您的经历很匹配。如果感兴趣可以点击应聘我发给您的职位,稍后可以详细沟通" ) self.d(text="发送").click() break else: self.d(resourceId= "com.lietou.mishu:id/recycler_view" ).swipe("up") post_num += 1 self.d( resourceId="com.lietou.mishu:id/chat_left_group" ).click() self.d( resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) tmp += 1 elif self.d(text="继续沟通"): self.d( resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) tmp += 1 elif self.d(text="该简历设置了隐私"): self.d( resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) tmp += 1 elif self.d(text="简历不符合要求,系统已过滤"): self.d( resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) tmp += 1 elif self.d(text="未审核通过"): self.d( resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) tmp += 1 elif self.d(text="亲~请连接网络~"): self.d( resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) tmp += 1 else: self.d.swipe(0.5, 0.8, 0.5, 0.55) tmp += 1 continue self.d(text="取消").click() time.sleep(2) if self.d(resourceId="com.lietou.mishu:id/search").wait( timeout=3): self.d(resourceId="com.lietou.mishu:id/search").click() else: log.d("未找到") except EOFError as e: log.d(e) self.d.press("back") self.d.press("back") self.d.press("back")
def test_a_recommend(self): try: if self.d(resourceId="com.lietou.mishu:id/v_hidden").wait( timeout=6): self.d(resourceId="com.lietou.mishu:id/v_hidden").click() else: print('正常') if self.d(text="您的账号已在其他设备登录,请重新登录").wait(timeout=3): time.sleep(5) self.d(text="确定").click() if LoginPage.LoginPage().wait_page("密码登录"): self.d(text="密码登录").click() self.d.set_fastinput_ime(True) LoginPage.login() self.d.set_fastinput_ime(False) if self.d(resourceId="com.lietou.mishu:id/iv_to_recruit").wait( timeout=5): self.d(resourceId="com.lietou.mishu:id/iv_to_recruit" ).click() elif self.d(text="我要招人").wait(timeout=3): self.d(text="我要招人").click() self.d(text="完成").click() elif self.d(resourceId="com.lietou.mishu:id/iv_close").wait( timeout=3): self.d(resourceId="com.lietou.mishu:id/iv_close").click() if self.d(text="跳过,暂时不想填写").wait(timeout=3): self.d(text="跳过,暂时不想填写").click() if self.d( resourceId="com.lietou.mishu:id/rl_resume_root" ).wait(timeout=10): self.d( resourceId="com.lietou.mishu:id/iv_to_recruit" ).click() tmp = 0 # get_num = self.get_post_num() if self.d(text="请选择性别").wait(timeout=3): self.d(resourceId="com.lietou.mishu:id/select_man").click() self.d(text="确认").click() elif self.d(text="一键升级").wait(timeout=3): self.d(resourceId="com.lietou.mishu:id/img_close").click() while tmp < 3: num = 0 while num < 30: time.sleep(3) get_version = self.d.device_info['version'] if self.d(resourceId="com.lietou.mishu:id/user_card").wait( timeout=3): self.d(resourceId="com.lietou.mishu:id/user_card" ).click() else: if get_version < '5.1.1': if self.d.xpath( "//android.widget.ScrollView/android.view.View" "/android.view.View/android.view.View" ).wait(timeout=3): self.d.xpath( "//android.widget.ScrollView/android.view.View" "/android.view.View/android.view.View" ).click() else: if self.d.xpath( "//android.widget.ScrollView/android.view.ViewGroup" "/android.view.ViewGroup/android.view.ViewGroup" ).wait(timeout=3): self.d.xpath( "//android.widget.ScrollView/android.view.ViewGroup" "/android.view.ViewGroup/android.view.ViewGroup" ).click() if self.d(text="立即沟通").wait(timeout=5): self.d(text="立即沟通").click() time.sleep(2) get_post_name = self.d( resourceId="com.lietou.mishu:id/tv_talk_position" ).get_text() self.d( resourceId="com.lietou.mishu:id/rl_multi_and_send" ).click() if self.d(text="发送职位").wait(timeout=5): self.d(text="发送职位").click() # 存在点击 发送职位时,进入职位详情页的情况 if self.d(text="职位介绍").wait(timeout=2): self.d.press("back") # 当职位list增多时,需要考虑弹框显示不全的情况,滑动找控件,只执行5次 post_num = 0 while post_num < 3: if self.d(text=get_post_name): self.d(text=get_post_name).click() self.d(text="确认").click() self.d( resourceId="com.lietou.mishu:id/rl_input" ).click() self.d( resourceId="com.lietou.mishu:id/et_chat" ).set_text( "您好,我们在为知名互联网公司招聘**岗位,工作地点在北京/上海/深圳,觉得您的经历很匹配。如果感兴趣可以点击应聘我发给您的职位,稍后可以详细沟通" ) self.d.set_fastinput_ime(False) self.d(text="发送").click() break else: self.d(resourceId= "com.lietou.mishu:id/recycler_view" ).swipe("up") post_num += 1 self.d(resourceId="com.lietou.mishu:id/chat_left_group" ).click() self.d(resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) num += 1 elif self.d(text="继续沟通"): self.d(resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) num += 1 elif self.d(text="该简历设置了隐私"): self.d(resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) num += 1 elif self.d(text="简历不符合要求,系统已过滤"): self.d(resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) num += 1 elif self.d(text="未审核通过"): self.d(resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) num += 1 elif self.d(text="亲~请连接网络~"): self.d(resourceId="com.lietou.mishu:id/ib_menu_back" ).click() self.d.swipe(0.5, 0.8, 0.5, 0.55) num += 1 else: self.d.swipe(0.5, 0.8, 0.5, 0.55) num += 1 continue self.d.swipe(0.9, 0.5, 0.2, 0.5) tmp += 1 # default status back_num = 0 while back_num < 5: self.d.swipe(0.4, 0.5, 0.9, 0.5) time.sleep(3) back_num += 1 except EOFError as e: log.d(e) self.d.press("back") self.d.press("back") self.d.press("back")
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.common.exceptions import TimeoutException, NoSuchElementException import traceback from PageObject.LoginPage import * from PageObject.buy_smartbid import * dr = webdriver.Chrome() dr.maximize_window() dr.get("http://dev.lantouzi.com/login") lp = LoginPage(dr) bs = Buy_smart(dr) wait = WebDriverWait(dr, 10, 0.2) # 显示等待 try: lp.login() time.sleep(1) bs.buy_smarbid() except TimeoutException as e: print("timeout", e) except NoSuchElementException as e: print("nosuch ", e) except Exception as e: print("other e", e) except BaseException as e: print("base error", e) finally: dr.close()