appium实战2的脚本,启动真机的企业微信报错

脚本和appium实战的企业微信的一样,用模拟器跑相同的脚本没有问题,用真机跑就报错

配置信息:Android 8.1,apppium 1.16,Python3.7

开头脚本

from appium import webdriver

from app.page.base_page import BasePage
from app.page.main import Main


class App(BasePage):
    def start(self):
        if self._driver == None:
            # caps = {}
            # caps["platformName"] = "Android"
            # caps["deviceName"] = "ed6c9b8e"
            # caps["appPackage"] = "com.tencent.wework"
            # caps["appActivity"] = ".launch.WwMainActivity"
            # caps['noReset'] = "true"
            # caps['skipServerInstallation'] = True
            # caps['skipDeviceInitialization'] = True
            desre_cap = {
                "deviceName": "ed6c9b8e",
                "platformName": "Android",
                "appPackage": "com.tencent.wework",
                "appActivity": ".launch.WwMainActivity",
                "noReset": True,
                "skipServerInstallation": True,
                "skipDeviceInitialization": True
            }
            _driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desre_cap)
        else:
            self._driver.launch_app()

        self._driver.implicitly_wait(10)

        return self

    def restart(self):
        pass

    def stop(self):
        pass

    def main(self) -> Main:
        return Main(self._driver)

结尾用例脚本

from app.page.app import App


class TestContact:
    def setup(self):
        self.app = App()
        self.main = self.app.start().main()

    def test_addcontact(self):
        invitpage = self.main.goto_addresslist().add_member(). \
            addmember_by_manul().input_name().set_gender() \
            .input_phonenum().click_save()

        assert '成功' in invitpage.get_toast()

pycharm报错信息

(venv) v_liuzhen01@B000000081810S testcase % pytest -vs test_scontact1.py
================================================================= test session starts ==================================================================
platform darwin -- Python 3.7.2rc1, pytest-5.4.2, py-1.8.1, pluggy-0.13.1 -- /Users/v_liuzhen01/PycharmProjects/webqiyeweixin/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/v_liuzhen01/PycharmProjects/webqiyeweixin/app/testcase
plugins: allure-pytest-2.8.16
collected 1 item                                                                                                                                       

test_scontact1.py::TestContact::test_addcontact ERROR

======================================================================== ERRORS ========================================================================
____________________________________________________ ERROR at setup of TestContact.test_addcontact _____________________________________________________

self = <app.testcase.test_scontact1.TestContact object at 0x7fe4bc79bf98>

    def setup(self):
        self.app = App()
>       self.main = self.app.start().main()

test_scontact1.py:7: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../page/app.py:27: in start
    _driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desre_cap)
../../venv/lib/python3.7/site-packages/appium/webdriver/webdriver.py:155: in __init__
    proxy
../../venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:157: in __init__
    self.start_session(capabilities, browser_profile)
