"Simulation" on real devices

Mobile Testing, Android App Testing.
aikvahidi
Posts: 2
Joined: Wed Feb 07, 2018 11:41 am

"Simulation" on real devices

Post by aikvahidi » Wed Feb 07, 2018 12:00 pm

Is it possible to simulate (or set) the following options on real devices?
1) Wifi on/of
2) SIM card
3) Battery on/off
4) Airplane mode on/off
5) Wifi/Local network change
6) Screen orientation change

qwertzu
Posts: 232
Joined: Wed Jan 25, 2017 11:08 am

Re: "Simulation" on real devices

Post by qwertzu » Thu Feb 08, 2018 1:32 pm

Hi,
you could try to use android OS automation which helps automating system apps on an android device.
osautomation.jpg
osautomation.jpg (58.33 KiB) Viewed 725 times
regards, qwertzu

aikvahidi
Posts: 2
Joined: Wed Feb 07, 2018 11:41 am

Re: "Simulation" on real devices

Post by aikvahidi » Thu Feb 08, 2018 2:23 pm

Thanks. But what if I want to test iOS?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4662
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: "Simulation" on real devices

Post by odklizec » Thu Feb 08, 2018 2:31 pm

Hi,

iOS does not allow automate system apps. It's iOS security thing. There is nothing Ranorex can do about this. In fact, some of the mentioned apps may not be possible to automate even on Android.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

hubjohn
Posts: 4
Joined: Mon Feb 12, 2018 10:47 am
Location: Singapore
Contact:

Re: "Simulation" on real devices

Post by hubjohn » Mon Feb 26, 2018 2:54 pm

I think some of the mentioned apps may not be possible to automate even on Android.

SanMan
Posts: 196
Joined: Tue Apr 13, 2010 9:59 am

Re: "Simulation" on real devices

Post by SanMan » Tue Apr 23, 2019 9:31 am

On Android device (Android OS automation true)

How I can change e.g. Airplane mode ?

It must be some user code...?

SanMan
Posts: 196
Joined: Tue Apr 13, 2010 9:59 am

Re: "Simulation" on real devices

Post by SanMan » Tue Apr 23, 2019 9:31 am

On Android device (Android OS automation true)

How I can change e.g. Airplane mode ?

It must be some user code...?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4662
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: "Simulation" on real devices

Post by odklizec » Tue Apr 23, 2019 9:39 am

Hi,

You will most probably have to use ADB command for this. You can learn how to send ADB commands in Ranorex for example here:
send-adb-commands-via-ranorex-t10596.html#p42515

For an example of code for switching airplane mode, check this page:
https://stackoverflow.com/questions/105 ... b/23413344
Basically, you just need to extract the adb arguments from the above link and apply them in Ranorex code from the first link.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

SanMan
Posts: 196
Joined: Tue Apr 13, 2010 9:59 am

Re: "Simulation" on real devices

Post by SanMan » Tue Apr 23, 2019 11:19 am

Hi odklizec,

thank you for your answer.

I managed to set the airplane mode UI status on/off, but could not switch the mode really on/off

C:\Program Files (x86)\Ranorex\Studio\Bin\RxEnv\Android\Tools>adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
Broadcasting: Intent { act=android.intent.action.AIRPLANE_MODE flg=0x400000 }
Security exception: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=27709, uid=2000

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=27709, uid=2000
at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:21899)
at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:22588)
at com.android.server.am.ActivityManagerShellCommand.runSendBroadcast(ActivityManagerShellCommand.java:683)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:174)
at android.os.ShellCommand.exec(ShellCommand.java:103)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:16532)
at android.os.Binder.shellCommand(Binder.java:634)
at android.os.Binder.onTransact(Binder.java:532)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3530)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3426)
at android.os.Binder.execTransact(Binder.java:731)

Seems that I need to modify "AndroidManifest.xml" file and add there permission:

<uses-permission android:name="android.permission.WRITE_SETTINGS" />

Is that right?

And where can I found this AndroidManifest.xml file? I did remove the folder "decomp" under..\Android\temp. Should it be auto created when building a project?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4662
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: "Simulation" on real devices

Post by odklizec » Tue Apr 23, 2019 11:46 am

Hi,

I believe the AndroidManifest.xml is created during APK instrumentation, not during building the test project?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

SanMan
Posts: 196
Joined: Tue Apr 13, 2010 9:59 am

Re: "Simulation" on real devices

Post by SanMan » Tue Apr 23, 2019 12:10 pm

Hi,

And now when I cannot instrument/use APK (made with crosswalk tech), is there any way I can get the AndroidManifest.xml what I could modify?

SanMan
Posts: 196
Joined: Tue Apr 13, 2010 9:59 am

Re: "Simulation" on real devices

Post by SanMan » Wed Apr 24, 2019 11:17 am

I think "Install RxBrowser" did the job and got the AndroidManifest.xml

When I added the <uses-permission android:name="android.permission.WRITE_SETTINGS" />, I still got this error:

C:\Program Files (x86)\Ranorex\Studio\Bin\RxEnv\Android\Tools>adb shell am broadcast -a android.intent.action.AIRPLANE_MODE
Broadcasting: Intent { act=android.intent.action.AIRPLANE_MODE flg=0x400000 }
Security exception: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=29648, uid=2000

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=29648, uid=2000
at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:21899)
at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:22588)
at com.android.server.am.ActivityManagerShellCommand.runSendBroadcast(ActivityManagerShellCommand.java:683)
at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:174)
at android.os.ShellCommand.exec(ShellCommand.java:103)
at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:16532)
at android.os.Binder.shellCommand(Binder.java:634)
at android.os.Binder.onTransact(Binder.java:532)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3530)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3426)
at android.os.Binder.execTransact(Binder.java:731)

What I browsed (and understood : ) ), seems that it is no longer possible to set airplane mode or mobile data mode on/off?

Wlan can be easily set by:
adb shell "svc wifi enable"

adb shell "svc wifi disable"

User avatar
RobinHood42
Posts: 285
Joined: Fri Jan 09, 2015 3:24 pm

Re: "Simulation" on real devices

Post by RobinHood42 » Fri Apr 26, 2019 12:43 pm

That seems to be true. According to this post, it is not possible.
https://stackoverflow.com/questions/438 ... -android-7

Cheers,
Robin