How to turn on Data / Bluetooth / WIFI in android?

I try work with driver.toggleLocationServices(); its work
but for driver.toggleWifi(); And driver.toggleData(); Does not work (its not support in last version)

https://appium.io/docs/en/commands/device/network/toggle-wifi/
https://appium.io/docs/en/commands/device/network/toggle-data/

and also How to turn on Bluetooth?
Do you have an effective solution that works for me?
thanks

I assume this would only reliably work on an emulator. Real device don’t allow such actions because of struct security limitations that Google has added there in recent OS releases.

1 Like

Thanks
its must to be on real device

So now we don’t have any solution ?

you have :-). just make it as human! open notification and tap needed icon.

1 Like

Thanks Aleksei

True this is another way ,But she is not stable at all
Because the location and names of the buttons vary from device to device

I found the buttons and it works
But note that for WIFI there is a name of the network, if the network changes then the test will fail

Is there a more stable way to control it?

//driver.findElement(By.xpath("//[@id=‘icon’ and ./parent::[@contentDescription=‘Wi-Fi,On.,EdimaxAPa8_2EX,Button’]]")).click();
//driver.findElement(By.xpath("//[@id=‘icon’ and ./parent::[@contentDescription=‘Bluetooth,On.,Button’]]")).click();
//driver.findElement(By.xpath("//[@id=‘icon’ and ./parent::[@contentDescription=‘Mobile,data,On.,Button’]]")).click();

Elad

No way yo make it working with all devices. Just choose some and make with them only.

1 Like

Do you know if in the future the APPIUM library will support it again?
same as ?
driver.toggleWifi ();
driver.toggleData();

@Aleksei
I found another way and I think gives the solution
If you click on AirplaneMode button
Then WIFI / Data / Bluetooth shuts down
And with another click everything opens back up

It might work well for me, until there is an Appium solution

Elad

nice.
regarding Appium solution - all depends on Android as far as Appium just uses what Google gives.

1 Like