Couldn't run protractor scripts on Android emulator - android

I want to execute protractor script on android emulator using Appium, but the problem emulator isn't launched when i tap: " protractor conf.js " on terminal. The test is passed in chrome browser of windows instead of browser in the emulator. Shall i add other capabilities ? or i should change the base url ?
// An example configuration file.
exports.config = {
seleniumAddress: 'http://localhost:4733/wd/hub',
specs: ['todo-spec.js'],
directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome',
'device': 'android',
'deviceName' : '5554:AndroidDevice',
device: 'android',
'appium-version': "1.4.16.1",
deviceName : '5554:AndroidDevice',
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
baseUrl: 'http://127.0.0.1:5858',
// Spec patterns are relative to the current working directly when
// protractor is called.
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
//------------------todo-spec.js----------------------------------------
describe('angularjs homepage todo list', function() {
it('should add a todo', function() {
browser.get('https://angularjs.org');
element(by.model('todoList.todoText')).sendKeys('write first protractor test');
element(by.css('[value="add"]')).click();
var todoList = element.all(by.repeater('todo in todoList.todos'));
expect(todoList.count()).toEqual(3);
expect(todoList.get(2).getText()).toEqual('write first protractor test');
// You wrote your first test, cross it off the list
todoList.get(2).element(by.css('input')).click();
var completedAmount = element.all(by.css('.done-true'));
expect(completedAmount.count()).toEqual(2);
});
});

Remove the directConnect to allow it to use the selenium server:
// An example configuration file.
exports.config = {
seleniumAddress: 'http://localhost:4733/wd/hub',
specs: ['todo-spec.js'],
directConnect: true, <-- remove this line
...
}
A related topic that should help clearing things up:
Difference running Protractor with/without Selenium?

Related

How to configure CodeceptJs to work with appium for website testing on mobile device

hope you are well, I am trying to configure Codeceptjs to work with Appium, for proof of concept I only need the configuration to naviagte to a website amazon.com for example and create an account.
I have been reading the appium documentation and the following is stated for Chrome on Andriod 'For web tests, to automate Chrome instead of your own application, leave the app capability empty and instead set the browserName capability to Chrome.' Can be found here https://appium.io/docs/en/drivers/android-uiautomator2/
So I have left 'app' blank as it tells me to do, but every time i run my test I get the following error
Error: Failed to create session.
An unknown server-side error occurred while processing the command. Original error: 'app' option is required for reinstall
My config is as follows, I have been changing settings for the past few days with no luck, any help or pointing me in the right direction would be really appreciated, thank you in advance.
```exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
// WebDriver: {
// url: 'https',
//browser: 'chrome'
// },
Appium: {
path: '/wd/hub',
port: 4723,
platform: 'Android',
url: 'https://www.test.com',
desiredCapabilities:{
deviceName: "emulator-5554",
platformVersion: "11.0",
platformName: 'Android',
deviceName: 'Android Emulator',
automationName: 'UIAutomator2',
browserName: 'Chrome'
}
}
},
include: {
I: './steps_file.js'
},
bootstrap: null,
mocha: {},
name: 'CodeceptJS',
plugins: {
wdio: {
enabled: true,
services: ['selenium-standalone']
},
pauseOnFail: {},
retryFailedStep: {
enabled: true
},
tryTo: {
enabled: true
},
screenshotOnFail: {
enabled: true
}
}
} ```
Configuration issue on my end, incompatable chrome browser version to to the chrome driver, has been resloved with a simple appium command

Ionic3-Cordova-UWP : Ionic Storage doesn’t work when app is running

I have a problem with Ionic storage in my Ionic App for Windows (UWP app). I already tested and deployed my app for Android without any trouble.
Now I would like to generate an UWP app.
The app I’m developing is a workshop’s dashboard. The indicators change every day and I need to save them from one day to another. To do this I usethe storage module of Ionic.
When launching the command
$ionic serve
the app responds exactly as it should in the web browser (Firefox). From one launch to another my data are still there.
When I use
$ionic cordova run windows
the installation and launch steps of my app work fine. Every function of my app runs fine, but the call to storage (get and set) doesn’t work : when I close, and then reopen it as an autonomous application, I loose all data every time. It is the same when I run the app from Visual Studio.
Moreover, I write some console.log in the result of the promise and none of them is written in the Javascript console. It is like Windows does not recognize the command.
I tried with Visual Studio 2015 Update 3 and Visual Studio 2017, the result is identical. I followed the recommendation of Ionic Doc and add the target platform windows10 in the config.xml.
Does anyone have an idea of what I’m doing wrong ? Is there an incompatibility between Windows and Ionic ?
Thanks for any help.
Config :
Windows 10 64-bits
Ionic CLI: 3.19.1
Cordova CLI : 8.0.0
Node : v6.11.2
Visual Studio Community 2017 (15.5.27130.2036)
Extract of my code maPage.ts :
import { Storage } from '#ionic/storage';
export class maPage {
constructor(public storage: Storage) {
this.downloadData();
}
ionViewWillLeave()
{
this.saveData();
}
TabData = {
id: 0,
label: '',
Tab1: [],
Tab2: [],
attri1 : 0,
attri2: false
}
Param = {
Objet1: {NbObj1: 7},
Objet2: {NbObj2: 5}
}
saveData()
{
var Data: object;
Data =
{
TData: this.TabData,
TParam: this.Param
}
this.storage.set('Data', Data).then(_=> {
console.log('Backup done!');
}, error => {
console.log('erreur : ', JSON.stringify(error))
});
}
downloadData()
{
this.storage.ready().then(()=>{
console.log('storage ready');
this.storage.get('Data').then((val) => {
this.TabData = val.TData;
this.Param = val.TParam;
console.log('Récupération terminée !');
}).catch(erreur => {
console.log('La variable Data est vide ou n\'existe pas!');
console.log('erreur : ', JSON.stringify(erreur));
}).catch(err => {
console.log('storage not ready');
console.log('err : ', JSON.stringify(err));
});
}
}
On Windows platform, console.log is not supported. To do that, you should install cordova-plugin-console, or need to use alert function.
Regarding storage, I am suggesting you could use localstorage or cordova-sqlite-storage.

Selenium grid with appium android and protractor configuration

I've got a selenium grid with chrome, firefox and android node running
and I have this protractor configuration within an angular cli project:
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const {SpecReporter} = require('jasmine-spec-reporter');
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var screenshotReporter = new HtmlScreenshotReporter({
dest: 'target/screenshots',
filename: 'my-report.html'
});
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
multiCapabilities: [{
'browserName': 'chrome'
}, {
'browserName': 'firefox'
}, {
'browserName': 'android',
'platformName': 'Android',
'platformVersion': '7.1.1',
'deviceName': 'Nexus 5'
}],
// directConnect: true,
seleniumAddress: "http://localhost:4444/wd/hub",
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function () {
}
},
beforeLaunch: function () {
return new Promise(function (resolve) {
screenshotReporter.beforeLaunch(resolve);
});
},
onPrepare: function () {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
jasmine.getEnv().addReporter(screenshotReporter);
},
afterLaunch: function (exitCode) {
return new Promise(function (resolve) {
screenshotReporter.afterLaunch(resolve.bind(this, exitCode));
})
}
};
When I launch my ng e2e task, tests are running fine on firefox and chrome node. However, I've got this error coming from the android capability:
WebDriverError: An unknown server-side error occurred while processing the command. Original error: The desired capabilities must include either an app, appPackage or browserName
...
If I get it right the android webdriver asks me to include a browserName although I already provide it one. Does anyone have an idea?
the andriod capability in your protractor config file will failed to get any matched node for you. Because you use one wrong name and one wrong value in capability.
you use 'platformVersion', but on selenium gird is 'version'.
you set 'deviceName' to 'Nexus 5', but on selenium gird is 'nexus_5_7.1.1'
please change 'platformVersion' to 'version' and correct 'Nexus 5' to 'nexus_5_7.1.1' in your protractor config file, then try again.
My last concern is on your selenium grid the browserName is 'android', I'm not sure testing can open the browser.
In most case, we install Chrome on andriod device and set browserName to 'Chrome' when register device to selenium grid and in protractor config file.
I indeed not know 'andriod' represents which browser, the build-in browser bind with andriod OS?

Using Android UIAutomator in Python or Ruby

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

Appium/Protractor tests do not run on real device .APK

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

Categories

Resources