Appium inspector resets permissions for app on Android - appium

When I start Appium inspector on Windows 10 for Android 10, my App shuts down and restarts with reset permissions, that is it asks me if the app needs access to camera, video, location, etc though these permissions were already given. It also removes the license file from my app. Any idea why this happens?
Following are my Desired capabilities:
{
"platformName": "Android",
"platformVersion": "10.0",
"deviceName": "R52N20ALVDN",
"udid": "R52N20ALVDN",
"appPackage": "Nap.CP.Android",
"automationName": "uiautomator2",
"appActivity": "crc6429e3927486beccbc.ActivityLicenseBrowse"
}
The uiautomatorviewer works fine. I tried changing the activity from:
"appActivity": "crc6429e3927486beccbc.ActivityLicenseBrowse"
To:
"appActivity": "crc6429e3927486beccbc.ActivityLogin"
And got the following error:
Error
An unknown server-side error occurred while processing the command. Original error: Cannot start the 'Nap.CP.Android' 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 'C:\Users\skhandekar\AppData\Local\Android\Sdk\platform-tools\adb.exe
-P 5037 -s R52N20ALVDN shell am start -W -n Nap.CP.Android/crc6429e3927486beccbc.ActivityLogin -S' exited with code 255'; Stderr: 'Security exception: Permission Denial: starting Intent { flg=0x10000000 cmp=Nap.CP.Android/crc6429e3927486beccbc.ActivityLogin } from null (pid=31202, uid=2000) not exported from uid 10286 java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=Nap.CP.Android/crc6429e3927486beccbc.ActivityLogin } from null (pid=31202, uid=2000) not exported from uid 10286 at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1447) at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:978) at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:732) at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:2072) at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:646) at com.android.server.wm.ActivityTaskManagerService.startActivityAndWait(ActivityTaskManagerService.java:1893) at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:4269) at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:513) at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:172) at android.os.ShellCommand.exec(ShellCommand.java:104) at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:12424) at android.os.Binder.shellCommand(Binder.java:916) at android.os.Binder.onTransact(Binder.java:790) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:5475) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3426) at android.os.Binder.execTransactInternal(Binder.java:1056) at android.os.Binder.execTransact(Binder.java:1029)'; Code: '255'
And it again resets the permissions as before in addition to giving above error.
Inspector was working fine when I tried it at my workplace but failure showed up when I tried the same from home, though other than the network ie wi-fi at home, nothing has changed. The Desired capabilities were also the same.

You can use this in your capabilities to allow permissions at app start :
autoGrantPermissions:true
noReset:False
It will allow all permission to the app and will not reset the app at startup.

Related

I need to use Appium 2 for CodeceptJS mobile tests

Because latest iOS is making problems with Appium 1.x, Appium team is no longer supporting it,
and Appium 2 is working ok - I need to use v2...
CodeceptJS 3.3.x is using Appium 1.x now and because of the '/wd/path' used by default in CodeceptJS Appium helper, I can't set it to use Appium 2.
When starting a test, CodeceptJS fails with:
Error: Failed to create session.
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
Please make sure Selenium Server is running and accessible
Error: Can't connect to WebDriver.
Error: Failed to create session.
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
Please make sure Selenium Server is running and accessible
And Appium 2 fails with:
[debug] [HTTP] No route found for /wd/hub/session
[HTTP] <-- POST /wd/hub/session 404 1 ms - 211
Is there a way to change the default '/wd/path' to just '/' ?
Or is there another helper or something for Appium 2?
Part of the codecept.config.js file:
Appium: {
host: process.env.CLOUD_HOST || 'localhost',
port: parseInt(process.env.CLOUD_PORT) || 4723,
app: (PLATFORM_NAME === 'iOS') ? APP_PATH_IOS || 'com.mobile.beta' : APP_PATH_ANDROID,
desiredCapabilities: {
platformName: process.env.PLATFORM_NAME || 'iOS',
platformVersion: process.env.PLATFORM_VERSION || '16.0',
automationName: process.env.AUTOMATION_NAME || 'xcuitest',
deviceName: process.env.DEVICE_NAME || 'iPhone Xs',
appPackage: process.env.APP_PACKAGE,
appActivity: process.env.APP_ACTIVITY,
xcodeOrgId: process.env.XCODE_ORG_ID,
// udid: process.env.UDID, // used only for real iOS device
},
},
=========================================
UPDATE:
I started Appium with --base-path /wd/hub (appium --base-path /wd/hub) but now another error appears:
Error: Can't connect to WebDriver.
Error: Failed to create session.
All non-standard capabilities should have a vendor prefix. The following capabilities did not have one: platformVersion,automationName,deviceName,appPackage,appActivity,xcodeOrgId,app
Please make sure Selenium Server is running and accessible
I tried updating the capabilities in codecept.conf.js with appium: prefix, but either I do it wrong or it doesn't work:
The Update:
Appium: {
host: process.env.CLOUD_HOST || 'localhost',
port: parseInt(process.env.CLOUD_PORT) || 4723,
app: (PLATFORM_NAME === 'iOS') ? APP_PATH_IOS || 'com.mobile.beta' : APP_PATH_ANDROID,
desiredCapabilities: {
'appium:platformName': process.env.PLATFORM_NAME || 'iOS',
'appium:platformVersion': process.env.PLATFORM_VERSION || '16.0',
'appium:automationName': process.env.AUTOMATION_NAME || 'xcuitest',
'appium:deviceName': process.env.DEVICE_NAME || 'iPhone Xs',
'appium:appPackage': process.env.APP_PACKAGE, // not needed for iOS
'appium:appActivity': process.env.APP_ACTIVITY, // not needed for iOS
'xcodeOrgId': process.env.XCODE_ORG_ID, // not needed for Android
udid: process.env.UDID, // used only for real iOS device testing
},
},
Error:
Error: Can't connect to WebDriver.
Error: Invalid or unsupported WebDriver capabilities found ("platformVersion", "deviceName", "appPackage", "appActivity", "xcodeOrgId", "app", "tunnelIdentifier"). Ensure to only use valid W3C WebDriver capabilities (see https://w3c.github.io/webdriver/#capabilities).If you run your tests on a remote vendor, like Sauce Labs or BrowserStack, make sure that you put them into vendor specific capabilities, e.g. "sauce:options" or "bstack:options". Please reach out to to your vendor support team if you have further questions.
Please make sure Selenium Server is running and accessible
Error#2:
Error: Can't connect to WebDriver.
Error: Invalid or unsupported WebDriver capabilities found ("deviceName", "app", "tunnelIdentifier"). Ensure to only use valid W3C WebDriver capabilities (see https://w3c.github.io/webdriver/#capabilities).If you run your tests on a remote vendor, like Sauce Labs or BrowserStack, make sure that you put them into vendor specific capabilities, e.g. "sauce:options" or "bstack:options". Please reach out to to your vendor support team if you have further questions.
Please make sure Selenium Server is running and accessible
If you are starting Appium server using the CLI you can use something like appium -p 4726 --base-path /wd/hub which will make it accept requests on the old endpoint
Update:
With Appium 2.0, the Appium server will enforce strict compability with the W3C WebDriver specification when it comes to Capabilities. They can be found here. Anything else that you provide for Appium should have the appium: prefix (like appium:platformVersion, appium:appPackage and so on)
This is most probably a problem with the CodeceptJS's Appium helper and needs to be updated to follow the Appium's more strict compability with the W3C WebDriver specification.
The update needs a support for prefixes like:
...
appium:platformName: 'iOS'
appium:automationName: 'xcuitest'
...
or
...
browserstack:platformName: 'Android'
saucelabs:automationName: 'uiautomator2'
...
for now, we can't configure variables with prefixes.
There's also no way I know of, to contact the CodeceptJS maintainers for making this update.

Xcode cannot connect to wkwebbview process

I am debugging a cordova app and suspecting a memory issue, using too much when loading images for upload.
I can connect the debugger to the app and watch the disk I/O as the large images are loaded. The memory footprint for the app stays the same as expected, see below.
The images should reside in the wkwebview in the app, and that should be running in a separate com.apple.WebKit.WebContent process. I cannot connect to that process from the Xcode debugger, I get the following error
Could not attach to pid : “32335”
Domain: IDEDebugSessionErrorDomain
Code: 3
Failure Reason: attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries when the attached failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)
In Console.app, debugserver reports:
1 +0.000000 sec [7edb/0103]: error: ::task_for_pid ( target_tport = 0x0203, pid = 32335, &task ) => err = 0x00000005 ((os/kern) failure) err = ::task_for_pid ( target_tport = 0x0203, pid = 32335, &task ) => err = 0x00000005 ((os/kern) failure) (0x00000005)
leading to https://developer.apple.com/forums/thread/694700
I have tried the suggestions in the link to no avail.
sudo DevToolsSecurity -enable
deleting the cerificates in ~/Library/MobileDevice/Provisioning\ Profiles (new ones are generated automatically)
my build.json contains the suggested settings:
"ios": {
"debug": {
"codeSignIdentity": "iPhone Developer",
"developmentTeam": "P9Q2VE5DWW",
"packageType": "development",
"automaticProvisioning": true,
"buildFlag": [
"EMBEDDED_CONTENT_CONTAINS_SWIFT=YES",
"DEPLOYMENT_POSTPROCESSING=NO",
"CODE_SIGN_INJECT_BASE_ENTITLEMENTS=YES",
"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES=NO",
"LD_RUNPATH_SEARCH_PATHS = \"#executable_path/Frameworks\""
]
},
Is there anything else I can try, and is it even possible to connect to the separate com.apple.WebKit.WebContent process?
Debugging on macOS and other Darwin systems is on an opt-in basis. If an app or helper tool does not choose to be debuggable, then you can't debug it, and you get the error that you have shown. This is for security reasons, and all the system binaries on macOS mark themselves as non-debuggable.
This access is controlled by "SIP" - System Integrity Protection, so you will need to defang that to some extent to debug system processes. This thread discusses how to disable just the debugging protections:
https://discussions.apple.com/thread/251326883

The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed

Now, I am trying to set selenium on Ruby and I want to change it from headless mode to normal mode but I don't know how to do it.
I thought that I just should remove add_argument but it didn't work.
options = Selenium::WebDriver::Chrome::Options.new
# options.add_argument('--headless')
# options.add_argument('--no-sandbox')
#driver = driver || Selenium::WebDriver.for(:chrome, options: options)
#driver.get("https://test.com")
The error says
Selenium::WebDriver::Error::UnknownError (unknown error: Chrome failed to start: exited abnormally.)
(unknown error: DevToolsActivePort file doesn't exist)
The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.
Is there any setting that I am missing ?
Please kindly give me any advice.
Thank you

intermittently occuring appium unknown server-side error

I seem to get this issue intermittently. no error if i were to un plug and replug the devices and re-excuite the test, however this is only temperory fix till the time it shows up again.
i have 2 instances of appium server for 2 devices-
server1
Host-0.0.0.0
server port-5050
Bootstrap port- 4734
allow session overrides- ticked
server2
Host-0.0.0.0
server port-4723
Bootstrap port- 4724
allow session overrides- ticked
appium version- 1.15.1
List of devices attached-
52002dd24392b5a1 device
5200472dec01a4a9 device
error on appium server console-
W3C] Encountered internal error running command: Error: Cannot start the 'com.XYZ.XYZ' 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 ''C:\\Users\\XYZ\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' -P 5037 -s 5200472dec01a4a9 shell am start -W -n com.XYZ.XYZ/host.exp.exponent.LauncherActivity -S' timed out after 120000ms'. Try to increase the 120000ms adb execution timeout represented by 'adbExecTimeout' capability
[W3C] at ADB.startApp (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:153:11)
[HTTP] <-- POST /wd/hub/session 500 132866 ms - 1782
[HTTP]
[Instrumentation] .
[Instrumentation] Time: 123.085
[Instrumentation]
[Instrumentation] OK (1 test)
[Instrumentation] The process has exited with code 0
error on IDE-
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.XYZ.XYZ' 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 ''C:\\Users\\XYZ\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' -P 5037 -s 5200472dec01a4a9 shell am start -W -n com.XYZ.XYZ/host.exp.exponent.LauncherActivity -S' timed out after 120000ms'. Try to increase the 120000ms adb execution timeout represented by 'adbExecTimeout' capability
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.XYZ.XYZ' 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 ''C:\\Users\\XYZ\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe' -P 5037 -s 5200472dec01a4a9 shell am start -W -n com.XYZ.XYZ/host.exp.exponent.LauncherActivity -S' timed out after 120000ms'. Try to increase the 120000ms adb execution timeout represented by 'adbExecTimeout' capability
desired capabilities for device1-
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Tab");
capabilities.setCapability("platformVersion", "8.0.0");
capabilities.setCapability("platformName", "ANDROID");
capabilities.setCapability("udid", "5200472dec01a4a9");
capabilities.setCapability("noReset", "true");
capabilities.setCapability("appPackage", "com.xyz.xyz");
capabilities.setCapability("appActivity", "host.exp.exponent.LauncherActivity");
capabilities.setCapability("adbExecTimeout", 120000);
capabilities.setCapability("newCommandTimeout", 3000);
capabilities.setCapability("noSign", "true");
URL mobileURL = new URL("http://0.0.0.0:5050/wd/hub");
mobileParent = new AndroidDriver(mobileURL, capabilities);
mobile capabilities for device2-
capabilities.setCapability("deviceName", "Tab");
capabilities.setCapability("platformVersion", "8.0.0");
capabilities.setCapability("platformName", "ANDROID");
capabilities.setCapability("udid", "52002dd24392b5a1");
capabilities.setCapability("noReset", "true");
capabilities.setCapability("appPackage", "com.coachhire.kura");
capabilities.setCapability("appActivity", "host.exp.exponent.LauncherActivity");
capabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);
capabilities.setCapability("adbExecTimeout", 120000);
capabilities.setCapability("newCommandTimeout", 3000);
capabilities.setCapability("noSign", "true");
URL mobileURL = new URL("http://0.0.0.0:4723/wd/hub");
mobileDriver = new AndroidDriver(mobileURL, capabilities);
any help greatly appretiated!
Looking at the details you have provided, there should not be any errors. It should work fine.
Unknown error usually accrues when Appium not able to figure out the list of capabilities provided for the run. I would suggest double check appPackage and appActivity details are right.
Also, try to run tests on one devices and see any errors. see the consistency of test run. if not errors than you can add one more device and see how it goes.
Add below in the capabilities,
"automationName": "UiAutomator2"
If you are running test on local machine use http://127.0.0.1:<Port>/wd/hubinstead 0.0.0.0
If you are running tests remotely make sure in above, local IP 127.0.0.0 replaced with the machine IP where Appium server is running.
As you are running Android devices only, I hope prerequisites softwares are installed as per Android test setup.
For mac device setup, follow steps here - https://www.swtestacademy.com/how-to-install-appium-on-mac/
Try below steps,
Check you can install the app manually by running below command.
adb -P <port> -s <device id > shell pm install -t -g <apk path>
If this could work, it indicates that there are no issues with the device. Else, you should reset the device and re test it.
Check Appium server is running with no issues. and access this link and see you get 200 response on appium server console.
http://<appium server ip>:4723/wd/hub/sessions
If you see an error there, it indicates that there is an issue with Appium. Un-install and install stable version of Appium and re test.
You should know that sometimes Node.js could not talk to 127.0.0.1:4723, So use 0.0.0.0:4723 instead and visa versa. Remember to change this in both code (DesiredCapabilities) and appium setting.
Try "udid" parametre is required for desired capabilities -
Example, caps.setCapability("udid", "ce0217124184c72505"); //DeviceId from "adb devices" command

Composer rest server can't connect to ca.org1.example.com

I followed this tutorial to setup myorg/composer-rest-server and everything was working fine till I import card but when I make a GET request to /api/system/ping it returns 500 Error:
{"error":{"statusCode":500,"name":"Error","message":"Error trying login and get user Context. Error: Error trying to enroll user or load channel configuration. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]","stack":"Error: Error trying login and get user Context. Error: Error trying to enroll user or load channel configuration. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]\n at client.getUserContext.then.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:393:34)\n at <anonymous>\n at process._tickDomainCallback (internal/process/next_tick.js:228:7)"}}
So I checked the logs for rest container, it can't seem to find 127.0.0.1:7054. Here is the error log.
Unhandled error for request GET /api/system/ping: Error: Error trying login and get user Context. Error: Error trying to enroll user or load channel configuration. Error: Calling enrollment endpoint failed with error [Error: connect ECONNREFUSED 127.0.0.1:7054]
at client.getUserContext.then.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:393:34)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)
So I checked the logs for the container ca.org1.example.com, and it is listening to port 7054
2018/04/01 09:57:25 [DEBUG] CA initialization successful
2018/04/01 09:57:25 [INFO] Home directory for default CA: /etc/hyperledger/fabric-ca-server
2018/04/01 09:57:25 [DEBUG] 1 CA instance(s) running on server
2018/04/01 09:57:25 [INFO] Listening on http://0.0.0.0:7054
I think i need to change 127.0.0.1 to 0.0.0.0 but not sure how to do it the right way. Could also be a firewall issue?
Here's my .composer/cards/restadmin#myserver/connection.json
{"name":"hlfv1","x-type":"hlfv1","x-commitTimeout":300,"version":"1.0.0","client":{"organization":"Org1","connection":{"timeout":{"peer":{"endorser":"300","eventHub":"300","eventReg":"300"},"orderer":"300"}}},"channels":{"composerchannel":{"orderers":["orderer.example.com"],"peers":{"peer0.org1.example.com":{}}}},"organizations":{"Org1":{"mspid":"Org1MSP","peers":["peer0.org1.example.com"],"certificateAuthorities":["ca.org1.example.com"]}},"orderers":{"orderer.example.com":{"url":"grpc://orderer.example.com:7050"}},"peers":{"peer0.org1.example.com":{"url":"grpc://peer0.org1.example.com:7051","eventUrl":"grpc://peer0.org1.example.com:7053"}},"certificateAuthorities":{"ca.org1.example.com":{"url":"http://ca.org1.example.com:7054","caName":"ca.org1.example.com"}}}
I'm using AWS EC2
OS: Ubuntu 16.04.3 LTS,
Docker: 17.12.0-ce,
Composer: v0.19.0
Fabric: v1.1
Which card have you imported? If it is the restadmin card, I think you may have imported a Card containing an expired One-Time secret. After the rest admin card was used to start the REST server (in the container) the secret was replaced with certificates - so if you export the restadmin card again with a different name composer card export -c restadmin#trade-network -f restadmin-cert.card you will see that it is a larger file because of the certificates. You should be able to import and use this new .card file.
(If you were using a different card e.g. jdoe - did you run the sed command for this card to correct the addresses?)

Resources