Emna Ayadi
Emna Ayadi

Reputation: 2460

How can i disable internet connectivity in Android Emulator with Appium?

I want to test the connectivity icon in 3 cases :

  1. When the connection status is fine

  2. When few heartbeats were missed and/or if the web socket is closed.

  3. When no internet

In Case one i can test it because i'm always connected to the internet but others i can't.

PS: I'm using TestNG with Appium and Java

What do you suggest ?

Upvotes: 0

Views: 1331

Answers (2)

Maxim Karnaukh
Maxim Karnaukh

Reputation: 26

driver.ConnectionType = ConnectionType.None;

Or something like this. In this case driver is AndroidDriver instance for appium tests

Upvotes: 1

noor
noor

Reputation: 3004

i use the below code to stop wifi connection in ios :

Runtime rt = Runtime.getRuntime();
try {
    rt.exec("networksetup -setairportpower en0 off");
    System.out.println("Wifi OFF Successfully");
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

use below to on wifi:

rt.exec("networksetup -setairportpower en0 on");

Upvotes: 1

Related Questions