Commit adcc0801 authored by gaotao's avatar gaotao

取消捕获异常

parent 148b5bd3
......@@ -8,23 +8,23 @@ def get_engine(file, url=None, login=True):
def inner(f):
def wapper(*args, **kwargs):
try:
start_time = time.time()
log_name = os.path.split(file)[-1].split(".")[0]
# image_path = os.path.join(os.path.dirname(os.path.dirname(file)), "images")
# image_path = os.path.join(image_path, log_name)
# image_path += '.png'
engine = BrowserEngine(url, login, log_name)
ret = f(engine, *args, **kwargs)
end_time = time.time()
engine.logger.info(f'执行时间:{end_time-start_time}s')
if engine: del engine
return ret
except Exception as e:
print(e)
# try:
start_time = time.time()
log_name = os.path.split(file)[-1].split(".")[0]
# image_path = os.path.join(os.path.dirname(os.path.dirname(file)), "images")
# image_path = os.path.join(image_path, log_name)
# image_path += '.png'
engine = BrowserEngine(url, login, log_name)
ret = f(engine, *args, **kwargs)
time.sleep(0.1)
end_time = time.time()
engine.logger.info(f'执行时间:{end_time-start_time}s')
if engine: del engine
return ret
# except Exception as e:
# print(e)
return wapper
......
This diff is collapsed.
......@@ -10,7 +10,7 @@ URL1 = '''http://{host}/cm/currencydeal/{bmsah}/{page}?bmsah={bmsah}'''
params1 = {
'host' : HOST,
'bmsah': '瓯检起诉受[2020]33030400659号',
'bmsah': '瓯检起诉受[2020]33030400557号',
'page' : 'case',
}
......@@ -87,7 +87,7 @@ def test_del_xyr(engine):
@pytest.mark.nullxyr
@get_engine(__file__,url=URL1.format(**params1))
def test_null_xyr(engine):
def test_null_xyr(engine): # 嫌疑人姓名为空
# engine.get_page(engine.DQZ)
# js = '''document.querySelector("#起诉意见书_犯罪嫌疑人_0_犯罪嫌疑人姓名").value = "";'''
......@@ -103,6 +103,7 @@ def test_null_xyr(engine):
@pytest.mark.basicmatter
@get_engine(__file__,url=URL1.format(**params1))
def test_nullbirth(engine):
......@@ -116,15 +117,16 @@ def test_nullbirth(engine):
time.sleep(0.5)
save_button = engine.driver.xpath("//span[text()='保存']/..")[0]
save_button.click()
time.sleep(3.5)
time.sleep(0.5)
message = engine.driver.xpath("//div[@class='ant-message']//span[text()='有必填项未填']")
assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__, url=URL1.format(**params1))
def test_nullID(engine):
def test_nullID(engine): # 无身份证信息 todo input输入框清空无法保存
# engine.get_page(engine.DQZ)
time.sleep(0.5)
......@@ -134,17 +136,15 @@ def test_nullID(engine):
# # engine.driver.execute_script(js)
engine.driver.xpath("//input[@id='起诉意见书_犯罪嫌疑人_0_身份证号码']")[0].clear()
time.sleep(2.5)
time.sleep(0.5)
save_button = engine.driver.xpath("//span[text()='保存']/..")[0]
save_button.click()
time.sleep(0.5)
message = engine.driver.xpath("//div[@class='ant-message']//span[text()='有必填项未填']")
message = engine.driver.xpath("//div[@class='ant-message']//span[contains(text(),'保存成功')]")
assert len(message) == 1
# @pytest.mark.basicmatter # todo
# @pytest.mark.basicmatter
# @get_engine(__file__, url=URL1.format(**params1))
# def test_nulledu(engine):
# engine.driver.xpath("//div[@id='起诉意见书_犯罪嫌疑人_0_文化程度']")[0].clear()
......@@ -155,8 +155,6 @@ def test_nullID(engine):
# message = engine.driver.xpath("//div[@class='ant-message']//span[text()='有必填项未填']")
# assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__,url=URL1.format(**params1))
def test_notnulledu(engine):
......@@ -173,6 +171,7 @@ def test_notnulledu(engine):
@pytest.mark.basicmatter
@get_engine(__file__,url=URL1.format(**params1))
def test_nullDomicile(engine):
......@@ -185,12 +184,13 @@ def test_nullDomicile(engine):
save_button = engine.driver.xpath("//span[text()='保存']/..")[0]
save_button.click()
time.sleep(0.5)
message = engine.driver.xpath("//div[@class='ant-message']//span[text()='有必填项未填']")
message = engine.driver.xpath("//div[@class='ant-message']//span[contains(text(),'保存成功')]")
assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__,url=URL1.format(**params1))
def test_notnullDomicile(engine):
......@@ -207,6 +207,7 @@ def test_notnullDomicile(engine):
assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__,url=URL1.format(**params1))
def test_nulladdr(engine):
......@@ -220,10 +221,11 @@ def test_nulladdr(engine):
save_button = engine.driver.xpath("//span[text()='保存']/..")[0]
save_button.click()
time.sleep(0.5)
message = engine.driver.xpath("//div[@class='ant-message']//span[text()='有必填项未填']")
message = engine.driver.xpath("//div[@class='ant-message']//span[contains(text(),'保存成功')]")
assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__, url=URL1.format(**params1))
def test_notnulladdr(engine):
......@@ -240,7 +242,7 @@ def test_notnulladdr(engine):
assert len(message) == 1
# @pytest.mark.nullSpecifPerson # todo
# @pytest.mark.nullSpecifPerson
# @get_engine(__file__, url=URL1.format(**params1))
# def test_null_xyr(engine):
# # engine.driver.xpath("//input[@id='起诉意见书_犯罪嫌疑人_0_住址']")[0].clear().send_keys('123')
......@@ -251,8 +253,6 @@ def test_notnulladdr(engine):
# message = engine.driver.xpath("//div[@class='ant-message']//span[text()='有必填项未填']")
# assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__, url=URL1.format(**params1))
def test_notnullSpecifPerson(engine):
......@@ -268,9 +268,7 @@ def test_notnullSpecifPerson(engine):
assert len(message) == 1
# @pytest.mark.nullSpecialID # todo
# @pytest.mark.nullSpecialID
# @get_engine(__file__, url=URL1.format(**params1))
# def test_null_xyr(engine):
# # engine.driver.xpath("//input[@id='起诉意见书_犯罪嫌疑人_0_特殊身份']")[0].clear().send_keys('123')
......@@ -281,8 +279,6 @@ def test_notnullSpecifPerson(engine):
# message = engine.driver.xpath("//div[@class='ant-message']//span[text()='有必填项未填']")
# assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__, url=URL1.format(**params1))
def test_notnullSpecialID(engine):
......@@ -298,6 +294,7 @@ def test_notnullSpecialID(engine):
assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__, url=URL1.format(**params1))
def test_nullFilingTime(engine):
......@@ -315,9 +312,10 @@ def test_nullFilingTime(engine):
assert len(message) == 1
@pytest.mark.basicmatter
@get_engine(__file__, url=URL1.format(**params1))
def test_IncorrectFormatFilingTime(engine): # 立案时间为空
def test_IncorrectFormatFilingTime(engine): # 立案时间格式于标准不一致 todo 不提示格式不正确!!
# engine.get_page(engine.DQZ)
input =engine.driver.xpath("//div[@title='立案时间']/following-sibling::div[1]//input")[0]
......@@ -328,12 +326,13 @@ def test_IncorrectFormatFilingTime(engine): # 立案时间为空
save_button.click()
time.sleep(0.5)
message = engine.driver.xpath("//div[@class='ant-message']//span[text()='日期格式不正确!']")
assert len(message) == 1
assert len(message) == 1 and '不提示格式不正确!!'
@pytest.mark.basicmatter
@get_engine(__file__, url=URL1.format(**params1))
def test_correctFormatFilingTime(engine): # 立案时间格式于标准一致
def test_correctFormatFilingTime(engine): # 立案时间格式于标准一致
# engine.get_page(engine.DQZ)
input = engine.driver.xpath("//div[@title='立案时间']/following-sibling::div[1]//input")[0]
......@@ -348,6 +347,7 @@ def test_correctFormatFilingTime(engine): # 立案时间格式于标准不一致
@pytest.mark.basicmatter
@get_engine(__file__, url=URL1.format(**params1))
def test_nullmeasure(engine): # 强制措施为空
......@@ -367,6 +367,7 @@ def test_nullmeasure(engine): # 强制措施为空
assert len(message) == 1
# @pytest.mark.basicmatter
# @get_engine(__file__, url=URL1.format(**params1))
# def test_fzjlRetract(engine): # 犯罪经历收起
......
......@@ -393,17 +393,17 @@ def test_xgxyrqtxx(engine): # 修改嫌疑人qtxx
time.sleep(0.5)
engine.driver.xpath("//div[text()='嫌疑人基本信息']/../..//div[contains(@class,'item___2HoCU')]")[0].click()
time.sleep(0.5)
engine.driver.xpath("//div[@title='出生日期']/following-sibling::div[1]/input")[-1].click()
engine.driver.xpath("//div[@title='出生日期']/following-sibling::div[1]//input")[-1].click()
time.sleep(0.5)
# engine.driver.xpath("//div[@title='出生日期']/following-sibling::div[1]/input")[-1].clear()
# engine.driver.xpath("//div[@title='出生日期']/following-sibling::div[1]//input")[-1].clear()
js = '''
document.querySelector("#root > div > div.default___1xRiJ > div.content___2Qldd > div > div > div > div.all___1MXc1 > div > div.main___JcrjF > div > div.mainRight___2k3VE.rightBack___3QMs7.rightElement___3KEHQ > div > form > div > div:nth-child(1) > div > div.ant-collapse-content.ant-collapse-content-active > div > div > form > div > div > div.default___17U5U > div > div > div:nth-child(1) > div:nth-child(3) > div.content___3n339 > div > div > div > span > input").value = "";'''
engine.driver.execute_script(js)
engine.driver.xpath("//div[@title='出生日期']/following-sibling::div[1]/input")[-1].send_keys(xyr_birth)
engine.driver.xpath("//div[@title='出生日期']/following-sibling::div[1]//input")[-1].send_keys(xyr_birth)
engine.driver.xpath("//span[text()='保 存']/..")[0].click()
time.sleep(0.5)
message = engine.driver.xpath("//div[@class='ant-message']//span[contains(text(),'保存成功')]")
test_birth = engine.driver.xpath("//input[@title='出生日期']/following-sibling::div[1]/input")[-1].text
test_birth = engine.driver.xpath("//input[@title='出生日期']/following-sibling::div[1]//input")[-1].text
assert len(message) == 1 and test_birth == xyr_birth
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment