Failed to start an Appium session, err was: Error: Bad app: - java

I want to automated Facebook app on my android device.
I have tried to init a driver like this:
private AppiumDriver driver;
#Before
public void setUp() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "../../../data/app/ ");
File app = new File(appDir, "Facebook.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", app.getAbsolutePath());
// capabilities.setCapability("appPackage", "com.example.android.apis");
// capabilities.setCapability("appActivity", ".ApiDemos");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
and I got:
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/eladb/WorkspaceQa/myAppiumExm/../../../data/app/ /Facebook.apk","platformVersion":"4.4","browserName":"","platformName":"Android","deviceName":"Android Emulator"}}
info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
error: Failed to start an Appium session, err was: Error: Bad app: /Users/data/app/ /Facebook.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat '/Users/data/app/ /Facebook.apk'
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: /Users/data/app/ /Facebook.apk
info: [debug] Got configuration error, not starting session
info: [debug] Cleaning up appium session
info: [debug] Error: Bad app: /Users/data/app/ /Facebook.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat '/Users/data/app/ /Facebook.apk'
at null.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-common.js:56:13)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/device.js:81:16
at FSReqWrap.oncomplete (fs.js:99:15)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: /Users/data/app/ /Facebook.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat '/Users/data/app/ /Facebook.apk')","origValue":"Bad app: /Users/data/app/ /Facebook.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat '/Users/data/app/ /Facebook.apk'"},"sessionId":null}
info: <-- POST /wd/hub/session 500 8.318 ms - 628
I have tried:
capabilities.setCapability("app", "Facebook.apk");
and I got:
error: Failed to start an Appium session, err was: Error: Bad app: null. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: You passed in an app package as the 'app' capability, but didn't include appActivity. We need to know that too in order to start your app
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Got configuration error, not starting session
info: [debug] Cleaning up appium session
info: [debug] Error: Bad app: null. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: You passed in an app package as the 'app' capability, but didn't include appActivity. We need to know that too in order to start your app
at null.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-common.js:56:13)
at androidCommon.configureApp (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-common.js:69:14)
at androidCommon.configure (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-common.js:37:10)
at Appium.configure (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:250:15)
at null.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:118:10)
at Appium.start (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:129:5)
at Object.exports.createSession [as handle] (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/controller.js:182:16)
at next_layer (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/route.js:113:13)
at Route.dispatch (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/route.js:117:5)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:222:24
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Bad app: null. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: You passed in an app package as the 'app' capability, but didn't include appActivity. We need to know that too in order to start your app)","origValue":"Bad app: null. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: You passed in an app package as the 'app' capability, but didn't include appActivity. We need to know that too in order to start your app"},"sessionId":null}
info: <-- POST /wd/hub/session 500 9.616 ms - 712
error: Unexpected error: Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:335:11)
at ServerResponse.res.set.res.header (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/response.js:561:10)
at ServerResponse.res.send (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/response.js:133:12)
at ServerResponse.res.json (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/response.js:210:15)
at ServerResponse.res.send (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/response.js:121:21)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/helpers.js:42:9
at safely (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/helpers.js:306:5)
at Layer.module.exports.catchAllHandler [as handle] (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/helpers.js:41:3)
at trim_prefix (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:261:17)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:225:9 context: [POST /wd/hub/session {"desiredCapabilities":{"app":"Facebook.apk","platformVersion":"4.4","browserName":"","platformName":"Android","deviceName":"Android Emulator"}}]
TypeError: Cannot set property 'onResetTimeout' of null
at Appium.configure (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:252:30)
at null.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:118:10)
at Appium.start (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:129:5)
how can I make it work?
Update
I have tried:
#Before
public void setUp() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "../../../data/app/");
File app = new File(appDir, "Facebook.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", app.getCanonicalPath());
// capabilities.setCapability("appPackage", "com.example.android.apis");
// capabilities.setCapability("appActivity", ".ApiDemos");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
and got:
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Bad app: /Users/data/app/Facebook.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat '/Users/data/app/Facebook.apk') (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 900 milliseconds
Build info: version: '2.43.1', revision: '5163bceef1bc36d43f3dc0b83c88998168a363a0', time: '2014-09-10 09:43:55'
System info: host: 'eladb-macbookpro.roam.corp.google.com', ip: '10.0.0.2', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.5', java.version: '1.8.0_25'

I cannot verify it at the moment but my guess is that you have a blank space generating some problems here:
1. private AppiumDriver driver;
2.
3. #Before
4. public void setUp() throws Exception {
5. File classpathRoot = new File(System.getProperty("user.dir"));
6. File appDir = new File(classpathRoot, "../../../data/app/ "); // <== HERE
7. File app = new File(appDir, "Facebook.apk");
8. ...
Appium log is telling you that the generated path is:
"app":"/Users/eladb/WorkspaceQa/myAppiumExm/../../../data/app/ /Facebook.apk"
That space in line 6 at "app/ " is causing the final path to be "/Users/eladb/WorkspaceQa/myAppiumExm/../../../data/app/ /Facebook.apk". I would rewrite line 6 like this:
File appDir = new File(classpathRoot, "../../../data/app/");
Instead of "app/ ", use "...app/"
Canonical paths
I haven't been using Java for a while so I do not remember IO APIs how they work, however you should find a better way to get the absolute path to you appfile because you have a final address which using the parent folder pattern ../ to access a resource... This is not the best. The final path should be:
"app":"/Users/data/app/Facebook.apk"
Am I right? In this answer you can see that probably you should be using getCanonicalPath rather than getAbsolutePath.
If my guess is right, the following code should work:
public void setUp() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "../../../data/app/");
File app = new File(appDir, "Facebook.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", app.getCanonicalPath());
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
If you want to automate an existing app...
So looks like you might want to automate an existing app, the set of capabilities is as follows for Android:
public void setUp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "<java-package-name-of-the-app>");
capabilities.setCapability("appActivity", "<android-app-activity-name>");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
Those new capabilities: appPackage and appActivity can be found in your app's property if you inspect Settings.

