import pytest, time
from basepage import get_engine

'''
测试主页面的功能
'''


@pytest.mark.select
@get_engine(__file__, 'INDEX')
def test_select(engine):
    '''搜索功能'''
    bmsah = engine.get_caseId('caseId')
    engine.logger.info('bmsah：' + bmsah)
    scqs_button = engine.driver.xpath("//span[text()='审查起诉']/..")[0]
    scqs_button.click()
    time.sleep(0.5)
    anjian_list = engine.driver.xpath("//div[@class='ant-table-body']//tr")
    engine.logger.info('案件列表长度：{}'.format(len(anjian_list)))
    input_button = engine.driver.xpath("//input[@id='ajmc']")[0]
    input_button.send_keys(bmsah)
    engine.logger.info('输入受案号')
    time.sleep(0.5)
    submit_button = engine.driver.xpath("//button[@class='ant-btn ant-btn-primary']")[0]
    submit_button.click()
    engine.logger.info('点击提交')
    time.sleep(1)
    anjian_list = engine.driver.xpath("//div[@class='ant-table-body']//tr")
    anjian = anjian_list[0]
    engine.logger.info('案件列表长度：{}'.format(len(anjian_list)))
    shouanhao = anjian.get_attribute('data-row-key')
    engine.logger.info('部门受案号/案件名称：{}'.format(shouanhao))
    assert shouanhao == bmsah
