|
38 | 38 | else: |
39 | 39 | print(f' ❌ FAIL: Expected 1 absolute XPath, got {len(result_1)}') |
40 | 40 | if len(result_1) > 0 and result_1[0] != absolute_xpath: |
41 | | - print(f' ❌ FAIL: First XPath is not the absolute one!') |
| 41 | + print(' ❌ FAIL: First XPath is not the absolute one!') |
42 | 42 |
|
43 | 43 | # Test max_alternatives = 2 |
44 | 44 | print('\n📋 Test 2: max_alternatives=2') |
|
55 | 55 | test_2_pass = ( |
56 | 56 | len(result_2) == 2 |
57 | 57 | and result_2[-1] == absolute_xpath # Last is absolute |
58 | | - and result_2[0] != absolute_xpath # First is optimized (different from absolute) |
| 58 | + and result_2[0] != absolute_xpath # First is optimized (different from absolute) |
59 | 59 | ) |
60 | 60 | if test_2_pass: |
61 | 61 | print(' ✅ PASS: Exactly 2 XPaths (1 optimized + 1 absolute)') |
62 | 62 | else: |
63 | 63 | print(f' ❌ FAIL: Expected 2 XPaths (1 optimized + 1 absolute), got {len(result_2)}') |
64 | 64 | if len(result_2) >= 2 and result_2[-1] != absolute_xpath: |
65 | | - print(f' ❌ FAIL: Last XPath is not the absolute fallback!') |
| 65 | + print(' ❌ FAIL: Last XPath is not the absolute fallback!') |
66 | 66 | if len(result_2) >= 1 and result_2[0] == absolute_xpath: |
67 | | - print(f' ❌ FAIL: First XPath should be optimized, not absolute!') |
| 67 | + print(' ❌ FAIL: First XPath should be optimized, not absolute!') |
68 | 68 |
|
69 | 69 | # Test max_alternatives = 3 |
70 | 70 | print('\n📋 Test 3: max_alternatives=3') |
|
81 | 81 | optimized_count = sum(1 for xpath in result_3[:-1] if xpath != absolute_xpath) |
82 | 82 | test_3_pass = ( |
83 | 83 | len(result_3) == 3 |
84 | | - and result_3[-1] == absolute_xpath # Last is absolute |
85 | | - and optimized_count >= 1 # At least 1 optimized (ideally 2) |
| 84 | + and result_3[-1] == absolute_xpath # Last is absolute |
| 85 | + and optimized_count >= 1 # At least 1 optimized (ideally 2) |
86 | 86 | and all(xpath != absolute_xpath for xpath in result_3[:-1]) # All except last are different from absolute |
87 | 87 | ) |
88 | 88 | if test_3_pass: |
89 | 89 | print(f' ✅ PASS: Exactly 3 XPaths ({optimized_count} optimized + 1 absolute)') |
90 | 90 | else: |
91 | 91 | print(f' ❌ FAIL: Expected 3 XPaths (2 optimized + 1 absolute), got {len(result_3)}') |
92 | 92 | if len(result_3) >= 3 and result_3[-1] != absolute_xpath: |
93 | | - print(f' ❌ FAIL: Last XPath is not the absolute fallback!') |
| 93 | + print(' ❌ FAIL: Last XPath is not the absolute fallback!') |
94 | 94 | if len(result_3) >= 2: |
95 | 95 | non_optimized = sum(1 for xpath in result_3[:-1] if xpath == absolute_xpath) |
96 | 96 | if non_optimized > 0: |
|
0 commit comments