I did nothing but clearing up the space in mac, and it worked.!

Related

SessionNotCreatedException: session not created exception from unknown error: Runtime.executionContextCreated has invalid 'context' with Chrome driver

Error stack trace (Updated from comments):
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 7778 Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"961185F0AA38D24650EF6C797BC32535","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"}
(Session info: chrome=70.0.3538.102)
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.68 seconds Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:41'
System info: host: 'LTAH024', ip: '192.168.131.142', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'
Driver info: driver.version: ChromeDriver
I wrote simple program to launching a chrome browser. Please see the below code. I have already set a path in environment variable:
package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ChromeBrowser {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver drive = new ChromeDriver();
drive.get("http://toolsqa.com/selenium-webdriver/running-tests-in-chrome-browser/");
System.out.println("Successfully open tools qa website in Chrome browser");
//Thread.sleep(5000); //To initiate thread , we need to add throws interrupt exception
//Close the driver
//driver.quit();
}
}
Please look into this and help me out. The same thing geckodriver for firefox is working.
This error message...
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 7778 Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"961185F0AA38D24650EF6C797BC32535","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"}
(Session info: chrome=70.0.3538.102)
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.68 seconds Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:41'
System info: host: 'LTAH024', ip: '192.168.131.142', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'
Driver info: driver.version: ChromeDriver
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
You have 3 issues exactly and your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.2.20
Release Notes of chromedriver=2.20 clearly mentions the following :
Supports Chrome v43-48
You are using chrome=70.0
Release Notes of ChromeDriver v2.43 clearly mentions the following :
Supports Chrome v69-71
Your Selenium Client version is the current version of 3.141.5..
Your JDK version is 1.8.0_60 which is pretty ancient.
So there is a clear mismatch between the JDK v8u60 , Selenium Client v3.141.5 , ChromeDriver v2.20 and the Chrome Browser v70.0
Solution
While using Selenium v3.x clients you need to download the latest ChromeDriver from ChromeDriver - WebDriver for Chrome store it anywhere within your system and provide the absolute path of the ChromeDriver through System.setProperty() line as follows:
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
Upgrade JDK to recent levels JDK 8u191.
Upgrade ChromeDriver to current ChromeDriver v2.43 level.
Keep Chrome version between Chrome v69-71 levels. (as per ChromeDriver v2.43 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
(WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
(LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Download chrome driver, keep it at your local and put the path at System.setProperty try the below code, hope it helps.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class ChromeBrowser {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "B:\\chromedriver.exe"); //put driver path here
WebDriver drive = new ChromeDriver();
drive.get("http://toolsqa.com/selenium-webdriver/running-tests-in- chrome-browser/");
System.out.println("Successfully open tools qa website in Chrome browser");
drive.quit();
}
}
Their are Three Ways to open The Chrome Browser:
First one:using system.setproperty
System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");
Webdriver driver = new ChromeDriver();
Second one : using Chrome Options:
//set path to chromedriver.exe
ChromeOptions options = new ChromeOptions();
options.setAcceptInsecureCerts(true);
options.setBinary(new File("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"));
options.addArguments("disable-infobars");
System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");
driver = new ChromeDriver(options);
Last one : if you are using maven use this
This downloads the latest chrome driver version and starts it. You can use WebDriverManager within using bonigarcia dependency. Add The bonigarcia dependency in your Pom.xml File and start using it via WebdriverManager
https://github.com/bonigarcia/webdrivermanager
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
Finally What is Version for your Gecko driver & Firefox?

How to run selenium tests on chrome if only binary file of chrome is placed in a server location in E drive

I have a situation in my project as below :
My code was executing as expected till the IT admin uninstalled chrome and FF from Jenkins server.
After raising a concern they placed a chrome binary in E drive .( E:\GC Local\GoogleChrome).But Chrome is not installed anywhere
I am facing issues to resolve this.
Do anyone guide here ?
Code I used :
if ("chrome".equals(browser))
{
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")
+ "\\src\\test\\resources\\drivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
options.addArguments("--start-maximized");
driver = new ChromeDriver(options);
}
Will it work for you ?
ChromeOptions options = new ChromeOptions();
options.setBinary("E:\\GC Local\\GoogleChrome");
I understand that in homepath \app data chrome should be installed by default to run chrome tests. In my case , there is no chrome istalled in homepath-app but in E drive
When I used the below code :
ChromeOptions options = new ChromeOptions();
options.setBinary("E:\\GCLocal\\GoogleChrome\\GoogleChromePortable.exe");
// System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\Browsers\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")
+ "\\src\\test\\resources\\drivers\\chromedriver.exe");
driver = new ChromeDriver(options);
I am getting getting the following :
T E S T S
Running TestSuite
Browser :chrome
Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 45594
Only local connections are allowed.
Error in initializing the Test .Details :-
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 62.74 seconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'WHIS2002', ip: '10.192.129.112', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: org.openqa.selenium.chrome.ChromeDriver
./TestReport.html
The above approach is correct. My issue was that portable-chrome binary refused to open due to some issues in server .code was fine.
This happened because of portable chrome binary performance issues which I solved like this :
Google Chrome Portable may run slowly from some flash drives. You can speed this up by copying GoogleChromePortable.ini from the GoogleChromePortable\Other\Source directory to the GoogleChromePortable directory and editing it to set RunLocally=true. If you do so, be sure to allow Google Chrome Portable time to copy your profile back after shutting it down. Of course, there are privacy implications to copying your personal data locally to a PC not under your control.
Thanks

