Lesson 59: Mobile Page Object Model
The Junior Trap: “I’ll Just Find the Element Directly”
Picture a fresh automation engineer handed their first mobile test task: “Automate the login flow.” They fire up Appium Inspector, grab the XPath, and write this:
# ❌ The Junior Trap
def test_login():
driver.find_element(By.XPATH, '//android.widget.EditText[@resource-id="com.app:id/username"]').send_keys("admin")
driver.find_element(By.XPATH, '//android.widget.EditText[@resource-id="com.app:id/password"]').send_keys("pass123")
driver.find_element(By.ID, "com.app:id/login_btn").click()
time.sleep(5) # "give the app time to load"
assert driver.find_element(By.ID, "com.app:id/home_header").is_displayed()
Then they copy this exact pattern into
test_profile.py,test_checkout.py, and 14 other test files — always grabbing the locator fresh, always trustingtime.sleep.
Why this destroys you in CI/CD:
Maintenance explosion: When the dev team renames
com.app:id/login_btntocom.app:id/btn_login(happens every sprint), you now have a grep-and-replace hunt across 15 files. In a pipeline running at 2 AM, this means a red build nobody can explain.time.sleep(5)is a lie: On a cloud device farm (BrowserStack, Sauce Labs), network RTT varies from 80 ms to 4 seconds.sleep(5)either wastes 4.9 seconds or fails intermittently. In a 200-test suite, that’s 16+ minutes of wasted wait time — guaranteed.Zero reuse: Every test re-invents the same interactions. You’re not building a framework; you’re building technical debt.
GitHub Link :
https://github.com/sysdr/auto-testing-manual-p/tree/main/lesson59/lesson_59_workspace


