Bird
Raised Fist0
Testing Fundamentalstesting~10 mins

Mobile-specific test cases in Testing Fundamentals - Test Execution Trace

Choose your learning style10 modes available
Test Overview

This test checks if a mobile app's login screen works correctly on a smartphone. It verifies that the app opens, the login fields are visible, the user can enter credentials, and the login button works to access the home screen.

Test Code - Appium with unittest
Testing Fundamentals
import unittest
from appium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class MobileLoginTest(unittest.TestCase):
    def setUp(self):
        desired_caps = {
            "platformName": "Android",
            "deviceName": "Android Emulator",
            "appPackage": "com.example.myapp",
            "appActivity": ".MainActivity",
            "automationName": "UiAutomator2"
        }
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

    def test_login_functionality(self):
        wait = WebDriverWait(self.driver, 10)
        # Wait for username field
        username_field = wait.until(EC.presence_of_element_located((By.ID, "com.example.myapp:id/username")))
        self.assertTrue(username_field.is_displayed())
        username_field.send_keys("testuser")

        # Wait for password field
        password_field = wait.until(EC.presence_of_element_located((By.ID, "com.example.myapp:id/password")))
        self.assertTrue(password_field.is_displayed())
        password_field.send_keys("password123")

        # Wait for login button and click
        login_button = wait.until(EC.element_to_be_clickable((By.ID, "com.example.myapp:id/login_button")))
        login_button.click()

        # Verify home screen loaded by checking welcome message
        welcome_msg = wait.until(EC.presence_of_element_located((By.ID, "com.example.myapp:id/welcome_message")))
        self.assertIn("Welcome", welcome_msg.text)

    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()
Execution Trace - 9 Steps
StepActionSystem StateAssertionResult
1Test starts and Appium driver launches the Android app on emulatorAndroid emulator opens with the app's main activity visible—PASS
2Waits for username input field to appearLogin screen shows username fieldCheck username field is displayedPASS
3Enters 'testuser' into username fieldUsername field contains 'testuser'—PASS
4Waits for password input field to appearLogin screen shows password fieldCheck password field is displayedPASS
5Enters 'password123' into password fieldPassword field contains 'password123'—PASS
6Waits for login button to be clickableLogin button is visible and enabledCheck login button is clickablePASS
7Clicks the login buttonApp navigates to home screen—PASS
8Waits for welcome message on home screenHome screen shows welcome messageVerify welcome message text contains 'Welcome'PASS
9Test ends and Appium driver quitsApp closed, emulator ready for next test—PASS
Failure Scenario
Failing Condition: Login button is not found or not clickable within 10 seconds
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify after clicking the login button?
AThe username field is cleared
BThe home screen shows a welcome message
CThe app closes automatically
DThe password field becomes hidden
Key Result
Always wait explicitly for mobile app elements to appear or become clickable before interacting to avoid flaky tests caused by slow loading or animations.

Practice

(1/5)
1. Which of the following is a key focus when writing mobile-specific test cases?
easy
A. Testing only desktop browser compatibility
B. Testing features unique to mobile devices like GPS and touch gestures
C. Ignoring screen size variations
D. Testing only backend APIs without UI

Solution

  1. Step 1: Understand mobile-specific features

    Mobile devices have unique features like GPS, accelerometer, and touch gestures that desktop devices do not.
  2. Step 2: Identify test case focus

    Mobile-specific test cases must focus on these unique features to find device-specific issues.
  3. Final Answer:

    Testing features unique to mobile devices like GPS and touch gestures -> Option B
  4. Quick Check:

    Mobile features = A [OK]
Hint: Focus on device features unique to mobile devices [OK]
Common Mistakes:
  • Ignoring mobile-only features
  • Testing only desktop scenarios
  • Not considering touch interactions
2. Which syntax correctly describes a test step for checking screen orientation change in a mobile test case?
easy
A. Step 1: Open browser and check URL
B. Step 1: Click desktop menu and verify dropdown
C. Step 1: Rotate device to landscape mode and verify UI adjusts correctly
D. Step 1: Run backend API and check response code

Solution

  1. Step 1: Identify relevant mobile action

    Rotating device orientation is a common mobile-specific action to test UI responsiveness.
  2. Step 2: Match test step syntax

    Step 1: Rotate device to landscape mode and verify UI adjusts correctly clearly states rotating device and verifying UI adjustment, which fits mobile test case syntax.
  3. Final Answer:

    Step 1: Rotate device to landscape mode and verify UI adjusts correctly -> Option C
  4. Quick Check:

    Mobile orientation test = B [OK]
Hint: Look for steps mentioning device rotation or orientation [OK]
Common Mistakes:
  • Confusing desktop actions with mobile
  • Ignoring device rotation in test steps
  • Using backend steps in UI test cases
3. Consider this test step in a mobile app test case:
Step 1: Enable airplane mode
Step 2: Open the app
Step 3: Verify the app shows 'No internet connection'

What is the expected result of Step 3?
medium
A. App shows 'No internet connection' message
B. App logs user out automatically
C. App loads data from server normally
D. App crashes due to no network

Solution

  1. Step 1: Analyze network condition

    Airplane mode disables all network connections, so the app cannot reach the internet.
  2. Step 2: Understand expected app behavior

    The app should detect no internet and show a friendly message, not crash or load data.
  3. Final Answer:

    App shows 'No internet connection' message -> Option A
  4. Quick Check:

    Airplane mode disables network = D [OK]
Hint: No network means app shows offline message, not crash [OK]
Common Mistakes:
  • Assuming app crashes without network
  • Expecting normal data load offline
  • Confusing logout with network loss
4. A tester wrote this mobile test step:
Step 1: Switch device to dark mode
Step 2: Open app
Step 3: Verify app UI uses dark colors

But the test always fails. What is the most likely error?
medium
A. The device was not actually switched to dark mode before testing
B. The app does not support dark mode at all
C. The tester used wrong device model
D. The app crashed on launch

Solution

  1. Step 1: Check test setup correctness

    If the device is not switched to dark mode, the app UI won't change, causing test failure.
  2. Step 2: Consider app support

    While app support matters, the question says test always fails, so setup is more likely the cause.
  3. Final Answer:

    The device was not actually switched to dark mode before testing -> Option A
  4. Quick Check:

    Incorrect setup causes test failure = A [OK]
Hint: Verify device mode before testing UI changes [OK]
Common Mistakes:
  • Skipping device mode setup
  • Assuming app supports dark mode without checking
  • Ignoring device compatibility
5. You need to write a mobile-specific test case to verify the app's behavior when the device battery is low (below 15%). Which of the following is the best test step?
hard
A. Step 1: Connect device to charger
Step 2: Open app
Step 3: Verify app loads data quickly
B. Step 1: Open app
Step 2: Check if app crashes on startup
C. Step 1: Switch device to airplane mode
Step 2: Open app
Step 3: Verify app shows offline message
D. Step 1: Set device battery level to 10%
Step 2: Open app
Step 3: Verify app shows low battery warning and reduces background activity

Solution

  1. Step 1: Simulate low battery condition

    Setting battery level below 15% tests app behavior under low power.
  2. Step 2: Verify app response

    The app should warn user and reduce background tasks to save battery.
  3. Final Answer:

    Step 1: Set device battery level to 10%
    Step 2: Open app
    Step 3: Verify app shows low battery warning and reduces background activity
    -> Option D
  4. Quick Check:

    Low battery test = C [OK]
Hint: Simulate battery level, check app warning and behavior [OK]
Common Mistakes:
  • Testing unrelated conditions
  • Ignoring battery level simulation
  • Confusing network and battery tests
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard