Beispiel #1
0
 def test_login(self, action: ElementActions):
     L.d('test_login')
     account = Steps.get_account()
     action.click(HomePage.登录入口)
     action.text(LoginPage.账户, account[0])
     action.text(LoginPage.密码, account[1])
     action.sleep(1)
     action.click(LoginPage.登录)
     assert action.is_toast_show('欢迎回来')
 def test_rrtv_login(self, action: ElementActions):
     L.d('rrtv login')
     account = Steps.get_account()
     action.click(MyPage.我的)
     action.click(MyPage.头像)
     action.click(LoginPage.账号密码登录)
     action.text(LoginPage.账户, account[0])
     action.back_press()
     action.text(LoginPage.密码, account[1])
     action.back_press()
     action.click(LoginPage.登录)
     assert action.is_text_displayed("test")
Beispiel #3
0
 def test_login(self, action: ElementActions):
     L.d('test_login')
     allure.attach('描述', '这是一个登陆的case')
     account = Steps.get_account()
     action.sleep(3)
     # action.test_SwipeGuideImages()
     action.click(HomePage.登录入口)
     action.text(LoginPage.账户, account[0])
     action.text(LoginPage.密码, account[1])
     action.sleep(1)
     action.click(LoginPage.登录)
     action.sleep(3)
     assert action._find_text_in_page("我的")
Beispiel #4
0
 def test_login_empty_password(self, action: ElementActions):
     account = Steps.get_account()
     time.sleep(20)
     action.swip_left(3)
     time.sleep(5)
     L.d('test_login_empty_password')
     L.i('账户{0},密码为空'.format(account[0]))
     action.click(HomePage.登录)
     login(account[0], "", action)
     action.sleep(5)
     try:
         assert action.is_text_displayed('密码能为空1')
     except Exception as e:
         action.save_failure_pic(sys._getframe().f_code.co_name)
Beispiel #5
0
    def test_login(self, action: ElementActions):
        L.d('test_login')
        """
        检查是否在登录状态,在登陆的话就退出登录再登录
        """
        action.click(HomePage.我的)
        if action.is_text_displayed('like'):
            action.click(MyPage.设置)
            action.click(SettingPage.登出)
            action.click(SettingPage.确定)
            action.click(HomePage.我的)

        else: pass
        action.click(HomePage.登陆按钮)
        action.sleep(1)
        action.text(LoginPage.手机号, '96522075359')
        action.click(LoginPage.获取验证码)
        action.sleep(1)
        action.text(LoginPage.密码, '2333')
        action.sleep(0.5)
        action.click(LoginPage.登陆)
        assert action.get_text(MyPage.名字) == 'kirua'
    def test_avatar_to_profile_page(self, action: ElementActions):
        """
        验证profile页面

        """
        L.d('test_popular_narrators_to_profile_page')
        # 关闭广告
        login_later(action)
        action.click(MainPage.discover_album_name)
        action.sleep(2)
        before_user = action.get_text(AlbumDetailsPage.popular_user_name)
        action.click(AlbumDetailsPage.popular_user_view)

        try:
            after_user = action.get_text(ProfilePage.user_name)
            assert before_user == after_user

        except AssertionError:
            action.screenshot("popular_narrators_to_page_error")
            file = tools.Find.find_screen("popular_narrators_to_page_error")
            allure.attach('popular_narrators_to_page_error.png', file,
                          allure.attach_type.PNG)
            action.quit()
            raise
Beispiel #7
0
    def sendMail(self):
        msg = MIMEMultipart()
        boby = """
        <h3>Hi,all</h3>
        <p>附件为本次FM_自动化测试报告。</p>
        <p>请解压zip,并使用Firefox打开index.html查看本次自动化测试报告结果。</p>
        <p>注:如运行失败请看如下截图,如运行成功请忽略。</p> 
        <p>
        错误截图一:
        <br><img src="cid:image1"></br> 
        </p>
        <p>
        错误截图二:
        <br><img src="cid:image2"></br> 
        </p>
        <p>
        错误截图三:
        <br><img src="cid:image3"></br> 
        </p>
        """
        mail_body = MIMEText(boby, _subtype='html', _charset='utf-8')
        tm = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))

        file = str(
            os.path.abspath(
                os.path.join(os.path.dirname(__file__), os.pardir,
                             "data/result.txt")))
        f = open(file, 'r')
        # 按行读出文件内容
        sourceInLines = f.readlines()
        f.close()
        # 定义一个空列表,用来存储结果
        new = []
        for line in sourceInLines:
            temp1 = line.strip('\n')  # 去掉每行最后的换行符'\n'
            temp2 = temp1.split(',')  # 以','为标志,将每行分割成列表
            new.append(temp2)  # 将上一步得到的列表添加到new中

        if new.count(['failed']) == 0:
            Subject = '[Passed]'
        else:
            Subject = '[Failed]'

        msg['Subject'] = Header(
            Subject + " " + "FM_Android_自动化测试报告" + "_" + tm, 'utf-8')
        msg['From'] = self.config.sender
        receivers = self.config.receiver
        toclause = receivers.split(',')
        msg['To'] = ",".join(toclause)
        print(msg['To'])
        msg.attach(mail_body)

        # 添加report附件
        att = MIMEText(open(self.report_html, "rb").read(), "base64", "utf-8")
        att["Content-Type"] = "application/octet-stream"
        times = time.strftime("%m_%d_%H_%M", time.localtime(time.time()))
        filename_report = 'FM_Android_Report' + '_' + times + '.zip'
        # print(filename_report)
        att["Content-Disposition"] = 'attachment; filename= %s ' % filename_report
        msg.attach(att)

        # 获取最新的错误截图
        error_file_count = new.count(['failed']) + 1
        dir_image = str(
            os.path.abspath(
                os.path.join(os.path.dirname(__file__), os.pardir,
                             "screenshot")))
        image_dir = tools.Find.find_new_file(dir_image, error_file_count)
        #
        for i in range(1, error_file_count):
            fp = open(image_dir[i - 1], 'rb')
            msgImage = MIMEImage(fp.read())
            fp.close()
            msgImage.add_header('Content-ID', '<image%i>' % i)
            msg.attach(msgImage)

        # 登陆并发送邮件
        try:
            smtp = smtplib.SMTP()
            # 打开调试模式
            # smtp.set_debuglevel(1)
            smtp.connect(self.config.smtpserver)
            smtp.login(self.config.username, self.config.password)
            smtp.sendmail(self.config.sender, toclause, msg.as_string())
        except Exception as e:
            print(e)
            L.d("邮件发送失败!!")
        else:
            L.d("邮件发送成功")

        finally:
            smtp.quit()
Beispiel #8
0
    def get_account():

        account = Environment().get_inited_config().account_success
        pwd = Environment().get_inited_config().password_success
        L.d('账号:%s 密码 %s' % (account, pwd))
        return [account, pwd]
Beispiel #9
0
 def get_vin_box(self):
     vin = Environment().get_inited_config().vin_success
     box = Environment().get_inited_config().box_success
     L.d('车架号:%s 盒子号 %s' % (vin, box))
     return [vin, box]