简体   繁体   English

使用Selenium / Appium在iOS模拟器上启用/禁用Wifi

[英]Enable/Disable Wifi on iOS simulator using selenium/Appium

I want to test some scenarios on my app when there is no Wifi connectivity, I need to first LogIn on good connection and then switch off the Wifi and continue doing some activities, Is it possible to disable and enable the network by code? 我想在没有Wifi连接的情况下在我的应用程序上测试某些方案,我需要先登录良好的连接,然后关闭Wifi并继续进行一些活动,是否可以通过代码禁用和启用网络? I am using Java/Selenium and Appium Server. 我正在使用Java / Selenium和Appium Server。

try{
    ((HasNetworkConnection) appiumDriver).setConnection(Connection.ALL);
    assertEquals(Connection.ALL,((HasNetworkConnection) appiumDriver).getConnection());
//  NetworkConnectionSetting ncs = new NetworkConnectionSetting(false, true, true);
    ((HasNetworkConnection) appiumDriver).setConnection(Connection.NONE);
    assertEquals(Connection.NONE, ((HasNetworkConnection) appiumDriver).getConnection());
}
catch(Exception e)
{e.printStackTrace();}
}

I only can recommend you use the Network Link Conditioner app from Apple. 我只能建议您使用Apple的Network Link Conditioner应用程序。 For more information please read NSHipster blog. 有关更多信息,请阅读NSHipster博客。

Some potential on this topic is contained over here . 关于这一主题的一些潜在被包含在这里 You can try creating a class of yours which includes an instance of NetworkConnectionSetting in the java-client of appium and set the flags accordingly by calling the built-in methods. 您可以尝试在appium的java-client中创建一个包含NetworkConnectionSetting实例的类,并通过调用内置方法来相应地设置标志。

This class 'NetworkConnectionSetting' works on Android. 此类“ NetworkConnectionSetting”在Android上适用。 As per the request, the need is for iOS app. 根据要求,需要iOS应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM