Appium: Starting an android app using an intent? - webdriver

Does anyone know if it's possible to start an android app with appium using just the intentAction and URL as optionalIntentArguments? This is to test against an expo app in local dev mode running in the Expo client app; I am basically copying what the expo-cli does, but in appium/webdriver tests.
I can get it to work via adb directly (e.g. adb shell am start -a "android.intent.action.VIEW" -d "exp://127.0.0.1:19000" but I have to leave out the appPackage and appActivity, which are (I think!) mandatory with appium desktop app at least. I actually hacked in changing appium's validation to not require an appPackage and appActivity when the intent is provided, and then leave that out of the subsequent adb command, which works, but was wondering if there was an intended/official way to do it? I'm happy to PR what I have if not, but figured someone else might be trying to do the same thing.
(If anyone knows how to launch dev expo for iOS I am also currently trying to work that out!)
Thanks!

Related

Ionic DevApp debugging in chrome console?

I am using ionic DevApp (ionic v4) for the first time, i’m trying to display a json object using the function console.log(). when i run the application in ionic DevApp i see the object only displays in the commande line console (cli) not in the remote devices from google.
Please, is there anyone of you who knows how to solve this issue.
Thank you in advance.
As far as I know, this is not possible. If you want to see the console output, add the parameter -c to the ionic serve:
ionic s -c --devapp
this will output the console in the terminal, but you will not have it as pretty as in Chrome.
Anyway, in my experience, DevApp is not a good solution whatsoever. On one hand, you have the console issue, on the other, plugins will not work. There is no significant pro compared to see your app in the browser directly.
I think you would rather use the --livereload modifier when running the app. This will make the app to quick recompile and reload every time you save some change (just like in ionic serve). You will get the Chrome inspector, your plugins will work normally and your app will quickly recompile and reload on any change save. Just run this:
ionic cordova run android --device --livereload

Root on Android Things userdebug builds

In my Android Things app, I need to use su from runtime. However, Android Things system is built as userdebug build, so I can only access it from adb. I tried to both replace su binaries with no luck. I tried to disable ro.secure by unpacking and repacking boot.img, however flashed system still returns getprop ro.secure 0. How can I achieve root in my Android Things device?
I had these scripts working on a quite early preview version, maybe 0.1 or 0.2. https://github.com/fmatosqg/androidthings_ndk/tree/master/app/src/main/script
Although I had to run it manually, there should be a place where I can add this script so it runs every boot, just like linux's /etc/rc.d
I don't remember how I got the script to work, but the idea is that one script simply exists to launch the other running as superuser, similar to what you would expect with sudo <insert command here>

PARSE4CN1 Android push don't work

I'm having some trouble integrating my app with the parse4cn1 lib. I followed the tutorial published on this link and the app registers normally on the Parse Server as an installation but when I try to send a push to Android devices they simply aren't being sent.
I haven't tried on iOS yet, since I figured I'd start with Android, and I'm working with a new GUI Builder app if maybe that affects something for any reason.
Thanks for your help.
Ok, I have found the problem, it was related to parse not the parse4cn1 lib. I'm actually new with parse and backend in general, I wasn't aware I had to run the pm2 restart command after modifying the cloud code.
It's working now, thanks!

Can you use Protractor and Appium together to test hybrid apps?

Here is my scenario. I have a website which is built on top of Angular JS. I am able to automate the website using protractor. However there are certain actions which when performed on website are reflected in Android and IOS devices.
Here's what I want to achieve.
Run my tests on website like I normally do but I want to fire commands to test the android and ios app also
/*
For eg:
1. Change password on website using protractor
2. Launch android app and check if the password has been changed
3. Switch back to protractor tests for website
*/
it('Change password and check on IOS and Android device' , function()
{
changePasswordOnWeb();
OpenMobileAppInDeviceUsingAppium();
checNewkPasswordOnMobileApp();
});
Is it possible? If it is can you point me to any of the tutorials?
To answer your question, yes you can integrate protractor and appium. Though as of now Protractor doesn't support appium officially, you can still make it possible with the below details. There is a help file that is available in Protractor docs. All you need to do is update your conf.js file to include the appium configurations and remember to start your appium server before you run the test script. Take care of below points -
Start your avd
Install the .apk file in your avd that you will be invoking through appium
Start the appium server using command - appium &
Update your protractor conf.js file to include appium android/chrome configurations. More details about configurations can be found in the below link.
Here's the link to more info on this - Protractor-Appium Setup . Hope this helps
It seems like you can use it
to test hybrid apps
This readme will help you to setup Protractor with Appium - Android/Chrome and Android/Safari. Here is video how-to. Maybe you should consider the SauceLabs option too.I think you can request iOS and Android devices by specifying the platform in the capabilities section of the config.
If you don't want to use SauceLabs you can look at using Selenium's Grid functionality. You can get Selenium drivers for iOS and Android and have them connect to a centralized Selenium server that your Protractor scenarios are ran against, you just change the seleniumAddress in your config file to point to the centralized server.

Way to debug Meteor code? [duplicate]

Does anyone know a good method to debug server side code?
I tried enable Node.js debug then use node-inspector but it does not show any of my code.
I end up using console.log but this is very inefficient.
Update: I found the following procedure works on my Linux machine:
When you run Meteor, it will spawn two processes
process1: /usr/lib/meteor/bin/node /usr/lib/meteor/app/meteor/meteor.js
process2: /usr/lib/meteor/bin/node /home/paul/codes/bbtest_code/bbtest02/.meteor/local/build/main.js --keepalive
You need to send kill -s USR1 on process2
Run node-inspector and you can see your server code
On my first try, I modify the last line on meteor startup script in /usr/lib/meteor/bin/meteor to
exec "$DEV_BUNDLE/bin/node" $NODE_DEBUG "$METEOR" "$#"
and run NODE_DEBUG=--debug meteor on command prompt. This only put --debug flag on process1 so I only see meteor files on node-inspector and could not find my code.
Can someone check this on Windows and Mac machine?
In Meteor 0.5.4 this has become a lot easier:
First run the following commands from the terminal:
npm install -g node-inspector
node-inspector &
export NODE_OPTIONS='--debug-brk'
meteor
And then open http://localhost:8080 in your browser to view the node-inspector console.
Update
Since Meteor 1.0 you can just type
meteor debug
which is essentially a shortcut for the above commands, and then launch node inspector in your browser as mentioned.
Update
In Meteor 1.0.2 a console or shell has been added. It may come in handy to output variables and run commands on the server:
meteor shell
Meteor apps are Node.js apps. When running a Meteor app with the meteor [run] command, you can configure the NODE_OPTIONS environment variable to start node in debug mode.
Examples of NODE_OPTIONS environment variable values:
--debug
--debug=47977 - specify a port
--debug-brk - break on the first statement
--debug-brk=5858 - specify a port and break on the first statement
If you export NODE_OPTIONS=--debug, all meteor command run from the same shell will inherit the environment variable. Alternatively, you can enable debugging just for one run, with NODE_OPTIONS="--debug=47977" meteor.
To debug, run node-inspector in a different shell, then go to http://localhost:8080/debug?port=<the port you specified in NODE_OPTIONS>, regardless of what node-inspector tells you to run.
To start node.js in debug mode, I did it this way:
open /usr/lib/meteor/app/meteor/run.js
before
nodeOptions.push(path.join(options.bundlePath, 'main.js'));
add
nodeOptions.push('--debug');
Here are additional practical steps for your to attach debugger eclipse:
use '--debug-brk' instead of '--debug' here, because it's easier for me to attach node.js using eclipse as debugger.
add 'debugger;' in the code where you want to debug.(I prefer this way personally)
run meteor in console
attach to node.js in eclipse(V8 tools, attach to localhost:5858)
run, wait for debugger to be hit
when you start meteor in your meteor app folder, you'll see that "debugger listening on port 5858" in console.
On Meteor 1.0.3.1 (update to Sergey.Simonchik answer)
Start your server with meteor run --debug-port=<port-number>
Point browser to http://localhost:6222/debug?port=<port-number>
Where <port-number> is a port you specify.
In your code add a debugger; where you want to set your break point.
Depending on where debugger; is invoked, it will either break on your client or server browser window with inspector opened.
I like to set breakpoints via a GUI. This way I don't have to remember to remove any debugging code from my app.
This is how I managed to do it server side for my local meteor app:
meteor debug
start your app this way.
Open Chrome to the address it gives you. You MAY need to install https://github.com/node-inspector/node-inspector (it might come bundled with Meteor now? not sure)
You'll see some weird internal meteor code (not the app code you wrote). Press play to run the code. This code simply starts up your server to listen for connections.
Only after you press play you'll see a new directory in your debugger folder structure called "app". In there are your meteor project files. Set a breakpoint in there one the line you want.
Open the local address of your app. This will run your server side code and you you should be able to hit your breakpoint!
Note: you have to reopen the inspector and go through this process again each time your app restarts!
As of Meteor 1.0.2 probably the best way for server-side debugging is directly via the new built-in shell: with running server run meteor shell. More info here: https://www.meteor.com/blog/2014/12/19/meteor-102-meteor-shell
I am not sure why it was not working for you.
I am able to use it by following steps on console (Mac).
$ ps
$ kill -s USR1 *meteor_node_process_id*
$ node-inspector &
Above steps are mentioned on https://github.com/dannycoates/node-inspector. It is for attaching node-inspector to running node process.
I wrote a small meteor package called meteor-inspector which simplifies the use of node-inspector to debug meteor apps. It internally manages the lifecycle of node-inspector and hence, the user does not need to restart the debugger manually after some files have changed.
For more details and concrete usage instructions take a look at https://github.com/broth-eu/meteor-inspector.
for meteor 1.3.5.2, run
meteor debug --debug-port 5858+n
n is a non-zero number, this will cause node-inspector use 8080+n as web port.
WebStorm, the powerful IDE free for open source developers, makes it much easier to debug server-side.
I've tested it on Windows, and the configuration was painless - see my answer.
A inspector that solve my issues is meteor server console. Here is the process I followed to install it:
In your project folder, add the smart package server-eval:
mrt add server-eval
For Meteor 1.0:
meteor add gandev:server-eval
Restart meteor.
Download crx Chrome extension file from here.
Open extensions page in Chrome and drag crx file to extensions page.
Restart Chrome.
Check the web inspector out to eval server side code:
In comparison with node-inspector, I have a clearer output.
If you prefer to use nodeJS' official debugger you can call NODE_OPTIONS='--debug' meteor and then (on a different shell) node debug localhost:5858.

Resources