'''
基本案情-基本情况
'''
import pytest,time
from engine import get_engine


@pytest.mark.addxyr
@get_engine(__file__,'JBAQ_URL')
def test_addxyr(engine):
    # engine.init()
    basic_url = engine.get_testUrl('JBAQ_URL')
    case_id = engine.get_caseId('caseId')
    url = basic_url.format(bmsah=case_id)
    engine.driver.get(url)
    xyr_add = engine.driver.xpath("//div[@class='plus___1ckgY']")
    if not xyr_add:
        engine.logger.info('没有基本信息！！查看具体情况')
        exit(-1)
        return
    xyr_add = xyr_add[0]
    xyr_list = engine.driver.xpath("//div[contains(@class,'item___2HoCU')]")
    # 添加犯罪嫌疑人
    xyr_add.click()
    engine.logger.info('点击添加嫌疑人')
    time.sleep(1)
    new_xyr_list = engine.driver.xpath("//div[contains(@class,'item___2HoCU')]")
    xyr_name = engine.driver.xpath("//div[@title='犯罪嫌疑人姓名']/following-sibling::div[1]//input")[0].get_attribute('value')
    assert len(new_xyr_list) - len(xyr_list) == 1 and xyr_name == '','嫌疑人数+1'
    # 再加一个
    xyr_add.click()
    engine.logger.info('点击添加嫌疑人')
    time.sleep(1)
    new_xyr_list = engine.driver.xpath("//div[contains(@class,'item___2HoCU')]")
    xyr_name = engine.driver.xpath("//div[@title='犯罪嫌疑人姓名']/following-sibling::div[1]//input")[0].get_attribute('value')
    assert len(new_xyr_list) - len(xyr_list) == 2 and xyr_name == '','嫌疑人数+2'



@pytest.mark.delxyr
@get_engine(__file__,'JBAQ_URL')
def test_addxyr(engine):
    xyr_list = engine.driver.xpath("//div[contains(@class,'item___2HoCU')]")
    xyr_last = xyr_list[-1]
    # 删除犯罪嫌疑人
    xyr_last.click()
    engine.logger.info('点击最后一个嫌疑人')
    xyr_del = engine.driver.xpath("//div[@class='item___2HoCU active___2SHXM']/a[contains(@class,'delete___3-b3m')]")[0]
    xyr_del.click()
    engine.logger.info('点击X')
    time.sleep(0.5)
    # 点击否
    xyr_del_false = engine.driver.xpath("//div[@class='ant-popover-buttons']/button[@class='ant-btn ant-btn-sm']")[0]
    xyr_del_false.click()
    engine.logger.info('点击否')
    time.sleep(0.5)
    new_xyr_list = engine.driver.xpath("//div[contains(@class,'item___2HoCU')]")
    assert len(xyr_list) == len(new_xyr_list),'嫌疑人数不变'
    xyr_last.click()
    xyr_del.click()
    engine.logger.info('点击X')
    time.sleep(0.5)
    # 点击是
    xyr_del_true = engine.driver.xpath("//div[@class='ant-popover-buttons']/button[@class='ant-btn ant-btn-primary ant-btn-sm']")[0]
    xyr_del_true.click()
    engine.logger.info('点击是')
    time.sleep(1)
    new_xyr_list = engine.driver.xpath("//div[contains(@class,'item___2HoCU')]")
    assert len(xyr_list) - len(new_xyr_list) == 1,'嫌疑人数-1'

