How to update to UiAutomator2? - appium

I have some Robot Framework tests for Android device which I'm running. I'm currently using Windows10 computer to develop those tests.
I just installed version v1.15.0-1 of Appium. By default this new Appium is using UIAutomator2. Not anymore UIAutomator1. My problem is, that I have installed UIAutomator2, but Appium not seem to find that. Only way I can run my tests is to use UIAutomator1.
I have installed UIAutomator2 driver:
npm -g install appium-uiautomator2-driver
Not working:
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME} platformVersion=${PLATFORM_VERSION} deviceName=${DEVICE_NAME} appPackage=${${ENV}_APP_PACKAGE} automationName=UiAutomator2 app=${${ENV}_APP} appActivity=com.dummyfi.viestit.ui.splash.SplashActivity noReset=True
Working:
Open Application ${REMOTE_URL} platformName=${PLATFORM_NAME} platformVersion=${PLATFORM_VERSION} deviceName=${DEVICE_NAME} appPackage=${${ENV}_APP_PACKAGE} automationName=UiAutomator1 app=${${ENV}_APP} appActivity=com.dummyfi.viestit.ui.splash.SplashActivity noReset=True
This is what I get, when I'm trying to run tests with UIAutomator2:
Suite setup failed:
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: The application at 'fi.dummy.viestit.sa' does not exist or is not accessible
With UIAutomator1, everything is working fine.

Related

Appium - AWS device farm

