|
1 | 1 | import logging |
| 2 | +import time |
2 | 3 | import pytest |
3 | 4 | from pages.HomePage import HomePage |
4 | | - |
| 5 | + |
5 | 6 | logger = logging.getLogger(__name__) |
6 | | - |
| 7 | + |
7 | 8 | # Define step-wise test actions for Golden Path |
8 | 9 | golden_path_steps = [ |
9 | 10 | ("Validate home page is loaded", lambda home: home.validate_home_page()), |
10 | | - ("Select Invoice Schema", lambda home: home.select_schema("Invoice")), |
| 11 | + ("Select Invoice Schema", lambda home: home.select_schema("Invoice")), |
11 | 12 | ("Upload Invoice documents", lambda home: home.upload_files("Invoice")), |
12 | | - ("Refresh page till status is updated to Completed", lambda home: home.refresh()), |
13 | | - ("Validate extracted result for Invoice", lambda home: home.validate_invoice_extracted_result()), |
14 | | - ("Modify Extracted Data JSON & submit comments", lambda home: home.modify_and_submit_extracted_data()), |
| 13 | + ("Refreshing the page until the 'Invoice' file status is updated to 'Completed'", lambda home: home.refresh()), |
| 14 | + ( |
| 15 | + "Validate extracted result for Invoice", |
| 16 | + lambda home: home.validate_invoice_extracted_result(), |
| 17 | + ), |
| 18 | + ( |
| 19 | + "Modify Extracted Data JSON & submit comments", |
| 20 | + lambda home: home.modify_and_submit_extracted_data(), |
| 21 | + ), |
15 | 22 | ("Validate process steps for Invoice", lambda home: home.validate_process_steps()), |
16 | | - ("Select Property Loss Damage Claim Form Schema", lambda home: home.select_schema("Property")), |
17 | | - ("Upload Property Loss Damage Claim Form documents", lambda home: home.upload_files("Property")), |
18 | | - ("Refresh page till status is updated to Completed", lambda home: home.refresh()), |
19 | | - ("Validate extracted result for Property Loss Damage Claim Form", lambda home: home.validate_property_extracted_result()), |
20 | | - ("Validate process steps for Property Loss Damage Claim Form", lambda home: home.validate_process_steps()), |
21 | | - ("Validate Delete files", lambda home: home.delete_files()) |
| 23 | + ( |
| 24 | + "Select Property Loss Damage Claim Form Schema", |
| 25 | + lambda home: home.select_schema("Property"), |
| 26 | + ), |
| 27 | + ( |
| 28 | + "Upload Property Loss Damage Claim Form documents", |
| 29 | + lambda home: home.upload_files("Property"), |
| 30 | + ), |
| 31 | + ("Refreshing the page until the 'Claim Form' status is updated to 'Completed'", lambda home: home.refresh()), |
| 32 | + ( |
| 33 | + "Validate extracted result for Property Loss Damage Claim Form", |
| 34 | + lambda home: home.validate_property_extracted_result(), |
| 35 | + ), |
| 36 | + ( |
| 37 | + "Validate process steps for Property Loss Damage Claim Form", |
| 38 | + lambda home: home.validate_process_steps(), |
| 39 | + ), |
| 40 | + ("Validate user able to delete file", lambda home: home.delete_files()), |
22 | 41 | ] |
23 | | - |
| 42 | + |
24 | 43 | # Generate readable test step IDs |
25 | | -golden_path_ids = [f"{i+1:02d}. {desc}" for i, (desc, _) in enumerate(golden_path_steps)] |
| 44 | +golden_path_ids = [ |
| 45 | + f"{i+1:02d}. {desc}" for i, (desc, _) in enumerate(golden_path_steps) |
| 46 | +] |
26 | 47 |
|
27 | 48 |
|
28 | 49 | @pytest.mark.parametrize("description, action", golden_path_steps, ids=golden_path_ids) |
29 | 50 | def test_content_processing_steps(login_logout, description, action, request): |
30 | 51 | """ |
31 | 52 | Executes Golden Path content processing steps with individual log entries. |
32 | 53 | """ |
33 | | - request.node._nodeid = description |
34 | 54 |
|
35 | 55 | page = login_logout |
36 | 56 | home = HomePage(page) |
37 | | - |
| 57 | + |
38 | 58 | logger.info(f"Running test step: {description}") |
| 59 | + |
| 60 | + start_time = time.time() |
| 61 | + |
39 | 62 | try: |
40 | 63 | action(home) |
| 64 | + duration = time.time() - start_time |
| 65 | + logger.info(f"Step passed: {description} (Duration: {duration:.2f} seconds)") |
| 66 | + request.node._report_sections.append( |
| 67 | + ("call", "log", f"Step passed: {description} (Duration: {duration:.2f} seconds)") |
| 68 | + ) |
41 | 69 | except Exception as e: |
42 | | - logger.error(f"Step failed: {description}") |
| 70 | + duration = time.time() - start_time |
| 71 | + logger.error(f"Step failed: {description} (Duration: {duration:.2f} seconds)") |
43 | 72 | raise |
44 | | - |
45 | | - # Optionally attach to report |
| 73 | + |
| 74 | + request.node._nodeid = description |
| 75 | + |
46 | 76 | request.node._report_sections.append(("call", "log", f"Step passed: {description}")) |
0 commit comments