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,swip
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.doctor_List)
        ele.click()

    def test_02_doctor_list(self):
        '医生榜详情页pv + 医生banner点击'
        # 点击医生banner
        self.driver.tap([[500,700]])

        backtoapp.backapp(self.driver,2)
        # "params": {
        #     "referrer_tab_name": "",
        #     "referrer_id": "",
        #     "in": "1625218190",
        #     "is_first": "1",
        #     "referrer_link": [
        #         ""
        #     ],
        #     "out": "1625218193",
        #     "referrer": "",
        #     "is_push": 0,
        #     "page_name": "doctor_list",
        #     "out_time_millis": 1625218193499,
        #     "fake": 0,
        #     "business_id": ""
        # },
        # "type": "page_view",
        result= mitm_query(action="page_view", page_name="doctor_list")
        AssertLen.maidiannumber(result)

        # "params": {
        #     "referrer": "",
        #     "referrer_id": "",
        #     "page_name": "doctor_list",
        #     "card_name": "王娟",
        #     "referrer_link": [
        #         ""
        #     ],
        #     "position": 0,
        #     "transaction_type": " -1",
        #     "card_type": "card",
        #     "card_content_type": "doctor",
        #     "card_id": "7c36ff2dd7ca440eae36282870e070fc"
        # },
        # "type": "on_click_card",
        result = mitm_query(action="on_click_card", page_name="doctor_list", card_name="王娟", card_type="card", card_content_type="doctor")
        AssertLen.maidiannumber(result)

    def test_03_doctor_list(self):
        '医生榜单-美购按钮点击'
        self.driver.tap([[200,1100]])
        backtoapp.backapp(self.driver,2)
        # "params": {
        #     "referrer": "",
        #     "referrer_id": "",
        #     "page_name": "doctor_list",
        #     "referrer_link": [
        #         ""
        #     ],
        #     "position": 0,
        #     "transaction_type": " -1",
        #     "card_type": "card",
        #     "card_content_type": "service",
        #     "card_id": 5867811,
        #     "extra_param": {
        #         "doctor_id": "a8ce575fb8d84698aae145f047d92d59"
        #     }
        # },
        # "type": "on_click_card",
        result = mitm_query(action="on_click_card", page_name="doctor_list", position="0", card_content_type="service")
        AssertLen.maidiannumber(result)

    def test_04_doctor_list(self):
        '查看更多按钮点击'
        TouchAction(self.driver).press(x=800,y=1100).wait(1000).move_to(x=200,y=1100).release().perform()
        time.sleep(3)












