Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Toggle Airplane Mode #1443

Closed
mdethlefs opened this issue Sep 13, 2023 · 5 comments
Closed

[Feature Request] Toggle Airplane Mode #1443

mdethlefs opened this issue Sep 13, 2023 · 5 comments
Labels
enhancement New feature request or improvement of an existing feature

Comments

@mdethlefs
Copy link

Is your feature request related to a problem? Please describe.
Our Apps have certain features that only work in airplane mode - like watching downloaded videos etc.
We need a way to toggle the airplane mode on iOS and Android

Describe the solution you'd like
Two simple commands would be great:
- turnAirplanemodeOn
- turnAirplanemodeOff

Describe alternatives you've considered
We tried to do this with the settings app and via control center but that solution is very flaky. Especially on different OS versions

@mdethlefs mdethlefs added the enhancement New feature request or improvement of an existing feature label Sep 13, 2023
@bartekpacia
Copy link
Contributor

bartekpacia commented Sep 21, 2023

Looks like it's possible on Android through adb (link).

It'd be a bit problematic on iOS though, because Airplane Mode is only visible in Control Center on physical devices, which are currently unsupported (see #686). Once they are supported, toggling the airplane mode still (likely) wouldn't work through calling a command (like adb on Android), because there isn't one. So Maestro would have to click through the UI manually - fortunately the icons in the Control Center have a language-independent identifiers assigned (e.g. airplane-mode-button).

Once Control Center is opened, airplane mode could be enabled with:

let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let toggle = springboard.switches["airplane-mode-button"]
if toggle.value! as! String == "0" {
  toggle.tap()
}

And to open Control Center:

func openControlCenter() {
  let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")

  let start: CGVector
  let end: CGVector

  // for iPhone 8 (and older) and iPhone SEs
  start = CGVector(dx: 0.5, dy: 0.99)
  end = CGVector(dx: 0.5, dy: 0.8)
  // for iPhones with notch
  start = CGVector(dx: 0.9, dy: 0.01)
  end = CGVector(dx: 0.9, dy: 0.2)

  let startCoord = springboard.coordinate(withNormalizedOffset: start)
  let endCoord = springboard.coordinate(withNormalizedOffset: end)
  startCoord.press(forDuration: 0.1, thenDragTo: endCoord)
}

@amar-mindtickle
Copy link

@bartekpacia How would you run adb through maestro test/yaml file?

@bartekpacia
Copy link
Contributor

I don't think it's possible now - I was just sketching out implementation idea.

@bartekpacia
Copy link
Contributor

Support for configuring airplane mode on Android was implemented in #1672

And since there's no airplane mode on simulator, I'm going to close this issue.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.
Thank you for helping keep us our issue tracker clean!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature request or improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants