Skip to content

Commit c5284ba

Browse files
committed
fix(tests): improve OTP input field detection with multiple selectors
- Add robust selector fallback for OTP input field - Add debugging logs for URL and page title after email submission - Include page source snippet in error output for troubleshooting - Handle dynamic testids and various input field patterns The CI run showed email/OTP flow working perfectly, just needed more resilient OTP field detection for different page states.
1 parent 917e233 commit c5284ba

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

sample/Tests/test/test_windows_helpers.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,36 @@ def login():
271271
driver.quit()
272272

273273
print("Find OTP input...")
274-
otp_field = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'input[data-testid="passwordless_passcode__TextInput--0__input"]')))
274+
print(f"Current URL after email submission: {driver.current_url}")
275+
print(f"Page title after email submission: {driver.title}")
276+
277+
# Try multiple selectors for OTP input field
278+
otp_selectors = [
279+
'input[data-testid="passwordless_passcode__TextInput--0__input"]', # Original
280+
'input[placeholder*="verification"]', # By placeholder text
281+
'input[type="text"][maxlength="6"]', # By input type and length
282+
'input[autocomplete="one-time-code"]', # By autocomplete attribute
283+
'.otp-input input', # By class
284+
'input[data-testid*="passcode"]', # Partial testid match
285+
'input[name*="otp"]', # By name attribute
286+
'input[id*="otp"]' # By id attribute
287+
]
288+
289+
otp_field = None
290+
for selector in otp_selectors:
291+
try:
292+
print(f"Trying OTP selector: {selector}")
293+
otp_field = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.CSS_SELECTOR, selector)))
294+
print(f"Found OTP field with selector: {selector}")
295+
break
296+
except:
297+
continue
298+
299+
if not otp_field:
300+
print("Could not find OTP input field with any selector!")
301+
print("Page source snippet:")
302+
print(driver.page_source[:2000]) # First 2000 chars for debugging
303+
raise Exception("OTP input field not found")
275304
print("Enter OTP")
276305
otp_field.send_keys(code)
277306

0 commit comments

Comments
 (0)