Automation issue with MOS and UiAutomator - android-uiautomator

I am using the following command in APK to invoke UiAutomator based test scripts:
proc = java.lang.Runtime.getRuntime().exec("uiautomator runtest Library.jar -c com.uia.example.my.Library");
It is working fine till LOS.
But in MOS, I am getting the following error:
Unable to unlink
/data/local/tmp/dalvik-cache/arm64/sdcard#data#Library.jar#classes.dex:
Permission denied
Please provide solution for this issue.
Note: I need to run scripts in release binary. So rooting is not possible.

Use Android Testing Support Library and create a test case extending InstrumentationTestCase as explained in Testing UI for Multiple Apps.
Then run your tests using
$ ./gradlew connectedCheck

The problem is due to no write permission in /data/local/tmp/ where you placed your Library.jar file. Write permission is required to extract dex from the Jar.
May be OEMs could disable rooting and remove write permission to /data/local/tmp and that may the reason for your issue in production/release builds ..
If you use uiautomator commands like : uiautomator runtest Library.jar ....
uiautomator will search for Library.jar by default in /data/local/tmp .
You can check uiautomator shell script present in /system/bin.
export run_base=/data/local/tmp ==> Classpath for searching the dex files.
One solution could be to place Library.jar and modified uiautomator script in your application folder (data/data//files).
you have to modify run_base with your application data folder path.
You can bundle the uiautomator script and jar following the instrcutions in below link :
http://gimite.net/en/index.php?Run%20native%20executable%20in%20Android%20App
Hope it helps ... Please update about your results.

Related

Executing gradle scripts from external directories

I need to execute groovy script with gradle, but the thing is that these scripts are located in external directory (let's say it's Desktop). I've heard, that in previous versions of Gradle (currently working on 3.2.1) it was not possible, since it is not part of the gradle project. I wonder if it is possible now, or do I have to copy all these scripts into some folder located in gradle project, to execute it.
User story:
I found script in external directory (based on some properties passed to console) - I have absolute path to the script
Now I want to execute this script (build.gradle) without copying it into my gradle project
I'm pretty green with gradle and I hope I made my point clear.
Thanks for help and every attempt :)
Is that what you're looking for? To run the script clone the repository, navigate to 42556631/project folder and run the command:
gradle -b ../script/build.gradle clean build
yes you need to move build.gradle file into project/Build Script folder and then run it.

Selenium with Jenkins on MAC

Can someone explain step by step procedure to execute Selenium with Jenkins on MAC? There are many Video for windows but nothing on MAC.
Steps required:
How to set Classpath in terminal?
how to resolve "Permission denied" for jar files?
Run scripts in Jenkin.
You could try out the following:
How to set CLASSPATH in terminal?
A: Open new terminal you will be in your home directory example /User/pavan
You can edit .bash_profile
export JAVA_HOME=/user/pavan/jdk1.8.0_101
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib
you could add your required jar paths with colon separated.
2 How to resolve "Permission deined" for jar files?
You might tried jar command use the following:
java -jar yourtarget.jar
Run scripts in Jenkin.
You need to create a job in Jenkin dashboard.In the build section you give shell scripts or commands as shown below image:

problems running state machine examples

