gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:11:40 26 4
gpt4 key购买 nike

我使用的是 android 4.1.2,其 APK 级别为 16。

这是我的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 输出(错误):它说那是- apk 没有 INTERNET 权限。 Selendroid 需要互联网许可才能继续

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)

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

如何解决这个问题??

最佳答案

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

<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 尝试访问您的应用程序的方式有所不同。

关于android - apk 没有 INTERNET 权限。 Selendroid 需要互联网许可才能继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35883125/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com