I get an error as below when I try to run my tests on device farm.
testAppiumMethod failed: Invalid server instance exception has occured:
There is no installed nodes! Please install node via NPM
(https://www.npmjs.com/package/appium#using-node-js) or download and
install Appium app (http://appium.io/downloads.html)
I have installed Appium globally on local machine and the tests run fine. But they fail on device farm(have included all the dependencies). Can somebody help me out?
I believe you are trying to invoke the Appium server through your code, which is not required in Device Farm. Device farm has a Test Spec file (which is a yaml file) which does it for you, so all yo need to do is connect your driver to the invoked Appium server.
When you get the chance would you be able to provide this info:
appium verion being used
Specific method that the this failed on/code
snippet
Programming language Java/python
How exactly are the test being packaged and uploaded? Are we using the web console or the SDK/CLI?
Is this a web app tests or native app tests?
Also, to rule out an issue with a specific device would we be able to run the AWS Sample app/test on the same device?
Assuming this is an android test execute these commands to build the sample app:
git clone https://github.com/awslabs/aws-device-farm-sample-app-for-android.git
cd aws-device-farm-sample-app-for-android/
./gradlew cC
The app-debug.apk should be located in ./app/build/outputs/apk/
Then clone the sample appium testng tests:
git clone https://github.com/awslabs/aws-device-farm-appium-tests-for-sample-app.git
cd aws-device-farm-appium-tests-for-sample-app/
mvn clean package -DskipTests=true
The test pacakge "zip-with-dependencies.zip" should be located in the ./target directory
My apologies for adding all these questions as an answer. I look forward to your response.
HTH James
Seems to me that you need to install node on your AWS instance.
See below:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

Fitnesse: Slim server died issue

I am trying to add the Fitnesse testing tool for iOS app testing. I created sample test. When I clicked on test button, I am getting following error.
Unable to start test system 'slim': fitnesse.slim.SlimError: Error
SLiM server died before a connection could be established. [OCSP_INFO]
ERROR: Use '$ npm install ios-sim -g'
It looks like server connection is not created. How to solve this issue.

Dart unit test not working with content-shell

I have dart unit tests written using test: '>=0.12.1 <0.13.0' library. When I try to run tests using Dartium it works perfectly, but using content-shell it throws error.
pub run test test/unit -p content-shell
Failed to start content shell: Bad state: Stream has already been listened to..
I'm using ubuntu machine and content shell is in path.
I upgraded the dart and content-shell version to 1.11 and its working now.

How to setup Appium Environment for Android Automation?

I am working as SD in Test. I am new to Appium Automation tool, this tool is very tricky to set up environment for me.
I referred following link: http://unmesh.me/category/appium/
This link helped me to install Node.js and appium through command line. But I am not sure this right way to do.
I got following message from command line :
mani-kandans-MacBook-Pro:platform-tools manikandan$ info: Welcome to Appium v0.8.2 (REV e9cc66197ad6a3496322bd77a8699509fc761b69)
info: Appium REST http interface listener started on 0.0.0.0:4723
info - socket.io started
After this I don't have any idea. How to write testcase and run it through Appium?
If your interest to share your knowledge about Appium tool. Please guide me.
How to Install Appium?
How to run testcase through Appium tool?
Part One:-. You appear to have launched the appium server using node server.js
- You can check the server by going to localhost:4723/wd/hub/status in your browser this will return a few details of the server. You have already done this.
The command output will look like this confirming that the server is started:
info: Welcome to Appium v0.8.1 (REV ***********************************)
info: Appium REST http interface listener started on 0.0.0.0:4723
info - socket.io started
Part Two:-. Next you use the selenium RC for Python, Java, or c# or whatever your language choice. I used c# and can provide examples this should be similar for your tests.
To add the selenium to a c# class: using OpenQA.Selenium.Remote;
You pass all your data to a selenium desired capabilities object.
Some custom desired capabilities exist such as:
'app-package' this is the app package name such as com.myapp.main,
'app-activity' which is the apps main activity to be called which will also launch the app. This is often a splash activity or main activity,
'wait-activity' is the activity that Appium will check for once launched, this would be the app-activity but for me it is different if for some tests a new activity is launched than is called,
'version' taking the android version,
'device ID' taking your attached device or AVD to command and app which will have a local path to the apk you wish to install. This is signed and installed on start-up if a resigned app already exists it will skip this for you.
DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability("app-package", "com.myapp.test");
caps.SetCapability("browserName", "");
caps.SetCapability("device", "Android");
caps.SetCapability("app-activity", "com.myapp.SplashActivity");
caps.SetCapability("takesScreenshot", true);
caps.SetCapability("version", "4.1.2");
caps.SetCapability("device ID", "uniquedeviceid");
caps.SetCapability("app", #"C:\path to\app\on\pc\app.apk");
Following the Capabilities you create create a remote web driver object passing the hub url that you've used e.g http://localhost:4723/wd/hub and the Desired Capabilities you've created.
RemoteWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4723/wd/hub/"), caps);
This line uses the ip or host of the Appium server to begin listening for requests.
For me this step signs installs and launches the app on the attached device hopefully this will work for you the same.
This is where the selenium tests you write are connected to the Appium server.
Now using the created driver object you can access the selenium rc commands of which Appium has implemented many alternatives for android testing.
During each of these your Appium server console window should show you if there is any issues.
Output will be colour coded to assist in identifying failures from this window but you can handle these your own way and output to a file if needed.
Update for multiple devices
I am unsure on the use of multiple devices, I would consider selenium grid my previous attempts to add 2 devices to one machine and test had confusion where adb was unable to distinguish regardless of the device id addition to the configuration and commands.
The Appium team have been making improvements to add grid functionality to the server, I recommend you have a look into Appium Grid (link updated)
I apologize for my lack the experience with grid to assist you further.
Regards, Brian
It seems to be late reply, but still I guess this post can help some one, who are looking for step by step by guide to install Appium on Windows platform
http://qaautomationworld.blogspot.in/2014/12/appium-setup-for-android-windows.html
This link mainly deals with the following sections
JDK Installation
Android SDK Installation path setup
Appium Installation
a) Using node.js
b) Using Appium.exe
Here's my env.rb file for appium android.
require 'rubygems'
require 'appium_lib'
# Start Android driver
apk = {
device: :android,
app_path: (true && ENV['apk']) || 'path to apk',
app_package: (true && ENV['package']) || 'com.foo.cam',
app_activity: (true && ENV['activity']) || '.SplashActivity',
app_wait_activity: (true && ENV['activity']) || '.MainActivity',
}
Appium::Driver.new(apk).start_driver
Appium.promote_appium_methods Object
log = Logger.new(STDOUT)
case ENV['log']
when 'WARN'
log.level = Logger::WARN
when 'DEBUG'
log.level = Logger::DEBUG
when 'INFO'
log.level = Logger::INFO
when 'ERROR'
log.level = Logger::ERROR
when 'FATAL'
log.level = Logger::FATAL
when 'UNKNOWN'
log.level = Logger::UNKNOWN
else
log.level = Logger::DEBUG
end
log.debug('starting suite')
Before do
#test_env = {
device: driver,
main_activity: (true && ENV['main_activity']) || 'grid.GridLoginActivity',
logger: log
}
end
# Optional--clears alerts
After ('#rate_limit') do |scenario|
log = #test_env[:logger]
device = #test_env[:device]
if scenario.failed?
begin
wait = Selenium::WebDriver::Wait.new :timeout => 1
wait.until { device.alert_accept }
log.debug('cleared rate limit dialog')
rescue
log.error("dialog didn't pop.")
end
end
log.debug('rate_limit finished')
end
After ('#network_connection') do |scenario|
log = #test_env[:logger]
device = #test_env[:device]
if scenario.failed?
begin
wait = Selenium::WebDriver::Wait.new :timeout => 1
wait.until { device.alert_accept }
log.debug('cleared network connection issue')
rescue
log.error("dialog didn't pop.")
end
end
log.debug('network_connection finished')
end
To install Appium first up all Download Required Tools:
Android Studio
Appium Jar Files For Java
Java Selenium Client Plugin
Appium Server
Java SDK
After downloading all these tools follow step by step process mention in this blog:
Installation Process of Appium in Android Studio
Here I have tried to explain full end to end set up instruction to Configure and run Android Mobile Automation Testcases using Appium
Download Java and set Java_Home in environmental variables
Download Android STUDIO from below link
https://developer.android.com/studio/index.html
Check Android installation path in Machine
Set Android_Home Environmental variables path to SDK location and include bin folder paths in PATH variable
Open Android Studio and configure Virtual device/Emulator
Open Emulator and check if it is working.
Download Node.js
https://nodejs.org/en/download/
Set Node_Home Environmental variables path
Set npm Environmental variables path
Download Appium Server from Node
Download Appium and Selenium Java client library
Install Eclipse – Create a Project in Eclipse - configure Appium libraries
Add All dependencies
//You can download any node module only using npm
npm install – g appium – Latest Stable release version 1.16.0 – Android 10+ version
npm uninstall -g appium // g stands for global
Appium – starts the server

