Test Overview
This test compares running a mobile app test on an emulator versus a real device. It verifies that the app launches and a key button is clickable on both platforms.
This test compares running a mobile app test on an emulator versus a real device. It verifies that the app launches and a key button is clickable on both platforms.
from appium import webdriver import unittest class TestAppOnDevices(unittest.TestCase): def setUp(self): # Setup for emulator self.emulator_caps = { 'platformName': 'Android', 'deviceName': 'Android Emulator', 'app': '/path/to/app.apk' } # Setup for real device self.real_device_caps = { 'platformName': 'Android', 'deviceName': 'RealDevice123', 'app': '/path/to/app.apk' } def test_on_emulator(self): driver = webdriver.Remote('http://localhost:4723/wd/hub', self.emulator_caps) button = driver.find_element('id', 'com.example.app:id/startButton') button.click() self.assertTrue(button.is_enabled()) driver.quit() def test_on_real_device(self): driver = webdriver.Remote('http://localhost:4723/wd/hub', self.real_device_caps) button = driver.find_element('id', 'com.example.app:id/startButton') button.click() self.assertTrue(button.is_enabled()) driver.quit() if __name__ == '__main__': unittest.main()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts for emulator setup | Appium server running, emulator device ready | - | PASS |
| 2 | Driver connects to emulator and launches app | App is launched on emulator screen | - | PASS |
| 3 | Finds start button by id on emulator | Start button visible on emulator app screen | Element with id 'com.example.app:id/startButton' is found | PASS |
| 4 | Clicks start button on emulator | Button click triggers expected UI response | Button is enabled after click | PASS |
| 5 | Driver quits emulator session | Emulator app closed | - | PASS |
| 6 | Test starts for real device setup | Appium server running, real device connected | - | PASS |
| 7 | Driver connects to real device and launches app | App is launched on real device screen | - | PASS |
| 8 | Finds start button by id on real device | Start button visible on real device app screen | Element with id 'com.example.app:id/startButton' is found | PASS |
| 9 | Clicks start button on real device | Button click triggers expected UI response | Button is enabled after click | PASS |
| 10 | Driver quits real device session | Real device app closed | - | PASS |