../../venv/lib/python3.7/site-packages/appium/webdriver/webdriver.py:225: in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, parameters)
../../venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:321: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7fe4bc79bdd8>
response = {'status': 500, 'value': '{"value":{"error":"unknown error","message":"An unknown server-side error occurred while pro...lib/node_modules/appium/node_modules/_appium-base-driver@5.8.1@appium-base-driver/lib/protocol/protocol.js:392:37)"}}'}

    def check_response(self, response):
        """
        Checks that a JSON response from the WebDriver does not have an error.
    
        :Args:
         - response - The JSON response from the WebDriver server as a dictionary
           object.
    
        :Raises: If the response contains an error message.
        """
        status = response.get('status', None)
        if status is None or status == ErrorCode.SUCCESS:
            return
        value = None
        message = response.get("message", "")
        screen = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get('value', None)
            if value_json and isinstance(value_json, basestring):
                import json
                try:
                    value = json.loads(value_json)
                    if len(value.keys()) == 1:
                        value = value['value']
                    status = value.get('error', None)
                    if status is None:
                        status = value["status"]
                        message = value["value"]
                        if not isinstance(message, basestring):
                            value = message
                            message = message.get('message')
                    else:
                        message = value.get('message', None)
                except ValueError:
                    pass
    
        exception_class = ErrorInResponseException
        if status in ErrorCode.NO_SUCH_ELEMENT:
            exception_class = NoSuchElementException
        elif status in ErrorCode.NO_SUCH_FRAME:
            exception_class = NoSuchFrameException
        elif status in ErrorCode.NO_SUCH_WINDOW:
            exception_class = NoSuchWindowException
        elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
            exception_class = StaleElementReferenceException
        elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
            exception_class = ElementNotVisibleException
        elif status in ErrorCode.INVALID_ELEMENT_STATE:
            exception_class = InvalidElementStateException
        elif status in ErrorCode.INVALID_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
            exception_class = InvalidSelectorException
        elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
            exception_class = ElementNotSelectableException
        elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
            exception_class = ElementNotInteractableException
        elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
            exception_class = InvalidCookieDomainException
        elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
            exception_class = UnableToSetCookieException
        elif status in ErrorCode.TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.SCRIPT_TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.UNKNOWN_ERROR:
            exception_class = WebDriverException
        elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
            exception_class = UnexpectedAlertPresentException
        elif status in ErrorCode.NO_ALERT_OPEN:
            exception_class = NoAlertPresentException
        elif status in ErrorCode.IME_NOT_AVAILABLE:
            exception_class = ImeNotAvailableException
        elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
            exception_class = ImeActivationFailedException
        elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
            exception_class = MoveTargetOutOfBoundsException
        elif status in ErrorCode.JAVASCRIPT_ERROR:
            exception_class = JavascriptException
        elif status in ErrorCode.SESSION_NOT_CREATED:
            exception_class = SessionNotCreatedException
        elif status in ErrorCode.INVALID_ARGUMENT:
            exception_class = InvalidArgumentException
        elif status in ErrorCode.NO_SUCH_COOKIE:
            exception_class = NoSuchCookieException
        elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
            exception_class = ScreenshotException
        elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
            exception_class = ElementClickInterceptedException
        elif status in ErrorCode.INSECURE_CERTIFICATE:
            exception_class = InsecureCertificateException
        elif status in ErrorCode.INVALID_COORDINATES:
            exception_class = InvalidCoordinatesException
        elif status in ErrorCode.INVALID_SESSION_ID:
            exception_class = InvalidSessionIdException
        elif status in ErrorCode.UNKNOWN_METHOD:
            exception_class = UnknownMethodException
        else:
            exception_class = WebDriverException
        if value == '' or value is None:
            value = response['value']
        if isinstance(value, basestring):
            if exception_class == ErrorInResponseException:
                raise exception_class(response, value)
            raise exception_class(value)
        if message == "" and 'message' in value:
            message = value['message']
    
        screen = None
        if 'screen' in value:
            screen = value['screen']
    
        stacktrace = None
        if 'stackTrace' in value and value['stackTrace']:
            stacktrace = []
            try:
                for frame in value['stackTrace']:
                    line = self._value_or_default(frame, 'lineNumber', '')
                    file = self._value_or_default(frame, 'fileName', '<anonymous>')
                    if line:
                        file = "%s:%s" % (file, line)
                    meth = self._value_or_default(frame, 'methodName', '<anonymous>')
                    if 'className' in frame:
                        meth = "%s.%s" % (frame['className'], meth)
                    msg = "    at %s (%s)"
                    msg = msg % (meth, file)
                    stacktrace.append(msg)
            except TypeError:
                pass
        if exception_class == ErrorInResponseException:
            raise exception_class(response, message)
        elif exception_class == UnexpectedAlertPresentException:
            alert_text = None
            if 'data' in value:
                alert_text = value['data'].get('text')
            elif 'alert' in value:
                alert_text = value['alert'].get('text')
            raise exception_class(message, screen, stacktrace, alert_text)
>       raise exception_class(message, screen, stacktrace)
E       selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.tencent.wework' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e shell am start -W -n com.tencent.wework/.launch.WwMainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' exited with code 255'; Stderr: 'Security exception: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.wework/.launch.WwMainActivity } from null (pid=11741, uid=2000) not exported from uid 10211
E       
E       java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.wework/.launch.WwMainActivity } from null (pid=11741, uid=2000) not exported from uid 10211
E               at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1936)
E               at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:714)
E               at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:387)
E               at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1402)
E               at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1110)
E               at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:5791)
E               at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:415)
E               at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:144)
E               at android.os.ShellCommand.exec(ShellCommand.java:96)
E               at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:17691)
E               at android.os.Binder.shellCommand(Binder.java:595)
E               at android.os.Binder.onTransact(Binder.java:493)
E               at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4479)
E               at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3463)
E               at android.os.Binder.execTransact(Binder.java:708)'; Code: '255'

