Перейти к содержимому

Appium Page Object Model in Java: Pages, Config and a Driver Factory | Appium Android Testing #08

Code & Test Automation

0:00 / 0:00

Appium Page Object Model in Java: Pages, Config and a Driver Factory | Appium Android Testing #08

0 просмотров · 17 ч назад
Code & Test Automation
16 подписчиков
0 просмотров · 17 ч назад
Code & Test Automation |    / @codetestautomation   Turn scattered Appium test code into a small, readable framework in Java. We build a Config class where a system property beats an environment variable, which beats config.properties, and print where every setting came from. Then a DriverFactory that is the one place that starts a session, a Waits helper from video 06, a BasePage, and LoginPage and HomePage objects whose methods describe what a user does, not which locators they touch. On top sit a BaseTest that opens and closes the session, a JUnit 5 TestWatcher that takes a screenshot on failure, and a LoginTest that reads like a story. Five offline JUnit tests check the configuration and the capabilities the factory builds. The device tests are run for real on a machine with no emulator, so you see the factory's log line, the real session error, and the screenshot watcher's honest message. Video 8 of 10 in Appium Android Testing, for fresher and experienced engineers: installing Appium and the UiAutomator2 driver, capabilities and the first session, locators, basic interactions and assertions, gestures, waits and flakiness, app management, the Page Object Model, emulators, real devices and ADB, and CI/CD with reports. CHAPTERS 0:00 Introduction 1:01 Why Page Objects 2:53 Configuration 6:12 Pages and a driver factory 9:08 Tests on top 15:09 Recap 16:11 Subscribe HOW THE DEMOS WERE MADE Every command, test run and terminal output in this video was run for real (Appium 3.9.0, UiAutomator2 driver 8.7.3, Node.js v24.22.1, adb platform-tools 37.0.1-15733141, OpenJDK 21.0.13 2026-10-20 LTS, Apache Maven 3.9.16, Appium java-client 11.0.0; Debian 13 Linux) in throwaway projects created for this video. There is no Android device or emulator on the recording machine (it has no hardware virtualization access), so no Appium device session was ever started: every session request shown fails for real with the error Appium returns. Timestamps and durations in the output are whatever that run took. The final device-test commands are shown typed only, without output, because no emulator could run on this recording machine. Every mvn, grep and find command shown with output was run for real, in a throwaway home folder, with a local Appium server running. No page object in this video ever touched a real screen: the device tests stopped while creating the session. The phone screen is a labelled ILLUSTRATION, a simplified mockup of the sample login app, because there is no Android device or emulator on the recording machine. No Appium device session was created in this video; the attempts are shown failing, for real, with SessionNotCreatedException. Any screen marked ILLUSTRATION is a simplified mockup, not a screenshot; it shows what you will see on a real device or emulator, which you need to run the device steps yourself. PRACTICE Add a page object for one more screen of your app, with methods that describe what a user does there. Then add a setting such as app.apk to config.properties, and print where it came from with ShowConfig. Practice tip: pause at each code and terminal scene, run the same commands on your own machine, and compare your output with what you see on screen. Steps that drive an app need an Android emulator or a real device with USB debugging; everything else runs on any laptop. Next video: #09 Emulators, Real Devices, and Essential ADB. #Appium #MobileTesting #AndroidTesting #TestAutomation #CodeAndTestAutomation Subscribe to Code & Test Automation for more Appium, mobile testing, coding and test automation tutorials:    / @codetestautomation