Пример #1
0
class LoginBusiness(object):
    def __init__(self, driver):
        self.lh = LoginHandle(driver)

    # 正常登录
    def common_login(self, name, password, file_name):
        self.lh.send_login_name(name)
        self.lh.send_login_password(password)
        if len(file_name) != 0:
            self.lh.send_login_captcha(file_name)
        self.lh.click_login_btn()

    # 数据驱动整合代码
    def login_function(self, username, password, file_name, assertCode,
                       assertText):
        self.common_login(username, password, file_name)
        if len(assertCode) != 0:
            if self.lh.get_user_text(assertCode, assertText) is None:
                return False
            else:
                print("用例通过")
                return True

    # 判断是否注册成功
    def success_or_fail(self):
        if self.lh.get_login_btn_text() is None:
            return True
        else:
            return False
Пример #2
0
	def __init__(self):
		self.driver = webdriver.Chrome()
		self.driver.get('http://www.18crm.com')
		self.login_b = LoginBussiness(self.driver,'../config/LocalElement.ini')
		self.login_h = LoginHandle(self.driver,'../config/LocalElement.ini')
		self.rd = ReadIni('../config/TestData.ini')
		self.base = CommonUtil()
class RegistrationBusiness(object):
    def __init__(self, driver):
        self.driver = driver
        self.login_handle = LoginHandle(self.driver)
        self.registration_handle = RegistrationHandle(self.driver)
        self.swipe_page = SwipePage(self.driver)
        self.login_business = LoginBusiness(self.driver)

    def case_registration_001(self, i):  #进入注册页面,元素存在
        self.login_handle.click_account()
        self.login_handle.click_free_registration()
        time.sleep(1)
        try:
            if self.registration_handle.judge_resgistration_title() != None:
                print u"注册页面元素存在"
                self.screenshots.screenshots(i)
                if self.registration_handle.judge_validation_mobile() != None:
                    print u"验证手机号码元素存在"
                    self.driver.get_screenshot_as_file("../jpg/" + str(i) +
                                                       "Test-" +
                                                       str(time.time()) +
                                                       ".png")
                else:
                    print u"验证手机号码元素不存在"
                    self.driver.get_screenshot_as_file("../jpg/" + str(i) +
                                                       "Test-" +
                                                       str(time.time()) +
                                                       ".png")
            else:
                print u"注册页面元素不存在"
                self.driver.get_screenshot_as_file("../jpg/" + str(i) +
                                                   "Test-" + str(time.time()) +
                                                   ".png")
        except Exception, e:
            print u"用例失败:" + e
Пример #4
0
 def setup_class(cls):
     cls.driver = init_driver()
     login_handle = LoginHandle(cls.driver)
     login_handle.login_main("xxxx", "xxxx")
     cls.home_page_handle = HomePageHandle(cls.driver)
     cls.person_center_handle = PersonCenterHandle(cls.driver)
     cls.h5_page_handle = H5PageHandle(cls.driver)
     cls.msg_center_handle = MsgCenterHandle(cls.driver)
     cls.hot_map_handle = HotMapHandle(cls.driver)
     cls.mode_setting_handle = ModeSettingHandle(cls.driver)
Пример #5
0
 def test_login_error(self, username, password, veriycode, dialog_text):
     self.loginpage = LoginHandle(self.mydriver)
     self.loginpage.input_username(username)
     self.loginpage.input_password(password)
     self.loginpage.input_veriycode(veriycode)
     self.loginpage.click_login()
     dialog_text = self.loginpage.get_dialog_text()
     time.sleep(1)
     self.loginpage.click_dialog_yes_bg()
     assert dialog_text == dialog_text
Пример #6
0
	def __init__(self,driver):
		self.login_handle = LoginHandle(driver)
		self.driver = driver
		self.ini = ReadIni()
		self.txt = WriteTxt()
		self.login_page = LoginPage(driver)
		self.username = self.ini.get_value('username','login_value')
		self.password = self.ini.get_value('password','login_value')
		self.error_username = self.ini.get_value('error_username', 'login_value')
		self.error_pwd = self.ini.get_value('error_pwd', 'login_value')
		self.mt4 = self.ini.get_value('mt4id','login_value')
		self.error_mt4 = self.ini.get_value('error_mt4id','login_value')
		self.driver.implicitly_wait(15)