../../venv/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py:242: WebDriverException
=============================================================== short test summary info ================================================================
ERROR test_scontact1.py::TestContact::test_addcontact - selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred...
=================================================================== 1 error in 6.04s ===================================================================

appium 信息

[Appium] Welcome to Appium v1.16.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[debug] [HTTP] Request idempotency key: 2f727faa-6a67-4230-aedd-c4028d5a627e
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"firstMatch":[{"appium:deviceName":"ed6c9b8e","platformName":"Android","appium:appPackage":"com.tencent.wework","appium:appActivity":".launch.WwMainActivity","appium:noReset":true,"appium:skipServerInstallation":true,"appium:skipDeviceInitialization":true}]},"desiredCapabilities":{"deviceName":"ed6c9b8e","platformName":"Android","appPackage":"com.tencent.wework","appActivity":".launch.WwMainActivity","noReset":true,"skipServerInstallation":true,"skipDeviceInitialization":true}}
[debug] [W3C] Calling AppiumDriver.createSession() with args: [{"deviceName":"ed6c9b8e","platformName":"Android","appPackage":"com.tencent.wework","appActivity":".launch.WwMainActivity","noReset":true,"skipServerInstallation":true,"skipDeviceInitialization":true},null,{"firstMatch":[{"appium:deviceName":"ed6c9b8e","platformName":"Android","appium:appPackage":"com.tencent.wework","appium:appActivity":".launch.WwMainActivity","appium:noReset":true,"appium:skipServerInstallation":true,"appium:skipDeviceInitialization":true}]}]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1591149675502 (10:01:15 GMT+0800 (中国标准时间))
[Appium] 
[Appium] ======================================================================
[Appium]   DEPRECATION WARNING:
[Appium] 
[Appium]   The 'automationName' capability was not provided in the desired 
[Appium]   capabilities for this Android session
[Appium] 
[Appium]   Setting 'automationName=UiAutomator2' by default and using the 
[Appium]   UiAutomator2 Driver
[Appium] 
[Appium]   The next major version of Appium (2.x) will **require** the 
[Appium]   'automationName' capability to be set for all sessions on all 
[Appium]   platforms
[Appium] 
[Appium]   In previous versions (Appium <= 1.13.x), the default was 
[Appium]   'automationName=UiAutomator1'
[Appium] 
[Appium]   If you wish to use that automation instead of UiAutomator2, please 
[Appium]   add 'automationName=UiAutomator1' to your desired capabilities
[Appium] 
[Appium]   For more information about drivers, please visit 
[Appium]   http://appium.io/docs/en/about-appium/intro/ and explore the 
[Appium]   'Drivers' menu
[Appium] 
[Appium] ======================================================================
[Appium] 
[Appium] Appium v1.16.0 creating new AndroidUiautomator2Driver (v1.54.1) session
[debug] [BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[debug] [BaseDriver] Creating session with W3C capabilities: {
[debug] [BaseDriver]   "alwaysMatch": {
[debug] [BaseDriver]     "platformName": "Android",
[debug] [BaseDriver]     "appium:deviceName": "ed6c9b8e",
[debug] [BaseDriver]     "appium:appPackage": "com.tencent.wework",
[debug] [BaseDriver]     "appium:appActivity": ".launch.WwMainActivity",
[debug] [BaseDriver]     "appium:noReset": true,
[debug] [BaseDriver]     "appium:skipServerInstallation": true,
[debug] [BaseDriver]     "appium:skipDeviceInitialization": true
[debug] [BaseDriver]   },
[debug] [BaseDriver]   "firstMatch": [
[debug] [BaseDriver]     {}
[debug] [BaseDriver]   ]
[debug] [BaseDriver] }
[BaseDriver] Session created with session id: 6e8d162d-6b0d-4867-9fb3-edf8a70c849c
[UiAutomator2] Starting 'com.tencent.wework' directly on the device
[ADB] Found 2 'build-tools' folders under '/Applications/android-sdk-macosx' (newest first):
[ADB]     /Applications/android-sdk-macosx/build-tools/29.0.2
[ADB]     /Applications/android-sdk-macosx/build-tools/28.0.3
[ADB] Using 'adb' from '/Applications/android-sdk-macosx/platform-tools/adb'
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] Connected devices: [{"udid":"ed6c9b8e","state":"device"}]
[AndroidDriver] Using device: ed6c9b8e
[ADB] Using 'adb' from '/Applications/android-sdk-macosx/platform-tools/adb'
[debug] [ADB] Setting device id to ed6c9b8e
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 27
[debug] [ADB] Device API level: 27
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] 'skipDeviceInitialization' is set. Skipping device initialization.
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e shell appops set io.appium.settings android\:mock_location allow'
[debug] [Logcat] Starting logcat capture
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e forward tcp\:8200 tcp\:6790'
[UiAutomator2] 'skipServerInstallation' is set. Skipping UIAutomator2 server installation.
[debug] [UiAutomator2] No app capability. Assuming it is already on the device
[debug] [UiAutomator2] Performing shallow cleanup of automation leftovers
[debug] [UiAutomator2] No obsolete sessions have been detected (socket hang up)
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e shell am force-stop io.appium.uiautomator2.server.test'
[UiAutomator2] 'skipServerInstallation' is set. Attempting to use UIAutomator2 server from the device
[UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online...
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","ed6c9b8e","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] socket hang up
[debug] [WD Proxy] Error: socket hang up
[debug] [WD Proxy]     at connResetException (internal/errors.js:559:14)
[debug] [WD Proxy]     at Socket.socketOnEnd (_http_client.js:436:23)
[debug] [WD Proxy]     at Socket.emit (events.js:205:15)
[debug] [WD Proxy]     at endReadableNT (_stream_readable.js:1154:12)
[debug] [WD Proxy]     at processTicksAndRejections (internal/process/task_queues.js:84:9)
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] socket hang up
[debug] [WD Proxy] Error: socket hang up
[debug] [WD Proxy]     at connResetException (internal/errors.js:559:14)
[debug] [WD Proxy]     at Socket.socketOnEnd (_http_client.js:436:23)
[debug] [WD Proxy]     at Socket.emit (events.js:205:15)
[debug] [WD Proxy]     at endReadableNT (_stream_readable.js:1154:12)
[debug] [WD Proxy]     at processTicksAndRejections (internal/process/task_queues.js:84:9)
[debug] [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] socket hang up
[debug] [WD Proxy] Error: socket hang up
[debug] [WD Proxy]     at connResetException (internal/errors.js:559:14)
[debug] [WD Proxy]     at Socket.socketOnEnd (_http_client.js:436:23)
[debug] [WD Proxy]     at Socket.emit (events.js:205:15)
[debug] [WD Proxy]     at endReadableNT (_stream_readable.js:1154:12)
[debug] [WD Proxy]     at processTicksAndRejections (internal/process/task_queues.js:84:9)
[debug] [WD Proxy] Matched '/status' to command name 'getStatus'
[debug] [WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
[debug] [UiAutomator2] The initialization of the instrumentation process took 4217ms
[debug] [WD Proxy] Matched '/session' to command name 'createSession'
[debug] [WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8200/wd/hub/session] with body: {"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"ed6c9b8e","appPackage":"com.tencent.wework","appActivity":".launch.WwMainActivity","noReset":true,"skipServerInstallation":true,"skipDeviceInitialization":true},"platformName":"Android","deviceName":"ed6c9b8e","appPackage":"com.tencent.wework","appActivity":".launch.WwMainActivity","noReset":true,"skipServerInstallation":true,"skipDeviceInitialization":true,"deviceUDID":"ed6c9b8e"}],"alwaysMatch":{}}}
[debug] [WD Proxy] Got response with status 200: {"sessionId":"08cee231-423d-47e8-b0bf-dedff9fe500b","value":{"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"ed6c9b8e","appPackage":"com.tencent.wework","appActivity":".launch.WwMainActivity","noReset":true,"skipServerInstallation":true,"skipDeviceInitialization":true},"platformName":"Android","deviceName":"ed6c9b8e","appPackage":"com.tencent.wework","appActivity":".launch.WwMainActivity","noReset":true,"skipServerInstallation":true,"skipDeviceInitialization":true,"deviceUDID":"ed6c9b8e"}],"alwaysMatch":{}},"sessionId":"08cee231-423d-47e8-b0bf-dedff9fe500b"}}
[WD Proxy] Determined the downstream protocol as 'W3C'
[debug] [WD Proxy] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:8200/wd/hub/session/08cee231-423d-47e8-b0bf-dedff9fe500b/appium/device/info] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"08cee231-423d-47e8-b0bf-dedff9fe500b","value":{"androidId":"080a56cfc129fae9","apiVersion":"27","bluetooth":{"state":"OFF"},"brand":"vivo","carrierName":"","displayDensity":480,"locale":"zh_CN","manufacturer":"vivo","model":"vivo Y85","networks":[{"capabilities":{"SSID":null,"linkDownBandwidthKbps":1048576,"linkUpstreamBandwidthKbps":1048576,"networkCapabilities":"NET_CAPABILITY_NOT_METERED,NET_CAPABILITY_INTERNET,NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_NOT_ROAMING","signalStrength":-56,"transportTypes":"TRANSPORT_WIFI"},"detailedState":"CONNECTED","extraInfo":"\"Baidu_WiFi\"","isAvailable":true,"isConnected":true,"isFailover":false,"isRoaming":false,"state":"CONNECTED","subtype":0,"subtypeName":"","type":1,"typeName":"WIFI"}],"platformVersion":"8.1.0","realDisplaySize":"1080x2280","timeZone":"Asia/Shanghai"}}
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] Starting 'com.tencent.wework/.launch.WwMainActivity and waiting for 'com.tencent.wework/.launch.WwMainActivity'
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e shell am start -W -n com.tencent.wework/.launch.WwMainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[debug] [WD Proxy] Matched '/' to command name 'deleteSession'
[debug] [WD Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8200/wd/hub/session/08cee231-423d-47e8-b0bf-dedff9fe500b] with no body
[debug] [WD Proxy] Got response with status 200: {"sessionId":"08cee231-423d-47e8-b0bf-dedff9fe500b","value":null}
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e shell am force-stop com.tencent.wework'
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Removing forwarded port socket connection: 8200 
[debug] [ADB] Running '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e forward --remove tcp\:8200'
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1591149681172 (10:01:21 GMT+0800 (中国标准时间))
[debug] [W3C] Encountered internal error running command: Error: Cannot start the 'com.tencent.wework' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command '/Applications/android-sdk-macosx/platform-tools/adb -P 5037 -s ed6c9b8e shell am start -W -n com.tencent.wework/.launch.WwMainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' exited with code 255'; Stderr: 'Security exception: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.wework/.launch.WwMainActivity } from null (pid=11741, uid=2000) not exported from uid 10211
[debug] [W3C] 
[debug] [W3C] java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.wework/.launch.WwMainActivity } from null (pid=11741, uid=2000) not exported from uid 10211
[debug] [W3C] 	at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1936)
[debug] [W3C] 	at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:714)
[debug] [W3C] 	at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:387)
[debug] [W3C] 	at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1402)
[debug] [W3C] 	at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1110)
[debug] [W3C] 	at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:5791)
[debug] [W3C] 	at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:415)
[debug] [W3C] 	at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:144)
[debug] [W3C] 	at android.os.ShellCommand.exec(ShellCommand.java:96)
[debug] [W3C] 	at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:17691)
[debug] [W3C] 	at android.os.Binder.shellCommand(Binder.java:595)
[debug] [W3C] 	at android.os.Binder.onTransact(Binder.java:493)
[debug] [W3C] 	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4479)
[debug] [W3C] 	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3463)
[debug] [W3C] 	at android.os.Binder.execTransact(Binder.java:708)'; Code: '255'
[debug] [W3C]     at ADB.startApp (/usr/local/lib/node_modules/appium/node_modules/_appium-adb@8.0.0@appium-adb/lib/tools/apk-utils.js:177:11)
[debug] [W3C] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 5740 ms - 5181
[HTTP] 
[debug] [Instrumentation] .
[debug] [Instrumentation] Time: 3.117
[debug] [Instrumentation] 
[debug] [Instrumentation] OK (1 test)
[debug] [Instrumentation] The process has exited with code 0

