Selenium grid with appium android and protractor configuration - android

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?

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.

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

Nightwatch/Chromedriver with Android. Arguments for chrome are completely ignored

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"
]
}
},

Couldn't run protractor scripts on Android emulator

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?

Categories

Resources