Skip to content

Commit 0649d8c

Browse files
feat(tests): improve logout reliability with click here link (Windows) and tab cleanup (macOS)
Windows: - Add logic to click 'click here' link on logout page - Tries multiple selectors (partial link text, link text, xpath) - Falls back to registry deep-link dispatch if link not found macOS: - Call close_all_browser_tabs() in logout() after launch_browser() - Ensures clean browser state before logout interaction
1 parent 5512951 commit 0649d8c

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

sample/Tests/test/test_mac.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def login(cls):
209209
def logout(cls):
210210
print("Logging out...")
211211
cls.launch_browser()
212+
cls.close_all_browser_tabs()
212213
bring_sample_app_to_foreground()
213214
cls.altdriver.find_object(By.NAME, "LogoutBtn").tap()
214215
print("Logout button clicked")

sample/Tests/test/test_windows_helpers.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,58 @@ def logout_with_controlled_browser():
372372

373373
# Wait for logout page to load
374374
time.sleep(3)
375+
376+
# Try to click the "click here" link on the logged out page
377+
try:
378+
from selenium.webdriver.support.ui import WebDriverWait
379+
from selenium.webdriver.support import expected_conditions as EC
380+
from selenium.webdriver.common.by import By as SeleniumBy
381+
382+
print("Looking for 'click here' link on logout page...")
383+
# Try multiple possible selectors for the link
384+
link_found = False
385+
386+
# Try by partial link text
387+
try:
388+
link = WebDriverWait(driver, 5).until(
389+
EC.element_to_be_clickable((SeleniumBy.PARTIAL_LINK_TEXT, "click here"))
390+
)
391+
link.click()
392+
print("Clicked 'click here' link successfully")
393+
link_found = True
394+
time.sleep(2) # Wait for callback to process
395+
except:
396+
print("Could not find link by partial link text")
397+
398+
# Try by link text if partial didn't work
399+
if not link_found:
400+
try:
401+
link = WebDriverWait(driver, 2).until(
402+
EC.element_to_be_clickable((SeleniumBy.LINK_TEXT, "click here"))
403+
)
404+
link.click()
405+
print("Clicked 'click here' link successfully")
406+
link_found = True
407+
time.sleep(2) # Wait for callback to process
408+
except:
409+
print("Could not find link by link text")
410+
411+
# Try by xpath as last resort
412+
if not link_found:
413+
try:
414+
link = WebDriverWait(driver, 2).until(
415+
EC.element_to_be_clickable((SeleniumBy.XPATH, "//a[contains(text(), 'click here')]"))
416+
)
417+
link.click()
418+
print("Clicked 'click here' link successfully")
419+
time.sleep(2) # Wait for callback to process
420+
except:
421+
print("Could not find 'click here' link by any method")
422+
423+
except Exception as click_err:
424+
print(f"Could not click 'click here' link: {click_err}")
425+
print("Continuing with fallback deep-link dispatch...")
426+
375427
print("Logout completed in controlled browser")
376428

377429
# Check final page

0 commit comments

Comments
 (0)