result = 0


def outp_message(browser):
    special_elements = browser.find_elements_by_xpath(div[3]['key'])
    outp_type_code = []
    outp_date = []
    if len(special_elements) > 1:
        for special_element in special_elements:
            outp_type_code.append(
                special_element.find_elements_by_tag_name('div')[1].text)
            outp_date.append(
                special_element.find_elements_by_tag_name('div')[4].text)
    return [outp_type_code, outp_date]


if __name__ == '__main__':
    cache = Cache({})
    browser = Common.browser()
    testcase = {'用户名': 'jfli', '密码': '123456'}
    login.test_login(browser, testcase, cache)
    test_case = {
        '患者卡号': '%E?;1004627675=99015017425?+E?',
        '患者姓名': '',
        '号源类别': '专家',
        '专科编码': '083',
        '专科名称': '',
        '医生': ''
    }
    test_regist_button(browser, test_case, cache)
    depart_list = list(cache['检查单'].values())
    buttons = browser.find_elements_by_tag_name('button')
    for button in buttons:
        if  '【'in button.text :
            button.click()
            browser.find_element_by_xpath(plat.input[0]['key']).clear()
            # browser.find_element_by_xpath(plat.input[0]['key']).send_keys('光谷院区: '+depart_list[1])
            browser.find_element_by_xpath(plat.input[0]['key']).send_keys('光谷院区: 预约小组' )
            time.sleep(1)
            browser.find_element_by_xpath(plat.input[0]['key']).send_keys(Keys.ENTER)
            browser.find_element_by_xpath(plat.button[0]['key']).click()


if __name__ == '__main__':
    browser = common.browser()
    login.test_login(browser,testcase={'用户名':'jfli','密码':'123456'},cache={})
    login.select_workstation(browser, '检查预约', cache={})
    select_department(browser,cache={'depart':'预约小组'})
    time.sleep(2)

    swip_card = reservation.div[2]['key']
    swip_card_element = browser.find_element_by_xpath(swip_card).find_elements_by_tag_name('input')
    swip_card_element[0].send_keys('%E?;1004627675=99015017425?+E?' + '\n')
    time.sleep(2)
    browser.find_element_by_xpath("//div[contains(text(),'02D2017041400002')]").click()

    element = browser.find_element_by_xpath('/html/body/div[1]/div/div[2]/div[1]/div[2]/div[1]/div/div/div[2]/div[1]/div[2]/div/div[3]/div/div[2]/div[1]/div').find_elements_by_tag_name('input')[0]
    print(element.get_attribute('value'))
    js = "document.getElementsByTagName('input')[16].removeAttribute('readonly')"
    browser.execute_script(js)