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
from Charles.mitm import mitm_query
from appiumConfigure import backtoapp
from Charles import AssertLen

class Case(appiumConfig):

    def test_01_search_cancel_button(self):
        '取消按钮点击'

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

        # 点击搜索输入框
        ele = find_element.element(self.driver, home_Page.search_sendkey_click)
        ele.click()

        # 搜索页面取消按钮点击
        ele = find_element.element(self.driver,search_Page.search_cancel)
        ele.click()

        backtoapp.backapp(self.driver,2)

        # "params": {
        #     "business_id": "",
        #     "page_name": "search_home",
        #     "referrer_link": [
        #         "home"
        #     ],
        #     "referrer": "home",
        #     "button_name": "return",
        #     "referrer_id": ""
        # },
        #     "type": "on_click_button",

        result = mitm_query(action="on_click_button",page_name="search_home",referrer="home",button_name="return")
        AssertLen.maidiannumber(result)