class AccountBusiness(object):
    def __init__(self, driver):
        self.driver = driver
        self.account_handle = AccountHandle(self.driver)
        self.login_handle = LoginHandle(self.driver)

    def my_account(self, i):
        """
		我的账户元素是否存在
		"""
        time.sleep(1.5)
        if self.account_handle.judge_account_page_title() != None:
            print u"我的账户元素存在"
            self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" +
                                               str(time.time()) + ".png")
        else:
            print u"我的账户元素不存在"
            self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" +
                                               str(time.time()) + ".png")

    def login_out_app(self, i):
        """
		退出APP登录
		"""
        time.sleep(1.5)
        self.account_handle.click_account_page_head_portrait()
        time.sleep(2)
        self.account_handle.click_account_page_loginout()
        time.sleep(1.5)
        if self.login_handle.get_title_login() != None:
            print u"退出APP登录"
            self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" +
                                               str(time.time()) + ".png")
        else:
            print u"退出APP登录失败"
            self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" +
                                               str(time.time()) + ".png")
        time.sleep(5)

    def account_page_account(self, i):
        """
		判断账户元素是否存在
		"""
        time.sleep(2)
        if self.login_handle.judge_account() != None:
            time.sleep(1.5)
            self.login_handle.click_account()
            time.sleep(2)
            self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" +
                                               str(time.time()) + ".png")
        else:
            time.sleep(1.5)
            self.login_handle.manual_password_unlock()
            time.sleep(2)
            self.login_handle.click_account()
            time.sleep(1.5)
            self.login_out_app()
            time.sleep(2)
            self.driver.get_screenshot_as_file("../jpg/" + str(i) + "Test-" +
                                               str(time.time()) + ".png")