这句话报错显示启动微信无法启动,你用真机运行这个命令看看是那里出的问题,还有就是慢慢学会看appium的log

试过了也是报错和pycharm报错是相同的

adb -P 5037 -s ed6c9b8e shell am start -W -n com.tencent.wework/.launch.WwMainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000
Stopping: com.tencent.wework
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.wework/.launch.WwMainActivity }
Security exception: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.wework/.launch.WwMainActivity } from null (pid=11931, uid=2000) not exported from uid 10211

java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tencent.wework/.launch.WwMainActivity } from null (pid=11931, uid=2000) not exported from uid 10211
	at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1936)
	at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:714)
	at com.android.server.am.ActivityStarter.startActivityLocked(ActivityStarter.java:387)
	at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1402)
	at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1110)
	at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:5791)
	at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:415)
	at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:144)
	at android.os.ShellCommand.exec(ShellCommand.java:96)
	at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:17691)
	at android.os.Binder.shellCommand(Binder.java:595)
	at android.os.Binder.onTransact(Binder.java:493)
	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:4479)
	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3463)
	at android.os.Binder.execTransact(Binder.java:708)

你不要第一次在真机上跑就跳过初始化这些。。你机器上还没装好测试需要用的工具呢~~

从一个企业微信自动打卡的项目里找的企业微信入口,试了一下我这可以启动 原帖地址

