python - How to get/set network connection through Appium for an android device -


i try use appium test android device: basic work need network connection status. environment: [appium server v 1.4.0 on windows 7 + python client 0.16]

from appium import webdriver  desired_caps = {} desired_caps['platformname'] = 'android' desired_caps['platformversion'] = '4.4' desired_caps['devicename'] = 'samsung galaxy note4' desired_caps['browsername'] = 'chrome'   driver = webdriver.remote('http://localhost:4723/wd/hub', desired_caps) driver.get('http://google.com') print driver.contexts print driver.network_connection time.sleep(5) driver.quit() 

however, when run script, got below output:

> [u'native_app', u'webview_1'] traceback (most recent call last):   > file "d:/pycharmprojects/work/hello/work_ym/appium/sample_1.py", line > 15, in <module> >     print driver.network_connection()   file "c:\python27\lib\site-packages\appium\webdriver\webdriver.py", line > 601, in network_connection >     return self.execute(command.get_network_connection, {})['value']   file > "c:\python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", > line 195, in execute >     self.error_handler.check_response(response)   file "c:\python27\lib\site-packages\appium\webdriver\errorhandler.py", line > 29, in check_response >     raise wde selenium.common.exceptions.webdriverexception: message: "unknown command: > session/31fe15845b2580877c1900c31d8f688d/network_connection" 

it seems network_connection(which property of webdriver) doesn't work, can give help? thanks!

you can get/change network connection settings through androiddriver. however, works android version less 5.

appiumdriver<webelement> driver = new androiddriver<webelement>(new url("..."), caps); networkconnectionsetting networkconnection = new networkconnectionsetting(false, true, false);  // airplane mode, wiif, data  networkconnection.setdata(true);  // enable mobile data networkconnection.setwifi(false); // close wifi  ((androiddriver<webelement>)driver).setnetworkconnection(networkconnection); networkconnection = ((androiddriver<webelement>)driver).getnetworkconnection(); 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -