apk没有INTERNET权限。Selendroid需要互联网许可才能继续

2024-09-24 22:26:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是APK级别为16的android4.1.2。在

这是我的python代码

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)`

python输出(错误):上面说s-apk没有互联网权限。Selendroid需要互联网许可才能继续

^{pr2}$

*这是我在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 `

如何解决这个问题??


Tags: todebuginfoapphomejscapsat
1条回答
网友
1楼 · 发布于 2024-09-24 22:26:41

测试中的应用程序在<application>标记外的代码中的AndroidManifest.xml文件中应具有以下权限:

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

引用设计中的http://appium.io/introduction.html?lang=en

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)

因此,测试的API级别和所使用的自动化类型在appium访问应用程序的方式上产生了差异。在

相关问题 更多 >