I'm trying to run simple RSpec test on real Android device using Appium. My config is:
apk = {
device: :android,
app_path: *path_to_apk*,
app_package: *app_package*,
app_activity: '.Start'
}
Then I'm starting driver by:
Appium::Driver.new(apk).start_driver
Script fails with error:
Selenium::WebDriver::Error::WebDriverError: Parameter 'appActivity' is
required for launching application
I tried to debug by steps and found out, that in Selenium::WebDriver::Remote::Http::Default inside request method script sends post request with path: "/wd/hub/session" and body: {"desiredCapabilities":{"platform":"OS X 10.9","platformName":"android","name":"Ruby Console iOS Appium","device-orientation":"portrait","app":*path_to_apk*}}. The response is HTTPInternalServerError object with body:
"{ "status": 33, "value": {
"message": "A new session could not be created. (Original error: Parameter 'appActivity' is required for launching application)",
"origValue": "Parameter 'appActivity' is required for launching application" }, "sessionId": null }"
I can't understand what's the problem and find any solutions in google. Maybe value of 'app_package' parameter is wrong? So my second question is how can I get it?
P.S. Before all, appium was run in terminal by command appium & and started successfully
How to get app package?
Answer: Open 'Dev Tools' in emulator/device, then go to package browser then select your application , there you will get the app package along with available activities.
What is the problem with your code:
Ensure to include these stuffs:
platformName: 'Android',
appActivity: '.activity_name',
appPackage: 'package_name'
Related
I have an app that I build on CI using fastlane and I publish on HockeyApp.
I'm already accessing the build on AppCenter and everything is fine.
Now, I want to replace the call to the hockey plugin in the fastfile with a call to appcenter_upload.
The appcenter_upload asks me to define owner_name and app_name.
What I have seen is that these values are then used to build a URI:
https://appcenter.ms/orgs/{owner_name}/apps/{app_name}
When I open the app in AppCenter I can read that parts of the URI.
https://appcenter.ms/orgs/mobile-XXXX/apps/MyApp-Name
I tried to use
owner_name=mobile-XXXX
app_name=MyApp-Name
This was the code with hockey-app
hockey(
api_token: HOCKEYAPP_TOKEN,
apk: "path/to/apk",
notes: notes,
status: "2",
notes_type: "1",
teams: team,
commit_sha: `git rev-parse HEAD`.strip,
strategy: "add"
)
This is the code with appcenter_upload
ENV["APPCENTER_DISTRIBUTE_RELEASE_NOTES_CLIPPING"] = notes
appcenter_upload(
owner_name: "mobile-XXX",
app_name: "MyApp-Name,
api_token: HOCKEYAPP_TOKEN,
apk: "path/to/apk",
group: team
)
I was expecting this to be enough to publish directly in appcenter but the appcenter_plugin tells me that the app can't be found and asks me whether I want to create a new one.
I don't want to create another one.
This is the message I get:
Error 401: {"message"=>"12345678-abcd-ef01-994a-0123456789ab", "statusCode"=>401, "code"=>"Unauthorized"}
App with name MyApp-Name not found, create one? (y/n)
I am trying to automate android apps using python (or possibly ruby), by linking into the provided UIAutomator in the android SDK.
Right now I am trying to use a Python tool here, but I am having issues connecting (getting TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Code snipped of what i am trying to do with the Python tool:
def print_info():
print('Getting info...')
d = ui.Device('SERIAL_NUMBER', adb_server_host='192.168.1.20', adb_server_port='5037')
print(d.info)
Is there something wrong with how I am trying to send commands? Alternatively, is there a better ruby/python tool for testing android devices?
Update I am now using the Appium library Ruby gem to test. Got applications to launch, however things like tapping the screen result in this error
assert_ok': A session is either terminated or not started
(Selenium::WebDriver::Error::NoSuchDriverError)`
This is the code
desired_caps = {
caps: {
appiumVersion: '1.6.5',
platformName: 'Android',
platformVersion: '4.4',
browserName: '',
deviceName: 'DEVICE_SERIAL',
app: 'APK',
appActivity: 'mainactivity',
appWaitDuration: '60000', # wait a minute (set to 20000 by default)
clearSystemFiles: 'true'
},
appium_lib: {
sauce_username: nil,
sauce_access_key: nil
}
}
$driver = Appium::Driver.new(desired_caps)
$driver.start_driver
sleep(60) # wait a minute for app to fully load, before tring to tap anything
touch_action = Appium::TouchAction.new
touch_action.press(x: 243, y: 288).wait(5).release.perform
touch_action.press(x: 311, y: 165).wait(5).release.perform
This is how I do it for an emulator
app_path = File.absolute_path('automateme.apk', 'data')
caps = {
:platformName => "android",
:deviceName => "android",
:app => app_path,
:noReset => 'true',
:newCommandTimeout => "30"
}
#driver = Appium::Driver.new(:caps => caps).start_driver
try this and let me know if it helps... :)
There is an one good mobile test automation tool available - Appium.
Currently I have been using ruby,appium,cucumber,selenium webdriver for android automation. I am suggesting that you will try to use Appium tool for mobile automation. below is important link,
http://www.software-testing-tutorials-automation.com/2015/09/appium-tutorials.html
https://community.perfectomobile.com/posts/1103155-ruby-example-for-appium-android
http://appium.io/slate/en/tutorial/android.html?ruby#troubleshooting
following is the example to start
require 'appium_lib'
desired_caps = {
caps: { appiumVersion: '1.6.0',
platformName: 'Android',
platformVersion: '4.4.2',
browserName: '',
deviceName: 'Samsung Galaxy S4 Emulator',
app: 'D:\Workspace\android-sample-app.apk',
name: 'Ruby Appium Sauce example'
} }
driver = Appium::Driver.new(desired_caps)
puts driver
begin
driver.start_driver
rescue Exception => e
puts e
end
driver.first_textfield.send_key 10
driver.last_textfield.send_key 20
driver.first_button.click
driver.driver_quit
download "android-sample-app.apk" and put in any path and also set this path
in desired_caps.
Thanks,
Kapil Chothe
I am trying to use Protractor tests already working nice on PC to hybrid apps thanks to Appium.
As you guess there is a failure that ruin the chain and no way to find help on google.
This problem is quite hard because there is many software engaged so let me list them :
• Gulp (classic server that launch commands)
• Protractor (test language running over webdriver)
• Phonegap (compile website to app ex: .apk)
• Appium (intermediate server that control mobile device)
• Real device (debug-mode: on)
The process is almost working, I mean the apk is well installed, the application start and after 10 sec waiting, instead of starting the test, it crash/ignore the app.
I present here two scenario because I am not sure which configuration is the good one for my setup.
I leave the details under but in short: first case the app.apk is installed but ignored, and in the other apk start but crash (~3sec later)
Here is Gulp start command :
gulp.task('appium', ['webdriver_update'], function (cb) {
return gulp.src(['packages/custom/*/public/tests/e2e/*.spec.js']).pipe(protractor({
configFile: __dirname + '/../protractor.appium.conf.js',
args: ['--baseUrl', 'http://10.56.160.74:3000'] //My Local IP: Website Port
})).on('error', function (e) {
console.log(e);
});
});
Here is my Protractor/Appium config :
exports.config = {
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4723/wd/hub',
capabilities: {
fullReset: true,
browserName: 'android',
deviceName: "Galaxy Note S3",
platformName: "Android",
platformVersion: "5.1.1",
app: "C:/Projet/Spherea/appca/packages/custom/appca/public/apk/appca.apk",
'app-package': 'com.spherea.appca',
'app-captivity': 'MainActivity',
autoWebview: true //<= On/Off change the scenario
},
onPrepare: function () {
var wd = require('wd'),
protractor = require('gulp-protractor').protractor,
wdBridge = require('wd-bridge')(protractor, wd);
wdBridge.initFromProtractor(exports.config);
}
};
When autoWebview = true :
The application freeze at start, and after 10 sec of failing starting protractor tests, Appium give up and launch the browser and deal with test there, which is NOT what I need.
Error when autoWebview = false :
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.
[launcher] Error: UnknownError: Not yet implemented. Please help us: http://appium.io/get-involved.html
at new bot.Error (C:\Projet\Spherea\appca\node_modules\gulp-protractor\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108:18)
at Object.bot.response.checkResponse (C:\Projet\Spherea\appca\node_modules\gulp-protractor\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\response.js:
109:9)
at C:\Projet\Spherea\appca\node_modules\gulp-protractor\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\webdriver.js:379:20
at [object Object].promise.ControlFlow.runInFrame_ (C:/Projet/Spherea/appca/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/goog
/../webdriver/promise.js:1857:20)
at [object Object].goog.defineClass.notify (C:/Projet/Spherea/appca/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webd
river/promise.js:2448:25)
at [object Object].promise.Promise.notify_ (C:/Projet/Spherea/appca/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webd
river/promise.js:564:12)
at Array.forEach (native)
at [object Object].promise.Promise.notifyAll_ (C:/Projet/Spherea/appca/node_modules/gulp-protractor/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../w
ebdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (C:\Projet\Spherea\appca\node_modules\gulp-protractor\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:13
0:15)
at runMicrotasksCallback (node.js:337:7)
[launcher] Process exited with error code 100
I hope someone can help me, I already wasted 10 days trying this and I'm now out of idea to solve this issue.
i have tried the same, conclusion is protractor with jasmine/cucumber has no support for native apps it only supports web automation for desktop & web & hybrid apps automation for mobile.
you can find the responses in below link
https://github.com/angular/protractor/issues/1798
Thanks
I'm trying to run some nightwatch tests in my android emulator. My configuration for android in my nightwatch.json looks like follows:
"android" : {
"selenium_port" : 9515,
"selenium_host" : "localhost",
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"androidPackage": "com.android.chrome",
"args": ["--disable-web-security", "--no-first-run"]
}
}
}
The test runs without issues. But I'm always seeing the "First Run Experience" page in each run. Also it is always checking the SSL certificates event when I have set the --disable-web-security flag. Those flags work with Desktop version of Chrome.
I guess this is not an issue with Nightwatch itself. So maybe other implementations of selenium+android would work.
Addtionally, I'm not allowed to use Appium.
Do you know what I'm doing wrong? Have you faced the same issue?
I'm not sure about this spesific case, but passing args to Chrome via the conf file should not include the '--' in the beginning.
So, args: ["some-option"] instead of args: ["--some-option"] makes the difference in my setups.
You can use the below configuration for mobile emulation in the Chrome web browser:
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"mobileEmulation": { "deviceName" : "Galaxy S5"},
"args": [
"disable-web-security"
]
}
},
#BeforeSuite
public void setUp() throws Exception {
//Start selendroid-standalone during test
SelendroidConfiguration config = new SelendroidConfiguration();
// Add the selendroid-test-app to the standalone server
config.addSupportedApp("F:\\Seleandriod\\OFCOne.apk");
//start the standalone server
SelendroidLauncher selendroidServer = new SelendroidLauncher(config);
selendroidServer.launchSelendroid();
// Create the selendroid capabilities
SelendroidCapabilities capa = new SelendroidCapabilities();
// Specify to use selendroid's test app
capa.setAut("io.selendroid.androiddriver:0.11.0");
// Specify to use the Android device API 19
capa.setPlatformVersion(DeviceTargetPlatform.ANDROID19);
// Don't request simulator, use real device
capa.setEmulator(false);
//capa.wait(10000000);
// Create instance of Selendroid Driver
driver = new SelendroidDriver(capa);
We are using HYBRID cordova app,
the execution fails at the line where SelendroidDriver(capa); is getting initialized with the following error:
"The requested application under test is not configured in selendroid
server"
We are using selendroid-standalone-0.11.0-with-dependencies version.
We have run on command line:
java -jar selendroid-standalone-0.11.0-with-dependencies -aut OFCOne.apk
Its giving following error:
"SEVERE: Error building server: The base package name of the apk
resigned-OFCOne.apk cannot be extracted."
please give me some suggestion to resolve this error.
capa.setAut("io.selendroid.androiddriver:0.11.0");
Here should be your appId not the appId for the selendroid. Most probably your appId will be your_app_package_name:version. Using
http://localhost:4444/wd/hub/status you can get your appId and the first appId is not your appId it is the appId for selendroid server driver app being installed on your device. The second appId will be your appId. Please use it instead what you have used in he above line of code.
I just have met the same issue. The reason is wrong path to your .apk file. And I not sure about absolute path, I used relative path
config.addSupportedApp("src/resources/myapp.apk");
Hope this help!