apk does not have INTERNET permissions. Selendroid needs internet permission to proceed

喜你入骨 提交于 2019-12-11 10:50:54

问题


I am using android 4.1.2 whose APK level is 16.

This is my python code:

def setUp(self):
            "Setup for the test"
        desired_caps = {}
        desired_caps['automationName']='Selendroid'
        desired_caps['browserName']=''
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '4.1.2'
        desired_caps['deviceName'] = 'd65d04425101de'
            # Returns abs path relative to this file and not cwd
        desired_caps['app'] = '/home/karthik/appiumworkspace/tests/app-debug (2).apk'
        desired_caps['appPackage'] = 'com.prueba.maverick'
        desired_caps['app-activity'] = '.SplashActivity' 
        desired_caps['app-wait-activity'] = '.MainActivity' 
        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)`

The python output (error): It says thats- apk does not have INTERNET permissions. Selendroid needs internet permission to proceed

karthik@dkarnik2-Vostro-3558:~/appiumworkspace/appium-1.4.13/submodules/sample-code/examples/python$ python maverick.test.in.mobile.using.appium.py
test_record_the_audio (__main__.MaverickAndroidTests)
Test it clicks on Record button correctly ... ERROR

======================================================================
ERROR: test_record_the_audio (__main__.MaverickAndroidTests)
Test it clicks on Record button correctly
----------------------------------------------------------------------
Traceback (most recent call last):
  File "maverick.test.in.mobile.using.appium.py", line 47, in setUp
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
  File "/usr/local/lib/python2.7/dist-packages/appium/webdriver/webdriver.py", line 36, in __init__
super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 87, in __init__
self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 141, in start_session
'desiredCapabilities': desired_capabilities,
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: A new session could not be created. (Original error: apk does not have INTERNET permissions. Selendroid needs internet permission to proceed, please check if you have <uses-permission android:name="android.**permission.INTERNET"/> in your AndroidManifest.xml)


----------------------------------------------------------------------
Ran 1 test in 0.242s

FAILED (errors=1)

*This is what I get in Appium : *

info: --> POST /wd/hub/session {"desiredCapabilities":{"deviceName":"d65d04425101de","automationName":"Selendroid","app-wait-activity":".MainActivity","browserName":"","appPackage":"com.prueba.maverick","platformVersion":"4.1.2","app-activity":".SplashActivity","platformName":"Android","app":"/home/karthik/appiumworkspace/tests/app-debug (2).apk"}}
info: Client User-Agent string: Python-urllib/2.7
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : app-wait-activity, app-activity
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: /home/karthik/appiumworkspace/tests/app-debug (2).apk
info: [debug] Creating new appium session 32a66533-2ca7-4e7b-80e8-e12e6a24c774
info: [debug] Starting selendroid server
info: [debug] Getting Java version
info: Java version is: 1.7.0_95
info: [debug] Checking whether adb is present
info: [debug] Using adb from /home/karthik/selenium/android-sdk-linux/platform-tools/adb
info: [debug] Checking whether selendroid is built yet
info: [debug] Selendroid server exists!
info: [debug] Using fast reset? false
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices...
info: [debug] executing cmd: /home/karthik/selenium/android-sdk-linux/platform-tools/adb devices
info: [debug] 1 device(s) connected
info: Found device d65d04425101de
info: [debug] Setting device id to d65d04425101de
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: /home/karthik/selenium/android-sdk-linux/platform-tools/adb -s d65d04425101de wait-for-device
info: [debug] executing cmd: /home/karthik/selenium/android-sdk-linux/platform-tools/adb -s d65d04425101de shell "echo 'ready'"
info: [debug] Starting logcat capture
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from /home/karthik/selenium/android-sdk-linux/build-tools/23.0.2/aapt
info: [debug] Checking if has internet permission from manifest.
info: [debug] executing cmd: /home/karthik/selenium/android-sdk-linux/build-tools/23.0.2/aapt dump badging "/home/karthik/appiumworkspace/tests/app-debug (2).apk"
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: apk does not have INTERNET permissions. Selendroid needs internet permission to proceed, please check if you have <uses-permission android:name="android.**permission.INTERNET"/> in your AndroidManifest.xml
info: [debug] Error: apk does not have INTERNET permissions. Selendroid needs internet permission to proceed, please check if you have <uses-permission android:name="android.**permission.INTERNET"/> in your AndroidManifest.xml
at /home/karthik/.linuxbrew/lib/node_modules/appium/lib/devices/android/selendroid.js:217:10
at /home/karthik/.linuxbrew/lib/node_modules/appium/node_modules/appium-adb/lib/adb.js:1667:7
at ChildProcess.exithandler (child_process.js:193:7)
at emitTwo (events.js:100:13)
at ChildProcess.emit (events.js:185:7)
at maybeClose (internal/child_process.js:827:16)
at Socket.<anonymous> (internal/child_process.js:319:11)
at emitOne (events.js:90:13)
at Socket.emit (events.js:182:7)
at Pipe._onclose (net.js:475:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: apk does not have INTERNET permissions. Selendroid needs internet permission to proceed, please check if you have <uses-permission android:name=\"android.**permission.INTERNET\"/> in your AndroidManifest.xml)","origValue":"apk does not have INTERNET permissions. Selendroid needs internet permission to proceed, please check if you have <uses-permission android:name=\"android.**permission.INTERNET\"/> in your AndroidManifest.xml"},"sessionId":null}
info: <-- POST /wd/hub/session 500 236.606 ms - 536 `

How to solve this problem ??


回答1:


The application under test should have following permissions in the AndroidManifest.xmlfile in the code outside the <application> tag :

<uses-permission android:name="android.permission.INTERNET" /> 

Quoting from http://appium.io/introduction.html?lang=en under Design

The vendor-provided frameworks we use are:

iOS: Apple's UIAutomation Android

4.2+: Google's UiAutomator Android

2.3+: Google's Instrumentation. (Instrumentation support is provided by bundling a separate project, Selendroid)

So the API level at which you are testing and the automation type you are using creates the difference in how appium tries to access your application.



来源:https://stackoverflow.com/questions/35883125/apk-does-not-have-internet-permissions-selendroid-needs-internet-permission-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!