appium / appium/java-client

Value of Switches in iOS 12 always returned as 0

Open
#1,265 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.3k
Forks
752
Avg merge
6d 21h
Merged PRs (30d)
8

Description

Description

When I need to get the value of XCUIElementTypeSwitch it always returns 0. Appium UI Explorer shows the correct value of the switches, but the value is incorrect during automated tests. Occurs on iOS 12, doesn't occur on iOS 13.

Environment

  • Java client 7.3.0
  • Appium server version: 1.15.0 / 1.16.0-beta1
  • Desktop OS/version: macOS 10.14.6
  • Node.js version: 10.17.0 / 12.13.0
  • Mobile platform/version under test: iOS 12.1.4
  • Real device or emulator/simulator: real device - iPhone 8

Code To Reproduce Issue [ Good To Have ]

public void bluetoothOff() throws Exception {
    driver.runAppInBackground(Duration.ofSeconds(-1));
    driver.activateApp("com.apple.Preferences");
    driver.terminateApp("com.apple.Preferences");
    driver.activateApp("com.apple.Preferences");
    driver.findElement(By.id("Bluetooth")).click();

    WebElement BLE = driver.findElement(MobileBy.iOSClassChain("**/XCUIElementTypeSwitch[`name==\"Bluetooth\"`]"));
    String BluetoothState = BLE.getAttribute("value");
        if (BluetoothState.equals("1")) {
            BLE.click();
        } else {
            System.out.println("Bluetooth already disabled");
        }
        driver.launchApp();
}

Exception Stacktraces

No exception, just returns 0 every time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided bluetoothOff() reproduction and compare BLE.getAttribute("value") on iOS 12.1.4 and iOS 13, using the listed Appium and Java client versions. Done means an XCUIElementTypeSwitch returns its actual state instead of always returning 0 on iOS 12.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, java
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.