AWS appium ios test always fail

I am implementing aws automation testing using appium junit.
i am trying to run my testing script on aws device farm, my test script is working fine on simulator but its failing on aws devices. error does not describes the problem correctly.
Whenever i run my script on aws devices it gives me following error.
when i see the video, application was successfully launched and then nothing happens on the screen. i can see first popup that asks to allow push notifications and then after popover gets dismiss nothing happens.
failed: An error occurred while executing user supplied JavaScript.
(WARNING: The server did not provide any stacktrace information) Command
duration or timeout: 1.48 seconds Build info: version: '2.53.0', revision:
'35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'ip-172-31-13-65', ip: '172.31.13.65', os.name: 'Linux',
os.arch: 'amd64', os.version: '3.13.0-53-generic', java.version:
'1.8.0_65' Driver info: io.appium.java_client.ios.IOSDriver Capabilities
[{networkConnectionEnabled=false, desired={}, warnings={},
webStorageEnabled=false, locationContextEnabled=false, browserName=iOS,
takesScreenshot=true, javascriptEnabled=true, databaseEnabled=false,
platform=MAC}] Session ID: ca42e475-f253-40ed-a143-fef52146f655
and here is my java appium test script
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.1");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 5s");
capabilities.setCapability(CapabilityType.BROWSER_NAME, MobilePlatform.IOS);
capabilities.setCapability("autoAcceptAlerts", true);
capabilities.setCapability("showIOSLog", true);
capabilities.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, true);
String path = "/Users/home/Desktop/";
File app;
app = new File(path,"projectapp.ipa");
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
URL url =new URL("http://127.0.0.1:4723/wd/hub");
driver = new IOSDriver<WebElement>(url, capabilities);
i posted a question on aws forums no one awsering.
https://forums.aws.amazon.com/thread.jspa?threadID=247887
Don't set any DesiredCapabilities except for the URL. Resources to assist further are:
The Appium Developer Guide
AWS Device Farm sample Appium tests
Step-by-step to construct Appium tests
If you need specific assistance, please open a support case with AWS or post your issue on the AWS Device Farm forum and we can assist further.

Appium error : A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT) [duplicate]

