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_install_apk(self): # self.d.app_install(apk_url) self.d.app_start(pkg_name) time.sleep(3) LoginPage.LoginPage().wait_page() raise Exception('手动报错')
def test_01_install_apk(self): '''安装启动android_app_bootstrap''' self.d.app_install(apk_url) self.d.app_start(pkg_name) time.sleep(3) LoginPage.LoginPage().wait_page()
def test_05_Bar_click(self): '''主页操作并退出''' HomePage().home_click() HomePage().baidu_click() HomePage().webview_click() HomePage().personal_click() HomePage().personal_logout_click() LoginPage.LoginPage().wait_page()
class testCases(unittest.TestCase): def setUp(self): self.configuration = Initializer() self.driver = self.configuration.setUpDriver() self.HomePage = HomePage(self.driver) self.LoginPage = LoginPage(self.driver) self.RegisterPage = RegisterPage(self.driver) def test_Login(self): self.HomePage.click_login() self.LoginPage.login_user() def test_RegisterUser(self): self.HomePage.click_Register() self.RegisterPage.create_newUser() def tearDown(self): self.driver.close() self.driver.quit()
def login(useranme, password): '''封装的登录的函数''' driver = webdriver.Chrome(executable_path="d:\\chromedriver") driver.get("https://www.126.com") login_page = LoginPage.loginPage(driver) #login_page.click_login_link() login_page.switch_to_iframe() login_page.input_username(useranme) login_page.input_password(password) login_page.click_login_button() return driver
def test_login_52cx(self): #声明LoginPage类对象 login_page = LoginPage.LoginPage(self.driver, self.url, u"我爱出行管理平台") #调用打开页面组件 login_page.open() #调用用户名输入组件 login_page.input_username(self.username) #调用密码输入组件 login_page.input_password(self.password) #调用点击登录按钮组件 login_page.click_submit()
def test_open_new_customer_page(browser_driver, get_url): LoginPage(browser_driver) \ .open_account_page() \ .register_new_user() assert browser_driver.title == 'Register Account'
def test_05_login_again(self): '''再次登录''' LoginPage.LoginPage().login_click()
def login(dr, username, psw): lp = LoginPage(dr) lp.get_frame().click() lp.get_name().send_keys(username) lp.get_userpsw().send_keys(psw) lp.get_loginbutton().click()
def setUp(self): self.configuration = Initializer() self.driver = self.configuration.setUpDriver() self.HomePage = HomePage(self.driver) self.LoginPage = LoginPage(self.driver) self.RegisterPage = RegisterPage(self.driver)
def login(driver, userename, passord): lp = LoginPage(driver) driver.switch_to.frame(lp.getFrame()) lp.getclick().click() lp.getUserName().send_keys(userename) lp.getPassword().send_keys(passord) lp.getLoginButton().click() lp.driver.switch_to.default_content() time.sleep(3)
# -*- coding:utf-8 -*- from selenium import webdriver import chardet import string import time 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)
element = find_element(self.driver, check_box.split(">")[0], check_box.split(">")[1]) return element def click_star_flag(self, flag): if flag is None: return if ("y" in flag) or ("yes" in flag) or ("是" in flag): check_box = self.get_star_flag() check_box.click() if __name__ == "__main__": driver = webdriver.Chrome(executable_path="d:\\chromedriver") driver.get("https://www.126.com") login_page = LoginPage.loginPage(driver) login_page.click_login_link() login_page.switch_to_iframe() login_page.input_username("testgloryroad2020") login_page.input_password("123456789!!") login_page.click_login_button() home_page = HomePage.homePage(driver) home_page.click_address_link() address_page = addressPage(driver) address_page.click_create_button() address_page.input_name("吴老师") address_page.input_email("*****@*****.**") address_page.input_comment("随便写写") address_page.click_star_flag("是")
def test_open_forgotten_password_page(browser_driver, get_url): LoginPage(browser_driver) \ .open_account_page() \ .forgotten_password_form() assert browser_driver.title == 'Forgot Your Password?'
def test_login_user(browser_driver, get_url, email, password): LoginPage(browser_driver) \ .open_account_page() \ .login_user(email, password)
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")
def login(driver, username, password): lp = LoginPage(driver) driver.swicth_to.frame(lp.getFrame()) lp.getUserName().clear() lp.getUserName().send_keys(username) lp.getPassword().send_keys(password) lp.getLoginButton().click()