How to enable/disable mobile data and Settings Tab in an Android Device

I need to enable/disable the Mobile Data, enable/disable bluetooth and play around with the Settings of the Android Device. How can i achieve this using the Katalon tool >

Kindly help in this pls.

I would agree with Point 1) said.
For the code provided by you earlier, is the MobileDriverFactory a class declared as part of this Katalon tool. Pls let me know.
As i did the recording on the Andorid UI, i go to Settings, and then to the USB Tethering Option, its got a slider there and when i capture that , it shows me “android.widget.Switch0 – OFF” indicating that USB Tethering is disabled, so i wanted to enable USB Tethering by using something like “android.widget.Switch0 – ON”. How can i achieve this.

I see android.widget.Switch0 - OFF, for the USB Tethering option. I need to enable this android.widget.Switch0 - ON. How can i achieve this.

Can you also pls help me to attach the screenshot in this ticket. I cannot see an option to attach the attachment here.

Thanks. Now i tried to do the steps as mentioned in your first comment, but there are many failures that i have come across.

Is it possible to have a view of the Android UI ( virtual emulator view) when i click on the Mobile Spy, or even during the runtime/execution of the code, since i dont see the Virtual Emulator coming up on the screen. I always have to look at the real device to check on the operations done by the code.

Pls provide your comments.

Thanks for the reply. Now does Appium have the feature to automate the Settings of the Android UI, like can we be able to Enable/Disable mobile data etc.

Pls let me know in case of Appium Tool.

Now instead of Manually pressing the Home Button on the real device, can i use some Katalon APIs to go to the Home Screen. Kindly let me know.

Hi Santosh,

1. I have to confirm you that the Device View is only displayed in Mobile Object Spy/Record.

2. With regards to your first concern of this topic, I think you should use my provided code since the solution in my first comment is just a work around.

3. We’re so sorry for the inconvenience that we are not able to upload photos via this forum at this moment. Please upload your photo to another host and send us the hyperlink.

4. “I see android.widget.Switch0 – OFF, for the USB Tethering option. I need to enable this android.widget.Switch0 – ON. How can i achieve this.” I’m sorry I’m confused about this concern, could you please specify it?

Hi Santosh,

1. Yes, you can automate some settings of Android device (Bluetooth, Cellular Data). For now, we don’t have any keywords supported this action but you can create a custom keyword as below:

boolean isAirplaneOn = false;
boolean isWifiOn = false;
boolean isDataOn = false;
AndroidDriver androidDriver = (AndroidDriver) MobileDriverFactory.getDriver()
androidDriver.setNetworkConnection(new NetworkConnectionSetting(isAirplaneOn, isWifiOn, isDataOn))

2. Sure, you can use “Press Home” keyword to navigate to the home screen during your execution. However, you have to manually do it when you use the Mobile Object Spy.

Thanks.

Hi Santosh,

Actually, we have not provided yet keywords for your scenario. However, you can work around as below steps:

1. You should pin the Android Settings to the home screen
2. In Mobile Object Spy, you start with any application (This keyword will start your Appium session)
3. You press home on your real device and click Capture Object in Object Spy
4. Now, you can capture the Android Settings and continue your scenario

What about a https://mobile-phone-tracker.org mobile recorder on Android?

how to enable/disable cellular data or wifi automation using katalon in Mobile android?

If you are using mobile android, then the best way is using ‘adb’ command. You need to have an overview knowledge about activities in Android application: https://appiumpro.com/editions/56
Secondly, call ‘adb’ command directly from the test script to enable/disable wifi settings automatically. The command can be referred from this: https://stackoverflow.com/questions/10282484/android-adb-turn-on-wifi-via-adb

I search to find how to turn off Wifi and turn it on after and all the commands seems deprecated or not compatible with Android version 7 and over any idea? Maybe @Chris_Trevarthen would know this???

thanks in advance

Hi @jtheoret,

The following worked for me with Katalon Studio 7:

import io.appium.java_client.AppiumDriver
import io.appium.java_client.android.connection.ConnectionState
import io.appium.java_client.android.connection.ConnectionStateBuilder

// Turn wifi off:
AppiumDriver<?> driver = MobileDriverFactory.getDriver()
ConnectionState cs = new ConnectionStateBuilder().withWiFiDisabled().build()
driver.setConnection(cs) 

// Turn wifi on again:
cs = new ConnectionStateBuilder().withWiFiEnabled().build()
driver.setConnection(cs) 

Here’s some more info on the ConnectionStateBuilder:

https://www.javadoc.io/doc/io.appium/java-client/6.1.0/index.html

It looks like there might be some limitations to what data settings you can turn on and off:

http://appium.io/docs/en/writing-running-appium/other/network-connection/

Hope this helps,

Chris