My UIautomator is not starting in mac. I have done everything possible - automation

I am learning appium and I have set up everything that is required. I have setup paths, installed android studio, run appium and created a virtual android device too. But when i am writing uiautomatorviewer its giving me an error
mac#Macs-MacBook-Pro ~ % uiautomatorviewer
-Djava.ext.dirs=/Users/mac/Library/Android/sdk/tools/lib/x86_64:/Users/mac/Library/Android/sdk/tools/lib is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
mac#Macs-MacBook-Pro ~ %
Can anyone help me please

A. I encountered this issue once, sometime env var doesn't load and it throws error, open and load bash profile and run that command.
open ~/.bash_profile
source ~/.bash_profile
uiautomatorviewer
B. if appium server is running, try to close it and run the command.

Try the following command:
sudo ./uiautomatorviewer

Related

Python cron job with Chrome not running in AWS EC2

I've been using an EC2 instance to run a python script with cron everyday for a month or so. The script uses selenium.
Everything was working correctly until today, when my script did not run.
I have tried to run it manually but it's not working either. The error message says that
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.
NoSuchElementException: Message: no such element: Unable to locate element:
{"method":"cssselector","selector":"#ctl00_ctl00_moteurRapideOffre_
ctl01_EngineCriteriaCollection_Contract > option:nth-child(5)"}
(Session info: headless chrome=90.0.4430.85)
However, the same script is running fine on my computer (ie on my Macbook, not on AWS EC2).
As the problem seems to come from Chrome, I uninstalled it on AWS EC2 using:
sudo yum remove google-chrome-stable
Then I reinstalled it using :
curl https://intoli.com/install-google-chrome.sh | bash
sudo mv /usr/bin/google-chrome-stable /usr/bin/google-chrome
google-chrome --version && which google-chrome
If I try to run Chrome on the EC2 using /usr/bin/google-chrome, it does not work and it displays the following error message :
ERROR:browser_main_loop.cc(1386)] Unable to open X display.
I don't know if it was working before as I have never used it this way. But it seems to be a problem.
I have seen on the web that it might come from the fact that there is no screen and that I should use a package named xvfb. I have tried to install it with the following code:
sudo yum install xorg-x11-server-Xvfb
I guess the package was correclty installed, but it is not working better.
To sum up, I think my problem in the python code is linked to the fact that Google Chrome is not working correclty and this might be linked to xvfb. But I am not sure at all, it is just what I have tried until now.
Could you please help me ? Thanks!
You can simply add setup your like this, runs after every 30 minutes
*/30 * * * * export DISPLAY=:0 && ,<do what ever you want.>
If this does not work, and you google-chrome or firefox not found, simply run the command below in your shell BASH, FISH, ZSH etc to get PATH.
echo $PATH
Whatever the result comes out from the above command just copy and paste it above your cronjob like this,
*/30 * * * * export DISPLAY=:0 && ,<your selenium script.>```
You can remove export ```export DISPLAY=:0``` line if you want to this in the background or make your driver headless.
The reason of doing this, you might install the respective from snapd etc and that's why path is not defined as you downloaded from separate resource.

Payara does not start from Intellij

The Payara with GlassFish 5.192.0 does not start using the Intellij Idea.
If I run payara\bin\asadmin start-domain is works just fine, and the server starts and runs.
These are the final lines from the console output with the --verbose property set on true.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED
Command start-domain failed.
The DAS was stopped.
The root case of the issue is logged here.
Windows launcher prepends PATH with JetBrains Runtime bin directory in order to load certain DLLs without issues. It turned out to be not the best solution and we are working to address it in a different way.
asadmin.bat uses the first java.exe from PATH. It doesn't try to detect it via JAVA_HOME.
The workaround for now is to switch IntelliJ IDEA boot JDK to JBR8 per this document or start IntelliJ IDEA using idea.bat instead of idea64.exe.
The issue is fixed in 2019.2.1 RC.

Test instrumentation process crashed - where is the .txt file?

Sometimes, while Espresso testing, I see the following exception.
Test instrumentation process crashed. Check package_name.TestName#methodName.txt for details
Where is this .txt file stored? I can't seem to find it anywhere.
Use Case
In Jenkins (CI), I want the logs to see exactly what stacktrace caused the crash.
If you are working with an emulator, in A.S open Device File Explorer and go to:
/data/user_de/0/android.support.test.orchestrator/files/, then you can look for a particular file there
EDIT: June 25 - 2019 >> If you have updated to AndroidX dependencies, then the .txt file is located in
/data/user_de/0/androidx.test.orchestrator/files/
In my case, it was simpler to just check Logcat, rather than listen to that recommendation
For others encountering this issue, as #antek pointed out the files might not be accessible on a non-rooted device. You might try using an emulator running a non-Google Play API where you can obtain a root shell.
adb root
adb shell
ls /data/data/androidx.test.orchestrator/files
Alternatively, you could try running the tests using the debugger.
I could not find the text file, but I was able to get logcat and view the fatal that caused the orchestrator to crash
first I clear the logcat
adb logcat -c
then I run the test, then I grab the logcat
adb logcat > ~/Desktop/logcat
then I open logcat file and search for string FATAL
I just did wipe data in Android studio for my emulator using Device manager.
Restarted the emulator and run the test works for me

Publishing an .apk into IBM Application Center from Application Center command-line tools

I'm trying to publish an .apk into my Application Center through console. I've followed this note but it doesn't work in my environment:
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/moving-production/distributing-mobile-applications-with-application-center/#cmdLineTools
If I type :
./acdeploytool.sh /home/miguel/Downloads/HelloWorldMyHelloAndroid.apk
I get this error message:
FWLAC0803E: Unable to connect:
Connection refused
Perhaps the server or context is wrongly specified.
File:/home/myUser/Downloads/HelloWorldMyHelloAndroid.apk
And if I try another way using this java command:
java com.ibm.appcenter.Upload -f http://localhost:9080 -c applicationcenter -u demo -p demo /home/myUser/Downloads/HelloWorldMyHelloAndroid.apk
I get this one:
Error: Could not find or load main class com.ibm.appcenter.Upload
I don't get any errors when I do this 'publish' operation directly in Application Center or through MobileFirst Studio.
Miguel, whether you use the script or the Java command, you need to specify the arguments to use. Please try the following:
./acdeploytool.sh -s http://localhost:9080 -c applicationcenter -u demo -p demo /home/miguel/Downloads/HelloWorldMyHelloAndroid.apk
I tried a similar command in my environment and was able to successfully deploy the apk to Application Center. If the command still does not work, make sure that the host/port that you are using are correct, and that the username and password are valid.
For the Java command that you executed, I see a few problems. First, the -cp argument needs to be specified in order to add the applicationcenterdeploytool.jar and json4j.jar files to the classpath. Next, the command shows "-f", but it should be "-s" to specify the server. Lastly, the path that was specified for the .apk is different than what you specified in the first command: myUser vs. miguel. So make sure that the correct path is used. If there are any further questions, let me know. Thanks.

/sbin/nologin issue with msys2 on Windows 10

I have just installed MSys2 (https://msys2.github.io, msys2-x86_64-20150916.exe) on my Windows 10 computer.
Once installed, the terminal is launched. But as soon as I stop it and relaunch it, I get the error: "Failed to run /sbin/nologin: No such file or directory".
Any idea on what to do?
You should figure out why Bash is trying to run /sbin/nologin. Check your Windows home directory (e.g. C:\Users\Joe) for files like .bash_profile, .profile, and .bashrc. Inspect those files and find which one is calling nologin.
If that doesn't help, try creating an empty file in C:/msys64/sbin/nologin, or wherever you actually installed MSYS2. An empty file would be a valid shell script and run without errors.
If the error is non-fatal you might consider just ignoring it.