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,timecard_Page,me_page
from Charles.mitm import mitm_query
from appiumConfigure import backtoapp
from Charles import AssertLen
import time
from selenium.webdriver.common.action_chains import ActionChains
from appium.webdriver.common.touch_action import TouchAction
from selenium.webdriver.support.wait import WebDriverWait
from appium.webdriver.mobilecommand import MobileCommand
class Case(appiumConfig):

    def setUp(self):
        super().setUp()
        # 关闭弹窗点击
        find_element.ElementNotAssert(self.driver, home_Page.dialog_home_img_cancel)
        #点击机构榜
        ele = find_element.element(self.driver, home_Page.mechanism_List)
        ele.click()



    def test_01_organization_list(self):
        '机构榜单详情页pv'
        # "params": {
        #     "referrer_tab_name": "",
        #     "referrer_id": "",
        #     "in": "1625214664",
        #     "is_first": "1",
        #     "referrer_link": [
        #         ""
        #     ],
        #     "out": "1625214667",
        #     "referrer": "",
        #     "is_push": 0,
        #     "page_name": "mechanism_list",
        #     "out_time_millis": 1625214667704,
        #     "fake": 0,
        #     "business_id": ""
        # },
        # "type": "page_view",
        result = mitm_query(action="page_view", page_name="mechanism_list")
        AssertLen.maidiannumber(result)


    
    def test_02_organization_list(self):
        '点击医院banner，跳转医院主页'
        self.driver.tap([[500,800]])
        backtoapp.backapp(self.driver,2)
        # "params": {
        #     "referrer": "",
        #     "referrer_id": "",
        #     "page_name": "mechanism_list",
        #     "card_name": "上海薇琳医疗美容医院",
        #     "referrer_link": [
        #         ""
        #     ],
        #     "position": 0,
        #     "transaction_type": " -1",
        #     "card_type": "card",
        #     "card_content_type": "hospital",
        #     "card_id": "shanghaiweilinyiliaomeirongyiyuan"
        # },
        # "type": "on_click_card",
        result = mitm_query(action="on_click_card", page_name="mechanism_list", card_content_type="hospital")
        AssertLen.maidiannumber(result)


    def test_03_organization_list(self):
        '点击美购列表 美购'
        self.driver.tap([[200,1100]])
        backtoapp.backapp(self.driver,2)
        # 点击美购埋点
        # "params": {
        #     "referrer": "",
        #     "referrer_id": "",
        #     "page_name": "mechanism_list",
        #     "referrer_link": [
        #         ""
        #     ],
        #     "position": 0,
        #     "transaction_type": " -1",
        #     "card_type": "card",
        #     "card_content_type": "service",
        #     "card_id": 5665494,
        #     "extra_param": {
        #         "mechanism_id": "shanghaiweilinyiliaomeirongyiyuan"
        #     }
        # },
        # "type": "on_click_card",
        result = mitm_query(action="on_click_card", page_name="mechanism_list", card_content_type="service",card_type="service")
        AssertLen.maidiannumber(result)





