Пример #8
0
class LoginBusiness:
    def __init__(self, i):
        self.login_handle = LoginHandle(i)

    def login_pass(self):
        self.login_handle.send_username('15811061916')
        self.login_handle.send_password('llfs1056')
        self.login_handle.click_login()

    def login_error(self):
        self.login_handle.send_username('15811061916')
        #self.login_handle.send_password('111111')
        self.login_handle.click_login()
        '''
Пример #9
0
 def __init__(self, driver):
     self.register_handle = RegisterHandle(driver)
     self.driver = driver
     self.ini = ReadIni()
     self.txt = WriteTxt()
     self.register_page = RegisterPage(driver)
     self.login_handle = LoginHandle(driver)
     self.phone = self.ini.get_value('phone', 'register_input_value')
     self.verification_code = self.ini.get_value('Verification_Code',
                                                 'register_input_value')
     self.mail = self.ini.get_value('mail', 'register_input_value')
     self.call = self.ini.get_value('call', 'register_input_value')
     self.pwd = self.ini.get_value('pwd', 'register_input_value')
     self.confirm_pwd = self.ini.get_value('confirm_pwd',
                                           'register_input_value')
     self.introducer = self.ini.get_value('introducer',
                                          'register_input_value')
     self.driver.implicitly_wait(20)
Пример #10
0
class LoginBusiness(object):
    def __init__(self,driver):
        self.read_ini = ReadIni()
        self.login_handle = LoginHandle(driver)

   #执行操作
    def login_user_error(self):
        user = self.read_ini.get_user("user_error")
        pwd = self.read_ini.get_user("pwd_true")
        self.login_base(user,pwd)
        if self.error_test() == "用户名或密码不对":
            print("用户检验成功")
            return True
        else:
            return False

    def login_pwd_error(self):
        user = self.read_ini.get_user("user_true")
        pwd = self.read_ini.get_user("pwd_error")
        self.login_base(user, pwd)
        if self.error_test() == "用户名或密码不对":
            print("密码检验成功")
            return True
        else:
            return False

    def login_base(self, user, pwd):

        self.login_handle.send_user_name(user)
        self.login_handle.send_user_pwd(pwd)
        self.login_handle.btn_submit()

    #登录成功
    def login_success(self):
        user = self.read_ini.get_user("user_true")
        pwd = self.read_ini.get_user("pwd_true")
        self.login_base(user, pwd)
        sleep(2)
        return self.logout_btn()

    def error_test(self):
        self.login_handle.send_msg()

    def logout_btn(self):
        return self.login_handle.logout_btn()
Пример #11
0
class LoginCase:
	def __init__(self):
		self.driver = webdriver.Chrome()
		self.driver.get('http://www.18crm.com')
		self.login_b = LoginBussiness(self.driver,'../config/LocalElement.ini')
		self.login_h = LoginHandle(self.driver,'../config/LocalElement.ini')
		self.rd = ReadIni('../config/TestData.ini')
		self.base = CommonUtil()
	
	def login_test01(self):
		'''
		不输入用户名、密码登录
		提示:用户账号格式为: 用户名@公司简称
		'''
		result = self.login_b.loginTest(self.rd.get_value('login','test01_username'),self.rd.get_value('login','test01_password'))
		return self.base.verifyTextMatch(self.driver,result,self.rd.get_value('login','test01_expect'))

	def login_test02(self):
		'''
		手机格式错误登录:130
		提示:输入的手机号格式不正确!
		'''
		result = self.login_b.loginTest(self.rd.get_value('login','test02_username'),self.rd.get_value('login','test02_password'))
		return self.base.verifyTextMatch(self.driver,result,self.rd.get_value('login','test02_expect'))

	def login_test03(self):
		'''
		用户名、密码错误:manager@test , 123456
		提示:用户名或密码错误
		'''
		result = self.login_b.loginTest(self.rd.get_value('login','test03_username'),self.rd.get_value('login','test03_password'))
		return self.base.verifyTextMatch(self.driver,result,self.rd.get_value('login','test03_expect'))

	def login_test04(self):
		'''
		企业号未开通登录:manager@999 , 123
		提示:企业号:999 不正确,或者您还没有开通软件,请点击“我要购买”进行开通
		'''
		result = self.login_b.loginTest(self.rd.get_value('login','test04_username'),self.rd.get_value('login','test04_password'))
		return self.base.verifyTextMatch(self.driver,result,self.rd.get_value('login','test04_expect'))

	def login_test05(self):
		'''
		登陆成功:manager@test , 123
		进入首页,姓名 == manager
		'''
		self.login_b.loginTest(self.rd.get_value('login','test05_username'),self.rd.get_value('login','test05_password'))
		try:
			result = self.login_h.homePageMyName().text
		except:
			result = ''
		return self.base.verifyTextMatch(self.driver,result,self.rd.get_value('login','test05_expect'))
Пример #12
0
class LoginBussiness(object):
    #执行操作
    def __init__(self, driver):
        self.login_h = LoginHandle(driver)

    def user_base(self, username, password):
        self.login_h.send_username(username)
        self.login_h.send_password(password)
        self.login_h.click_button()

    def login_succes(self):
        if self.login_h.get_login_text() == None:
            return True
        else:
            return False

    def login_user_error(self, username, password):
        self.user_base(username, password)
        if self.login_h.get_error("该账号格式不正确") == None:
            print("用户名校验不成功")
            return True
        else:
            return False

    def login_function(self, username, password, err_ele, err_code):
        self.user_base(username, password)
        if self.login_h.get_error(err_ele, err_code) == None:
            print("用户名校验不成功")
            return True
        else:
            return False

    def login_pass_error(self, username, password):
        self.user_base(username, password)
        if self.login_h.get_error("账号或者密码错误,请重新输入") == None:
            print("密码校验不成功")
            return True
        else:
            return False
Пример #13
0
class RegisterBusiness:
    def __init__(self, driver):
        self.register_handle = RegisterHandle(driver)
        self.driver = driver
        self.ini = ReadIni()
        self.txt = WriteTxt()
        self.register_page = RegisterPage(driver)
        self.login_handle = LoginHandle(driver)
        self.phone = self.ini.get_value('phone', 'register_input_value')
        self.verification_code = self.ini.get_value('Verification_Code',
                                                    'register_input_value')
        self.mail = self.ini.get_value('mail', 'register_input_value')
        self.call = self.ini.get_value('call', 'register_input_value')
        self.pwd = self.ini.get_value('pwd', 'register_input_value')
        self.confirm_pwd = self.ini.get_value('confirm_pwd',
                                              'register_input_value')
        self.introducer = self.ini.get_value('introducer',
                                             'register_input_value')
        self.driver.implicitly_wait(20)

    def register_demo_pass(self):
        '''
        成功注册demo用户
        '''
        self.login_handle.click_register()
        self.register_handle.click_register_au_btn()
        self.register_handle.switch_context()
        self.register_handle.send_phone(self.phone)
        self.register_handle.send_verification_code(self.verification_code)
        self.register_handle.click_next_step()
        self.register_handle.send_mail(self.mail)
        self.register_handle.send_call(self.call)
        self.register_handle.send_password(self.pwd)
        self.register_handle.send_confirm_password(self.confirm_pwd)
        self.register_handle.send_introducer(self.introducer)
        self.register_handle.click_accept_term()
        self.register_handle.click_accept_ad()
        self.register_handle.click_complete()
        time.sleep(20)
Пример #14
0
class LoginBusiness:
    def __init__(self,i):
        self.login_handle = LoginHandle(i)

    def login_pass(self):
        self.login_handle.send_username()
        self.login_handle.send_password()
        self.login_handle.check_login()
Пример #15
0
class LoginBusiness(object):
    def __init__(self, driver, i):
        self.login_handle = LoginHandle(driver, i)

    def login_token(self):
        '''
        登录
        :return:
        '''
        time.sleep(5)
        self.login_handle.click_traggle_button()
        self.login_handle.click_avatar_button()
        time.sleep(5)
        # self.login_handle.send_token_val("xxxxxxxxxxx")
        self.login_handle.send_token_val()
        self.login_handle.click_login()
Пример #16
0
class LoginBusiness:
    def __init__(self, driver, node):
        self.driver = driver
        self.login_h = LoginHandle(self.driver, node)

    def user_base(self, username, password):
        self.login_h.send_password(password)
        self.login_h.send_username(username)
        self.login_h.click_login_button()

    def login_function(self, username, password, assertCode, assertText):
        self.user_base(username, password)
        if assertText in self.login_h.get_text(assertCode):
            return True
        else:
            return False
class Login_Bussiness(object):
    def __init__(self, driver):
        self.driver = driver
        self.login_h = LoginHandle(self.driver)
        self.alert_present = False

    def user_base(self, username, password):
        self.login_h.send_username(username)
        self.login_h.send_password(password)
        self.login_h.click_submit_btn()
        self.alert_present = self.is_alert(self.driver)
        if self.alert_present:
            return False
        else:
            return True

    def login_success(self, username, password):
        #         current_handle = self.driver.current_window_handle
        if self.user_base(username, password):
            all_handles = self.driver.window_handles
            #           print(all_handles)
            for handle in all_handles:
                self.driver.switch_to.window(handle)
                #               print(self.driver.title)
                if '我的地盘 ' in self.driver.title:
                    #                     text =  self.driver.find_element_by_xpath('//*[@id="block2"]/div[1]/div').text
                    # #                 print(text)
                    # #                 print('login success !')
                    #                     if(text == '最新动态'):
                    return True
#         print('login fail')
        return False

    def is_alert(self, driver):
        try:
            alert = driver.switch_to.alert
            alert.text
            return True
        except NoAlertPresentException:
            return False


# if __name__ == '__main__':
#     driver = webdriver.Chrome()
#     lb = Login_Bussiness(driver)
#     driver.get('http://127.0.0.1/zentao/user-login.html')
#     lb.user_base('admin', 'Aa1234')
#     if lb.alert_present :
#         print('login fail ! ')
#     else :
#         lb.login_success()
#     driver.quit()
class LoginBusiness(object):

    def __init__(self, driver):
        self.login_h = LoginHandle(driver)


    def user_base(self, username, password):
        self.login_h.send_username(username)
        self.login_h.send_password(password)
        self.login_h.click_login_button()

    def login_success(self, username, password):
        self.user_base(username, password)
Пример #19
0
class LoginBussiness:
    def __init__(self, driver, filename):
        self.login_h = LoginHandle(driver, filename)
        self.util = CommonUtil()
        self.driver = driver

    def loginTest(self, username, password):
        self.login_h.sendUsername(username)
        self.login_h.sendPassword(password)
        self.login_h.clickLoginBt()
        alertText = self.util.getAlertText(self.driver)
        self.util.acceptAlert(self.driver)
        return alertText
Пример #20
0
class LoginBusiness(object):
    def __init__(self, driver):
        self.login = LoginHandle(driver)
        self.driver =driver

    def login_base(self, username, password):
        self.login.send_username(username)
        self.login.send_password(password)
        self.login.click_login()

    #执行操作
    def login_username_error(self, username, password):
        self.login_base(username, password)
        if self.login.get_error_info() == "您输入的用户名或密码错误,请重新输入。":
            print("用户名错误")
            return True
        else:
            return False

    def login_password_error(self, username, password):
        self.login_base(username, password)
        if self.login.get_error_info() == "您输入的用户名或密码错误,请重新输入。":
            print("密码错误")
            return True
        else:
            return False

    def login_success(self, username, password):
        self.login_base(username, password)
        time.sleep(3)
        text = self.driver.title
        print(text)
        if text == "预处理平台":
            print("登录成功")
            return True
        else:
            return False
Пример #21
0
class LoginBussiness():
    def __init__(self, driver):
        self.login_h = LoginHandle(driver)

    def user_base(self, user_name, password):
        self.login_h.send_user_name(user_name)
        self.login_h.send_user_password(password)
        self.login_h.click_button()

    #执行操作
    def login_success(self, user_name, password):
        self.user_base(user_name, password)

        if Login_Page.get_username_password_error() == None:
            return True
        else:
            return False
Пример #22
0
class TestLogin:
    mydriver = None
    homepage = None
    loginpage = None

    def setup_class(self):
        self.mydriver = BaseDriver('http://localhost/')
        self.mydriver.set_max_window()
        self.mydriver.set_imp_wait(10)

    def teardown_class(self):
        time.sleep(2)
        self.mydriver.quit()

    # @pytest.mark.skip
    @allure.title('进入主页后跳转至登录页')
    @pytest.mark.run(order=1)
    def test_to_loginpage(self):
        self.homepage = HomeHandle(self.mydriver)
        self.homepage.go_2_loginpage()

    # @pytest.mark.skip
    @allure.title("登录")
    @allure.description("用例描述:测试登录的各种异常情况")
    @pytest.mark.parametrize(
        ("username", "password", "veriycode", "dialog_text"), build_data())
    @pytest.mark.run(order=2)
    def test_login_error(self, username, password, veriycode, dialog_text):
        self.loginpage = LoginHandle(self.mydriver)
        self.loginpage.input_username(username)
        self.loginpage.input_password(password)
        self.loginpage.input_veriycode(veriycode)
        self.loginpage.click_login()
        dialog_text = self.loginpage.get_dialog_text()
        time.sleep(1)
        self.loginpage.click_dialog_yes_bg()
        assert dialog_text == dialog_text
Пример #23
0
 def __init__(self, driver, node):
     self.driver = driver
     self.login_h = LoginHandle(self.driver, node)
Пример #24
0
 def __init__(self,i):
     self.login_handle = LoginHandle(i)
Пример #25
0
class LoginBusiness:

    def __init__(self,i):
        self.login_handle = LoginHandle(i)

    def login_pass(self):
        self.login_handle.send_username('13421382449')
        self.login_handle.send_pwd('123456')
        self.login_handle.click_login()

    def login_user_err(self):
        self.login_handle.send_username('1342cuowu')
        self.login_handle.send_pwd('123456')
        self.login_handle.click_login()
        flag = self.login_handle.get_fail_toast('账号未注册')
        if flag:
            return True
        else:
            return False

    def login_pwd_err(self):
        self.login_handle.send_username('1342cuowu')
        self.login_handle.send_pwd('123456aaa')
        self.login_handle.click_login()
        flag = self.login_handle.get_fail_toast('登录密码错误')
        if flag:
            return True
        else:
            return False
Пример #26
0
class LoginBusiness:
    def __init__(self, i):
        self.login_handle = LoginHandle(i)

    def login_pass(self):
        self.login_handle.send_username('18513199586')
        self.login_handle.send_password('111111')
        self.login_handle.click_login()

    def login_user_error(self):
        self.login_handle.send_username('18513199587')
        self.login_handle.send_password('111111')
        self.login_handle.click_login()
        user_flag = self.login_handle.get_fail_tost('帐号未注册')
        if user_flag:
            return True
        else:
            return False

    def login_password_error(self):
        self.login_handle.send_username('18513199586')
        self.login_handle.send_password('111112')
        self.login_handle.click_login()
        user_flag = self.login_handle.get_fail_tost('登陆密码错误')
        if user_flag:
            return True
        else:
            return False
Пример #27
0
 def __init__(self,driver):
     self.read_ini = ReadIni()
     self.login_handle = LoginHandle(driver)
Пример #28
0
class LoginBusiness:
    def __init__(self, i):
        self.login_handle = LoginHandle(i)

    def login_pass(self):
        self.login_handle.send_username('18821768014')
        self.login_handle.send_password('19941120')
        self.login_handle.click_login()

    def login_user_error(self):
        self.login_handle.send_username('18821768011')
        self.login_handle.send_password('111111')
        self.login_handle.click_login()
        user_flag = self.login_handle.get_fail_tost('帐号未注册')
        if user_flag:
            return True
        else:
            return False

    def login_password_error(self):
        self.login_handle.send_username('18821768014')
        self.login_handle.send_password('111112')
        self.login_handle.click_login()
        user_flag = self.login_handle.get_fail_tost('登陆密码错误')
        if user_flag:
            return True
        else:
            return False

    def go_paizhao(self):
        self.login_handle.click_paizhao()

    def go_tianqi(self):
        self.login_handle.click_tianqi()
Пример #29
0
 def test_login(self, username, password, veriycode):
     loginhandle = LoginHandle(self.driver)
     loginhandle.input_username(username)
     loginhandle.input_password(password)
     loginhandle.input_veriycode(veriycode)
     loginhandle.click_login()
Пример #30
0
 def __init__(self, driver):
     self.login_h = LoginHandle(driver)