unable to run scripts from jenkins

We are using sikuli tool for mobile automation on our MAC OSX 10.7.3 I have written a shell script to open simulator and to run scripts on simulator:
SikuliScript.sh
/Users/ezprintsqa/Downloads/FoneMonkey/bin/iphonesim launch /Users/ezprintsqa/Documents/Xcode/DerivedData/SnapCards-btmjdowsgmixpvdyfxfvhxtoihab/Build/Products/Debug-iphonesimulator/SnapCardsFoneMonkey.app&
/Users/ezprintsqa/Downloads/Sikuli-IDE.app/sikuli-ide.sh -r /Users/ezprintsqa/Downloads/SikuliWorkSpace/SnapcardsTestSuite1.sikuli
When I execute from command line I can see simulator opening and scripts getting executed on simulator.
But when I run from Jenkins I am getting the following error:
[JavaAppLauncher Error] CFBundleCopyResourceURL() failed loading MRJApp.properties file
[DEBUG] Could not start simulator session: Error Domain=DTiPhoneSimulatorErrorDomain Code=5 "Operation failed with underlying error 4294956486." UserInfo=0x100305c70 {NSLocalizedDescription=Operation failed with underlying error 4294956486., NSUnderlyingError=0x100300610 "The operation couldn’t be completed. (OSStatus error -10810.)"}
[LaunchRunner Error] No main class specified
[JavaAppLauncher Error] CallStaticVoidMethod() threw an exception
Exception in thread "main" java.lang.NullPointerException
at apple.launcher.LaunchRunner.run(LaunchRunner.java:113)
at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
at apple.launcher.JavaApplicationLauncher.main(JavaApplicationLauncher.java:61)
Any suggestions will be very helpful
It definitely looks like a permission issue. The official Jenkins installer for Mac sets up Jenkins to run either as user "daemon" or user "jenkins". You need to make tools needed by Jenkins readable and executable by that user. Also, they need to be in a directory which is readable and executable by that user.
However, even if you get the permissions fixed, you will probably have further problems with your test run. The official Jenkins installer for Mac sets up Jenkins to run as a launch daemon. These run in the system context and they have no access to any desktop or GUI session, which means it is not possible to draw windows on the screen => Any tool that displays windows, like iPhone Simulator or Sikuli is going to fail.
You could try my unofficial Jenkins.app instead, which should solve your problem. It is available at https://github.com/stisti/jenkins-app (download it under the Downloads tab.)

Resources