Congratulations on the spring state machine, I found it yesterday and have been trying it out, specifically the turnstile example running in STS. I found it very easy and intuitive to build a FSM.
Because spring shell doesn't work well in STS I tracked down the instructions to run the examples from the command line in the reference doc,
"java -jar
spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar"
,
but running it got an error
"no main manifest attribute, in spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar".
Although not even a novice in using gradle, I tried fixing this by adding this line to build.gradle in the jar section
"manifest.attributes['Main-Class'] = 'demo.turnstile.Application'"
(which doesn't handle the various sub-projects I know) but got this error
"NoClassDefFoundError: org/springframework/shell/Bootstrap".
If it is possible to run the samples from gradle, could you include them in the reference document? I tried running the samples using
gradle run
but it there was no interaction with the shell scripts.
Samples are designed to be run as executable jar and with shell so that you can interact without a need to recompile with every change. Your error indicates that you didn't build that sample jar as mentioned in docs.
./gradlew clean build -x test
This will automatically use spring boot plugin which will add the necessary jar manifest headers to jar meta info to make it a true executable jar. Essentially every every sample is a spring boot app.
Building SM sample projects in Windows Environment:
Open Command prompt (windows key + r -->cmd-->Enter), Change directory to project root folder spring-statemachine-master (Inside the Extracted folder).
Run gradlew install to get all spring dependencies copied to local machine.
Run gradlew clean build -x test to get the spring shell jars built. Courtesy Janne
These steps should ideally get all .jar built, look into \build\libs folder of respective sample project for jar files.
Run the like any other java jar file java -jar [jar-file-name.jar] (make sure to be change directory to jar file directory location).
One more thing where I was stuck was, How to give events to SM:
It's like this sm event EVENT_NAME_AS_DEFINED_IN_CLASS. Ref
E.g.: sm event RINSE --> to washer project

Ant not loading salesforce task definitions?

The Question
I'm trying to use the Force.com Migration Tool (a custom ant library) on a linux box and can't for the life of me figure out how to get ant to see that library. What am I doing wrong?
The Error Message
BUILD FAILED
/home/ec2-user/ant/ucp/build.xml:48: Problem: failed to create
task or type antlib:com.salesforce:retrieve
Cause: The name is undefined.
The Background
I installed ant using yum install ant and then I dropped the Force.com Migration Tool (ant-salesforce.jar) into /usr/share/ant/lib. I'm able to see this library when I run ant -diagnostics, but none of the tasks for that library (should be seeing deploy, retrieve, etc.). I've uploaded a gist with the full output from ant -diagnostics.
-------------------------------------------
ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/share/ant
ant-bootstrap.jar (19837 bytes)
ant-salesforce.jar (3293054 bytes)
ant.jar (1942059 bytes)
ant-launcher.jar (18418 bytes)
After lots of googling and manual reading I tried the following to no avail (NB: the above diagnostics is without any of the below changes). I know I'm missing something obvious :(
Setting $ANT_HOME export ANT_HOME=/usr/share/ant
Fiddling with permissions chmod +x /usr/share/ant/lib/salesforce-jar
Fiddling with groups chown root:root /usr/share/ant/lib/salesforce-jar
Passing in class with -lib ant -lib /usr/share/ant/lib/salesforce-jar retrieve ...
Passing in lib folder with -lib ant -lib /usr/share/ant/lib retrieve ...
Adding $ANT_HOME to $PATH export PATH=$PATH:$ANT_HOME/bin
How about keeping ant-salesforce.jar under /home/ec2-user/ant/ucp and then change the taskdef element to look like this:
<taskdef resource="com/salesforce/antlib.xml" classpath="ant-salesforce.jar" />
Run your build again and see if things look better. Having the JAR in the same folder as build.xml will help you eliminate issues with permissions.
Based on #smooth_reggae's answer was able to get things working while keeping ant-salesforce.jar in the default ant lib directory. Seems like this should already be happening, but oh-well.
<taskdef resource="com/salesforce/antlib.xml"
classPath="${ant.library.dir}/ant-salesforce.jar"
uri="antlib:com.salesforce"/>

Xcode oclint analyzer

I want to use oclint (an Objective-C static analyzer) for my projects but the official documentation does not clearly describe how to configure it.
How do I use it?
I have installed the oclint package then copied the script for capturing projects configs into a project's folder. Running this script creates an empty file named compile_commands.json and it does not fill xcodebuild.log with any data.
Thank you!
I don't think this script will add anything into xcodebuild.log. It reads from it. You may want to manually run xcodebuild and save the output into xcodebuild.log before running the script.
Check out the documentation.
I have had luck with the manual route of copying the script into my project's folder then executing it on the command line.
Though this does not integrate oclint's functionality into XCode, it does provide feedback via stdout.
From this feedback I then update my code to align with oclint's recommendation and iteratively run oclint until my code complies with oclint's rules.

Resources