"appPackage": "com.tencent.wework",
"appActivity": "com.tencent.wework.launch.LaunchSplashActivity"

查看包名activity使用aapt方法:

aapt配置环境变量,aapt位置:android-sdk-macosx/build-tools/29.0.2/aapt
aapt命令:aapt dump badging [apk的位置]
如下结果:
包名:package: name=‘com.tencent.wework’
启动的activity:launchable-activity: name=‘com.tencent.wework.launch.LaunchSplashActivity’

package: name='com.tencent.wework' versionCode='12623' versionName='3.0.21' platformBuildVersionName='3.0.21' compileSdkVersion='28' compileSdkVersionCodename='9'
sdkVersion:'21'
targetSdkVersion:'28'
uses-permission: name='com.huawei.android.launcher.permission.READ_SETTINGS'
uses-permission: name='com.huawei.android.launcher.permission.WRITE_SETTINGS'
uses-permission: name='com.huawei.android.launcher.permission.CHANGE_BADGE'
uses-permission: name='com.huawei.permission.sec.SDK_LAUNCHER'
uses-permission: name='android.permission.REQUEST_INSTALL_PACKAGES'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.RECORD_AUDIO'
uses-permission: name='android.permission.MODIFY_AUDIO_SETTINGS'
uses-permission: name='android.permission.BLUETOOTH'
uses-permission: name='android.permission.CHANGE_WIFI_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.CHANGE_NETWORK_STATE'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.SYSTEM_ALERT_WINDOW'
uses-permission: name='android.permission.GET_TASKS'
uses-permission: name='android.permission.REORDER_TASKS'
uses-permission: name='android.permission.RECEIVE_BOOT_COMPLETED'
uses-permission: name='android.permission.DISABLE_KEYGUARD'
uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.ACCESS_LOCATION_EXTRA_COMMANDS'
uses-permission: name='android.permission.CAMERA'
uses-permission: name='android.permission.FLASHLIGHT'
uses-permission: name='android.permission.BROADCAST_STICKY'
uses-permission: name='android.permission.KILL_BACKGROUND_PROCESSES'
uses-permission: name='android.permission.CHANGE_WIFI_MULTICAST_STATE'
uses-permission: name='com.android.launcher.permission.INSTALL_SHORTCUT'
uses-permission: name='com.android.launcher.permission.UNINSTALL_SHORTCUT'
uses-permission: name='com.android.launcher.permission.READ_SETTINGS'
uses-permission: name='android.permission.CALL_PHONE'
uses-permission: name='android.permission.READ_CONTACTS'
uses-permission: name='android.permission.WRITE_CONTACTS'
uses-permission: name='com.huawei.pushagent.permission.RICHMEDIA_PROVIDER'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.ALARM_LOCK'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.RECEIVE_USER_PRESENT'
uses-permission: name='android.permission.RECEIVE_BOOT_COMPLETED'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='android.permission.RESTART_PACKAGES'
uses-permission: name='android.permission.BROADCAST_STICKY'
uses-permission: name='android.permission.KILL_BACKGROUND_PROCESSES'
uses-permission: name='android.permission.BLUETOOTH'
uses-permission: name='android.permission.READ_SYNC_SETTINGS'
uses-permission: name='android.permission.WRITE_SYNC_SETTINGS'
uses-permission: name='android.permission.AUTHENTICATE_ACCOUNTS'
uses-permission: name='android.permission.READ_APP_BADGE'
uses-permission: name='com.htc.launcher.permission.UPDATE_SHORTCUT'
uses-permission: name='com.sonyericsson.home.permission.BROADCAST_BADGE'
uses-permission: name='android.permission.USE_FULL_SCREEN_INTENT'
uses-permission: name='android.permission.FOREGROUND_SERVICE'
uses-permission: name='android.permission.NFC'
uses-permission: name='android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS'
uses-permission: name='android.permission.READ_CALENDAR'
uses-permission: name='android.permission.WRITE_CALENDAR'
uses-permission: name='com.huawei.systemmanager.permission.ACCESS_INTERFACE'
uses-permission: name='com.tencent.wework.permission.MIPUSH_RECEIVE'
uses-permission: name='com.coloros.mcs.permission.RECIEVE_MCS_MESSAGE'
uses-permission: name='com.asus.msa.SupplementaryDID.ACCESS'
uses-permission: name='android.permission.USE_BIOMETRIC'
uses-permission: name='android.permission.USE_FINGERPRINT'
uses-permission: name='android.permission.BLUETOOTH_ADMIN'
uses-permission: name='com.bbk.launcher2.permission.READ_SETTINGS'
uses-permission: name='com.tencent.wework.mm.WAID_PROVIDER_WRITE'
uses-permission: name='com.android.vending.CHECK_LICENSE'
uses-permission: name='android.permission.WRITE_SETTINGS'
uses-permission: name='android.permission.ACCESS_NOTIFICATION_POLICY'
uses-permission: name='android.permission.READ_LOGS'
uses-permission: name='com.soter.permission.ACCESS_SOTER_KEYSTORE'
uses-permission: name='android.permission.USE_FACERECOGNITION'
uses-permission: name='com.tencent.wework.permission.PROCESS_PUSH_MSG'
uses-permission: name='com.tencent.wework.permission.PUSH_PROVIDER'
uses-permission: name='com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA'
application-label:'WeChat Work'
application-label-en:'WeChat Work'
application-label-zh:'企业微信'
application-label-zh-CN:'企业微信'
application-label-zh-TW:'WeChat Work'
application-icon-120:'r/a9/ww_ic_launcher.png'
application-icon-160:'r/a9/ww_ic_launcher.png'
application-icon-240:'r/a9/ww_ic_launcher.png'
application-icon-320:'r/c/ww_ic_launcher.png'
application-icon-480:'r/c/ww_ic_launcher.png'
application-icon-640:'r/a2/ww_ic_launcher.png'
application-icon-65534:'r/a9/ww_ic_launcher.png'
application-icon-65535:'r/a2/ww_ic_launcher.png'
application: label='WeChat Work' icon='r/a9/ww_ic_launcher.png'
launchable-activity: name='com.tencent.wework.launch.LaunchSplashActivity'  label='WeChat Work' icon=''
uses-library-not-required:'org.apache.http.legacy'
uses-library-not-required:'android.test.base'
uses-library-not-required:'android.test.runner'
uses-library-not-required:'com.google.android.maps'
uses-library-not-required:'com.here.android'
aapt(43774,0x117a5edc0) malloc: *** error for object 0xa00007fe8daf0491: pointer being freed was not allocated
aapt(43774,0x117a5edc0) malloc: *** set a breakpoint in malloc_error_break to debug

关闭