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
Related
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.
I am trying to run my test in an android mobile in a cloud platform cloud.seetest.io by installing appium studio plugin in eclipse so that test can be run directly from eclipse IDE itself.
It is always giving the error as
org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
#BeforeMethod
#Parameters("deviceQuery")
public void setUp(#Optional("#os='android'") String deviceQuery)throws Exception{
init(deviceQuery);
// Init application / device capabilities
dc.setCapability(MobileCapabilityType.APP, "cloud:xxxxxxxx/.xxxx");
dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "xxxxx");
dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ".xxxxxx");
dc.setCapability(SeeTestCapabilityType.DEVICE_QUERY, deviceQuery);
dc.setCapability(SeeTestCapabilityType.TEST_NAME, "AndroidDemoTest");
dc.setCapability("appVersion", "1.0.10516");
dc.setCapability("testName", "AndroidDemoTest");
driver = new AndroidDriver<>(new URL(getProperty("url",cloudProperties) + "/wd/hub"), dc);
}
Most probably your Appium client library version is not supported, as per Set Appium Java Client chapter:
You could make use of the Appium Java Client by adding a dependency to your Maven and Gradle projects
Please make sure you replace with the appropriate version:
4.1.2
5.0.4
6.1.0
7.0.0
It is recommended to use the public maven repo before the code export.
So inspect your dependency management file and make sure to update the io.appium.java-client dependency to one of the supported versions.
Experitest's client libraries might be missing. Try adding compile 'com.experitest:repo:+' in your build.gradle. This would download the latest client libraries. This document might help you in creating a sample project with Appium Studio plugin
Solution 1st
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "xyz");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("platformName", Platform.ANDROID);
capabilities.setCapability("appPackage", "com.hp.HPSupportAssistant");
capabilities.setCapability("appActivity", "com.hp.HPSupportAssistant.MainActivity");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 6000); capabilities.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS,true);
//desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
Here comment below line and then run it will work
desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
solution 2nd
Or keep above line in desired capabilities but before that do
run 3 cmd on cmd promt
adb shell pm list packages -f > D://t.txt
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test
desiredCap.setCapability(MobileCapabilityType.AUTOMATION_NAME,AutomationName.ANDROID_UIAUTOMATOR2);
This problem occurs when the driver is unable to get initiated. While connecting to experitest, these could have been the problems which give this error:
Licence of Experitest. If the licence is for one device/session at a time, one cannot attempt to create another session.
Desired Capabilities. Make sure that the device with the device id you mentioned in the code is available in the seetest cloud. Best practice is to first block the device and then copy the UDID to code.
In fact, there can be many reasons which could lead to no driver getting created. The actual reason behind this error is mentioned down there itself in the stack trace. Go down the stack trace and you will find the actual reason.
In my case it was the second one that happened.
I need to test my app on windows, but I am using a mac. It is very easy to package the app to run on windows, but I cannot package the app in dev-mode. I am using electron-is-dev to decide if I am running in dev or not. I need to run my tests on windows because I am testing a very specific windows hardware functionality. I don't want to comment my if(isDev){doSomething} just to run these test, and then uncomment it before I push the change. I was hoping there is some flag I can set in the electron-build cli, or maybe run electon . -windows?
Parse the parameter by adding sample code below to your electron main.js
const args = process.argv.slice(1);
windows = args.some(val => val === '-windows');
It can still be parsed on electron executable app by running in cmd like "electronapp.exe -windows"
The best way to do this so as to use the IsDev is to add the ELECTRON_IS_DEV environment variable to the app kinda like #carlokid suggested. I used: https://stackoverflow.com/a/34769146/3966009. This is the target I used for my app:
C:\Windows\System32\cmd.exe /c "SET ELECTRON_IS_DEV=1 && START ^"^" ^"C:\Program Files (x86)\My App\Fun Time.exe^""
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
Can anyone please help me to start browserstack locale as a background process in jenkins using WINDOWS for protractor end to end testing .
I was going through this link but this is for linux,I need for windows .
https://janmolak.com/jenkins-2-0-pipelines-and-browserstack-bd5a4ed3010d#.gf9pxyhgc
I have already installed browserstack binary for win 32 in jenkins.
Have you tried the Jenkins plugin for BrowserStack? You can refer to the details here - https://www.browserstack.com/automate/jenkins.
Since you are not using Java you will not be able to use the reporting functionality of the plugin. You can however use the following features that the plugin offers.
1) Manage your BrowserStack credentials globally or per build job.
2) Set up and teardown BrowserStackLocal for testing internal, dev or staging environments.
Here's how I got it working:
Install the BrowserStackLocal binary from their website.
Install the Jenkins Browserstack Plugin how to
Configure the plugin with your username and access key and point it at the downloaded binary.
In order for the session to route ip traffic locally, we have to pass a local identifier from the binary into our desired capabilities when the test runs. (as Ashwin Gonsalves pointed out.)
public DesiredCapabilities GetCapabilities(Browser browser, bool isBSLocal)
{
DesiredCapabilities capability = new DesiredCapabilities();
// Get BSID for local ip routing
if (isBSLocal)
{
string BSID = System.Environment.GetEnvironmentVariable("BROWSERSTACK_LOCAL_IDENTIFIER");
capability.SetCapability("browserstack.localIdentifier", BSID);
}
switch (browser.ToString())
{
case "Chrome":
capability.SetCapability("os", "Windows");
capability.SetCapability("os_version", "10");
capability.SetCapability("browser", "Chrome");
capability.SetCapability("browser_version", ChromeVersion);
capability.SetCapability("browserstack.chrome.driver", "2.42");
capability.SetCapability("resolution", "1920x1200");
capability.SetCapability("project", TestOps.GetParent);
capability.SetCapability("name", TestOps.GetTestName);
capability.SetCapability("browserstack.local", "true");
capability.SetCapability("browserstack.debug", "true");
capability.SetCapability("browserstack.selenium_version", ChromeSeleniumVersion);
capability.SetCapability("browserstack.user", USERNAME);
capability.SetCapability("browserstack.key", AUTOMATE_KEY);
break;