from src.pageobject.mainpage import MainPage
from selenium.webdriver.common.by import By


# 主页面
class WhiteBoardPage(MainPage):
    # 元素集
    # 切换白板标签
    white_board = (By.XPATH, """//div[text()="白板"]""")
    # 添加白板按钮
    add_white_board = (By.XPATH, """//span[text()=" 添加白板"]""")
    # 打开白板
    open_white_board = (By.XPATH, """//span[@class="name oneLineText"]""")
    # iframe
    iframe_ele = (By.XPATH, """//iframe[@id="webview"]""")
    # 白板
    green_board = (By.XPATH, """//div[@class="whiteboard-box "]""")

    # 白板功能
    # 画笔
    huabi = (By.XPATH, """//span[@class="icon iconfont iconhuabi "]""")
    # 文本
    wenben = (By.XPATH, """//span[@class="icon iconfont iconwenben "]""")
    # 直线
    zhixian = (By.XPATH, """//span[@class="icon iconfont iconxiantiao "]""")
    # 形状
    xingzhuang = (By.XPATH, """//span[@class="icon iconfont iconfangxing "]""")
    # 移动
    yidong = (By.XPATH, """//span[@class="icon iconfont iconyidong "]""")
    # 橡皮擦
    xiangpica = (By.XPATH, """//span[@class="icon iconfont iconxiangpica "]""")
    # 文本输入框
    wenben_text = (By.XPATH, """//textarea[@class="editable-textarea my-textarea"]""")
    # 文本位置
    wenben_location = (By.XPATH, "//div[@class='textarea-container']")
    # 删除白板按钮
    delete_white_board = (By.XPATH, "//span[@class='icon iconfont delete']")
    # 白板名称元素定位
    white_board_ele = (By.XPATH, "//div[@class='item active']")

    # 删除白板确认窗口
    confirm_delete_btn = (By.XPATH, "//span[text()='确定']")

    # "进入直播间"按钮         format里面的参数还是要继续修改，先创建课程，再通过课程名称来查看进入直播间按钮
    in_live_btn = (By.XPATH, """//div[text()={}]/..//button[@class="ant-btn ant-btn-primary"]""".format("测试新增直播课"))

    # 验证元素

    def __init__(self, driver):
        MainPage.__init__(self, driver)

    # 点击切换白板
    def click_white_board(self):
        self.click(self.white_board)

    # 点击添加白板
    def click_add_white_board(self):
        self.click(self.add_white_board)

    # 打开白板
    def click_open_white_board(self):
        self.click(self.open_white_board)

    # 点击画笔
    def click_huabi(self):
        self.click(self.huabi)

    # 点击文本
    def click_wenben(self):
        self.click(self.wenben)

    # 点击直线
    def click_line(self):
        self.click(self.zhixian)

    # 点击形状
    def click_block(self):
        self.click(self.xingzhuang)

    # 点击移动
    def click_move(self):
        self.click(self.yidong)

    # 点击橡皮擦
    def click_eraser(self):
        self.click(self.xiangpica)

    # 点击输入文本
    def input_wenben(self, text):
        self.input_text(self.wenben_text, text=text)

    # 鼠标移动至100，100坐标
    def move_get_wenben(self):
        self.mouse_move(100, 100)

    # 获取iframe内的文本坐标
    def wenben_location_ele(self):
        return self.find_element(self.wenben_location)

    # 点击删除白板按钮
    def click_delete_white_board(self):
        self.click(self.delete_white_board)

    # 鼠标悬停
    def mouse_of_white_board(self):
        self.mouse_stop_until_ele_show(self.find_element(self.white_board_ele))

    # 二次确认删除白板
    def click_confirm_del_btn(self):
        self.click(self.confirm_delete_btn)