This question already has answers here:
A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT)
(3 answers)
Closed 7 years ago.
Code from eclipse :
public class desiredcapabilities {
#Test
public void test() throws IOException {
File appDir = new File("src");
File app = new File(appDir,"bookMyShow-ucb.apk");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
//cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
cap.setCapability(MobileCapabilityType.APP, app.getCanonicalPath());
AndroidDriver Driver = new AndroidDriver(new URL("http://127.0.0.1:4724/wd/hub"),cap);
}
}
Appium Log :
Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4724 --session-override --platform-name Android --platform-version 23 --automation-name Appium --log-no-color
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
info: Appium REST http interface listener started on 127.0.0.1:4724
info: [debug] Non-default server args: {"address":"127.0.0.1","port":4724,"sessionOverride":true,"logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"C:\Users\sahil\workspace\intro\src\bookMyShow-ucb.apk","platformName":"Android","deviceName":"Android Emulator"}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.7.0_79)
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: C:\Users\sahil\workspace\intro\src\bookMyShow-ucb.apk
info: [debug] Creating new appium session 16b1787e-64bd-4bc5-b009-a0a518730ae0
error: Failed to start an Appium session, err was: Error: 'java -version' failed. Error: spawn ENOENT
info: Starting android appium
info: [debug] Getting Java version
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Error: 'java -version' failed. Error: spawn ENOENT
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:1057:17)
at exithandler (child_process.js:633:7)
at ChildProcess.errorhandler (child_process.js:649:5)
at ChildProcess.EventEmitter.emit (events.js:95:17)
at Process.ChildProcess._handle.onexit (child_process.js:795:12)
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT)","origValue":"'java -version' failed. Error: spawn ENOENT"},"sessionId":null}
info: <-- POST /wd/hub/session 500 181.826 ms - 208
Upgrade your node click here
Should work
Looks like your node version is less than the required for Appium 1.4.13.
automation-name Appium --log-no-color warn: Appium support for versions of node < 0.12
Check your node version like this:
node --version v0.12.4

Appium sample calculator test fails with ERROR: no dump file specified

I'm trying to run a sample test for a native Calculator app on a real Android 4.1.2 device. I'm using Appium(run as admin) on Windows, Selendroid and Eclipse.
My sample code is
#BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "");
capabilities.setCapability("automationName", "Selendroid");
capabilities.setCapability("platformVersion", "4.1.2");
capabilities.setCapability("deviceName","0123456789ABCDEF");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity","com.android.calculator2.Calculator");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
From what i have found on different forums and resources, it is possible to refer to the necessary application only by its package name and the launcher activity(without providing the .apk). However, for some reason Appium fails when not provided with the dump. The log of the failure is
> Checking if an update is available
> Update not available
> Starting Node Server
> info: Welcome to Appium v1.3.7 (REV 72fbfaa116d3d9f6a862600ee99cf02f6d0e2182)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"16","automationName":"Selendroid"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.android.calculator2","app":"Calculator.apk","appActivity":"com.android.calculator2.Calculator","BROWSER_NAME":"Chrome","platformVersion":"4.1.2","automationName":"Selendroid","platformName":"Android","deviceName":"0123456789ABCDEF"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.6 (java 1.5)
> info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : BROWSER_NAME
> info: [debug] App is an Android package, will attempt to run on device
> info: [debug] Creating new appium session 9942d26b-d1c1-43c8-9c6b-a9c4382d5ac9
> info: [debug] Starting selendroid server
> info: [debug] Getting Java version
> info: Java version is: 1.8.0_45
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from D:\Android\android-sdk\platform-tools\adb.exe
> info: [debug] Checking whether selendroid is built yet
> info: [debug] Selendroid server exists!
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device 0123456789ABCDEF
> info: [debug] Setting device id to 0123456789ABCDEF
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe -s 0123456789ABCDEF wait-for-device
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe -s 0123456789ABCDEF shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Checking whether aapt is present
> info: [debug] Using aapt from D:\Android\android-sdk\build-tools\22.0.1\aapt.exe
> info: [debug] Checking if has internet permission from manifest.
> info: [debug] executing cmd: D:\Android\android-sdk\build-tools\22.0.1\aapt.exe dump badging
> warn: ERROR: no dump file specified
>
> error: Failed to start an Appium session, err was: Error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified
>
> info: [debug] Cleaning up appium session
> info: [debug] Error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified
>
> at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1661:19
> at ChildProcess.exithandler (child_process.js:641:7)
> at ChildProcess.EventEmitter.emit (events.js:98:17)
> at maybeClose (child_process.js:743:16)
> at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified\r\n)","origValue":"hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified\r\n"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 635.247 ms - 318
Is there a way around this?
This code works on my Android device. I able to launch the calculator app w/o path to apk.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.1.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "my_device_name");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("device", "Android");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
serverAddress = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AndroidDriver(serverAddress, capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Here is what i was able to figure out:
Please note that I'm running Android 4.1.2 and have to use Selendroid
Selendroid requires the <uses-permission android:name="android.**permission.INTERNET"/> permission for the app
What i guess here is that it then uses aapt to parse the .apk file, because
Once i provide the .apk file extracted from the phone, it actually passes on to the next step where it parses the manifest and looks for the permission
So to sum up: if i'm using Selendroid, i have to provide .apk and my .apk has to have Internet permission. That is why Calculator test won't work here.
I think the problem will be solved if we rebuild the apk. I faced this issue in the past and I was able to get over it after rebuilding the apk.
Regards
Jnaneswar

Categories

Resources