import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
# import event
from appiumConfigure.config import appiumConfig
from appiumConfigure import find_element
from page import home_Page,search_Page,ai_Page
from Charles.mitm import mitm_query
from appiumConfigure import backtoapp
from Charles import AssertLen
import time
class Case(appiumConfig):

    def test01_ai_double_eye(self):
        '模拟双眼皮拍照按钮点击'

        #关闭弹窗点击
        find_element.ElementNotAssert(self.driver, home_Page.dialog_home_img_cancel)

        # 首页点击双眼皮按钮
        ele = find_element.element(self.driver,home_Page.double_eye)
        ele.click()
        # 弹窗关闭按钮点击
        find_element.ElementNotAssert(self.driver,ai_Page.double_eye_iv_close_pop)
        # 点击拍照按钮
        ele = find_element.element(self.driver,ai_Page.double_eye_take_photo_record_button)
        ele.click()
        backtoapp.backapp(self.driver,2)

        # "params": {
        #     "referrer": "",
        #     "referrer_id": "",
        #     "button_name": "take_pic",
        #     "page_name": "face_scan",
        #     "tab_name": "模拟双眼皮",
        #     "referrer_link": [
        #         ""
        #     ],
        #     "business_id": ""
        # },
        # "type": "on_click_button",

        result = mitm_query(action="on_click_button",button_name="take_pic",page_name="face_scan",tab_name="模拟双眼皮")
        AssertLen.maidiannumber(result)


    def test02_ai_double_eye(self):
        '模拟双眼皮相册按钮点击'
        # 关闭弹窗点击
        find_element.ElementNotAssert(self.driver, home_Page.dialog_home_img_cancel)
        # 首页点击双眼皮按钮
        ele = find_element.element(self.driver, home_Page.double_eye)
        ele.click()
        # 弹窗关闭按钮点击
        find_element.ElementNotAssert(self.driver, ai_Page.double_eye_iv_close_pop)
        # 点击相册按钮
        ele = find_element.element(self.driver,ai_Page.take_photo_album_img)
        ele.click()
        backtoapp.backapp(self.driver,2)

        # "params": {
        #     "referrer": "",
        #     "referrer_id": "",
        #     "button_name": "album",
        #     "page_name": "face_scan",
        #     "tab_name": "模拟双眼皮",
        #     "referrer_link": [
        #         ""
        #     ],
        #     "business_id": "34027087"
        # },
        # "type": "on_click_button",

        result = mitm_query(action="on_click_button", button_name="album", page_name="face_scan", tab_name="模拟双眼皮")
        AssertLen.maidiannumber(result)












