How do I run an Intern test against iOS and android on BrowserStack? - intern

What should I put in the environments block of the intern config file to test iOS and android? According to https://www.browserstack.com/automate/capabilities it should be as simple as
environments: [
{ browserName: "iPad" },
{ browserName: "android" }
],
However, that doesn't work. Nor does this:
environments: [
{ os: "ios", browser: "iPad", device: "iPad 4th Gen" },
{ os: "android", browser: "Android" }
],

This question is very old so things have likely moved along.
But for completeness, it's possible to run mobile browsers with the following setup:
environments: [
{ platform: "MAC", browserName: "iPhone", device: "iPhone 5" }
]

Related

Parallel run in Chrome

I am trying to implement parallel test execution in Chrome to reduce the test execution time. The framework being used is protractor-cucumber framework with Node JS. The webdriver instances open up in two tabs rather than two separate windows of Chrome.
Used the multicapabilities in the config file to set testsharding as true and maxinstances as 2:
multiCapabilities: [
{
shardTestFiles: true,
maxInstances: 4,
browserName: chrome,
specs: ['*.spec.js']
},
Chrome is opening 2 tabs instead of windows and the tests are not getting distributed across the tabs.
Full config as requested
const path = require("path");
const jsonReports = process.cwd() + "/reports/json";
exports.config = {
seleniumAddress: "http://localhost:4444/wd/hub",
baseUrl: "https://www.google.co.uk",
multiCapabilities: [
{
browserName: "chrome",
shardTestFiles: true,
maxInstances: 2
}
],
framework: "custom",
frameworkPath: require.resolve("protractor-cucumber-framework"),
specs: ["../features/*.feature"],
onPrepare: function() {
browser.ignoreSynchronization = true;
browser.manage().window().maximize();
Reporter.createDirectory(jsonReports);
},
cucumberOpts: {
strict: true,
format: 'json:./reports/json/cucumber_report.json',
require: ["../stepDefinitions/*.js"],
tags: "(#AllureScenario or #CucumberScenario or #ProtractorScenario) and (not #DatabaseTest)" //
},
onComplete: function () {
}
};

Is there any way to run webdriver.io selenium tests against a chrome extension?

I'm thinking something along the lines of
capabilities: [
{
maxInstances: 1,
browser: "Chrome",
name: "Chrome"
},
{
maxInstances: 1,
browser: "Chrome",
options: "myIeExtension",
name: "IE"
}
]
The name bit is optional but would be really handy.
Edit:
Currently I've got
const fs = require('fs');
function encode(file) {
const stream = fs.readFileSync(file);
return Buffer.from(stream).toString('base64');
}
capabilities: [
{
maxInstances: 1,
browserName: 'chrome',
chromeOptions: { extensions: [encode('path_to_my_crx_file/my_extension.crx')] },
}
],
which works, but each time I run the selenium tests I have to go through the extension intro - enter email, password, select this that and launch. Is there any way to get round having to have selenium enter all these values as part of the test?
So you can do it as above specifying the path to the chrome extension in ChromeOptions. However you have to set it up every time.
Alternatively just use the default profile:
capabilities: [
{
maxInstances: 1,
browserName: 'chrome',
chromeOptions: { args: ['user-data-dir=/home/<username>/.config/google-chrome'] },
},
You won't have to set up the extension every time you use it, you just have to do it once and then it'll just be there.

Uable to access to localhost:8080 after upgrading NodeJS to 8.1.4

Our development group is starting a new React project and I have been trying to use Nightwatch + Selenium to do the e2e testing. I got it to work when running everything using NodeJS 6.9.4. Now we have been forced to upgrade NodeJS to 8.1.4 and I'm facing an issue that is stopping me to proceed with testing. When using Selenium with Chrome as browser, I keep getting a 'This site can't be reached' message (but the page can be accessed if I open manually a Chrome window. Any idea what can be going on? Here you have the test result log and my nightwatch.conf.js
Test Result:
INFO Request: GET /wd/hub/session/fc36e7a7-4909-4dfd-a853-6d769accb085/element/0/text
- data:
- headers: {"Accept":"application/json"}
INFO Response 200 GET /wd/hub/session/fc36e7a7-4909-4dfd-a853-6d769accb085/element/0/text (16ms) { state: 'success',
sessionId: 'fc36e7a7-4909-4dfd-a853-6d769accb085',
hCode: 972983271,
value: 'This site can’t be reached',
class: 'org.openqa.selenium.remote.Response',
status: 0 }
Nightwatch Conf
const SCREENSHOT_PATH = "./screenshots/";
const BIN_PATH = './node_modules/nightwatch/bin/';
``
// we use a nightwatch.conf.js file so we can include comments and helper functions
module.exports = {
"src_folders": [
"__tests__/e2e/specs"// Where you are storing your Nightwatch e2e tests
],
"output_folder": "./reports", // reports (test outcome) output by nightwatch
"selenium": { // downloaded by selenium-download module (see readme)
"start_process": false, // tells nightwatch to start/stop the selenium process
"server_path": "./node_modules/nightwatch/bin/selenium.jar",
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": { // chromedriver is downloaded by selenium-download (see readme)
"webdriver.chrome.driver" : "./node_modules/nightwatch/bin/chromedriver"
}
},
"test_settings": {
"default": {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
},
"globals": {
"waitForConditionTimeout": 5000 // sometimes internet is slow so wait.
},
"desiredCapabilities": { // use Chrome as the default browser for tests
"browserName": "chrome",
"javascriptEnabled": true, // turn off to test progressive enhancement
"chromeOptions" : {
"args": ['--disable-web-security', 'no-sandbox', '--disable-async-dns']
}
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true, // turn off to test progressive enhancement
"chromeOptions" : {
"args": ['--disable-web-security', 'no-sandbox', '--disable-async-dns']
}
}
}
},
"params": {
"baseUrl": "http://localhost:8080/",
}
}
Sorry for having the files attached instead of expanded on the comment but tho I have been using StackOverflow for a long time, this is my first request. StackOverflow
Apparently my localhost is not visible to the Selenium Chrome that is running. Needed to make my localhost accesible from outside my machine in order to get this running

Launching Multiple Browser and running the URL's

Protractor Version: 5.1.1
NPM : 3.10.10`
Browsers:Microsoft Edge(Ver 14), Safari(Ver 5.1.7), IE Ver11.0, firefox(ver 46.0) and Opera(Ver 43.0) Ver11.0, firefox(ver 46.0) and O: Win 10 43.0)
Operating System and Version : Win 10
Conf.js
//Code changes for multiCapabilities
multiCapabilities: [
{
browserName: 'chrome',
},
{
browserName: 'firefox',
},
{
browserName: 'MicrosoftEdge',
},
{
browserName: 'Opera',
},
{
browserName: 'Internet Explorer',
},
{
browserName: 'safari',
}, ],
Protractor.js
'webDriverUpdate': {
'browsers': ['chrome']
},
'webDriverUpdate': {
'browsers': ['Microsoft Edge']
},
'webDriverUpdate': {
'browsers': ['safari']
},
'webDriverUpdate': {
'browsers': ['Internet Explorer']
},
'webDriverUpdate': {
'browsers': ['firefox']
},
'webDriverUpdate': {
'browsers': ['Opera']
},
'webDriverStart': {
'args': ['--chrome']
},
'webDriverStart': {
'args': ['--Microsoft Edge']
},
'webDriverStart': {
'args': ['--Opera']
},
'webDriverStart': {
'args': ['--safari']
},
'webDriverStart': {
'args': ['--Internet Explorer']
},
'webDriverStart': {
'args': ['--firefox']
},
Issue: It is unable to launch Firefox,Safari,Microsoft Edge and Internet explorer though the drivers are downloaded in specific path
based on the browser versions.
The following is the error message which is throwing in the console for all the browser
Error message
\node_modules\gulp-angular-protractor\node_modules\gulp-protractor\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:108
var template = new Error(this.message);
^
UnknownError: The best matching driver provider org.openqa.selenium.edge.EdgeDriver can't create a new driver instance
for Capabilities [{count=1, browserName=Microsoft Edge
When I run the scripts using single browsers the same error message is getting displayed.

angular-phonecat tutorial: protractor.js unexpected behavior under Chrome Canary

I’m setting things up in order to run the angular-phonecat tutorial using Chrome Canary under OS X as a testing browser.
I got everything working, except when I input npm run protractor the e2e test runs on SAFARI of all browsers, despite the fact that I’ve specified Chrome Canary as the browser name in the protractor-conf.js file. Here’s the code:
exports.config = {
allScriptsTimeout: 11000,
specs: [
'e2e/*.js'
],
capabilities: {
'browserName': 'ChromeCanary',
'ChromeOptions': {
'binary': '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
}
},
chromeOnly: false,
baseUrl: 'http://localhost:8000/',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
When I set chromeOnly: true, the test returns an ELIFECYCLE error. I find this very awkward since the same browser name is specified in the Karma configuration file and the unit test runs on Canary as expected. Here’s the karma.conf.js code:
module.exports = function(config){
config.set({
basePath : '../',
files : [
'app/bower_components/angular/angular.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-resource/angular-resource.js',
'app/bower_components/angular-animate/angular-animate.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/js/**/*.js',
'test/unit/**/*.js'
],
autoWatch : true,
frameworks: ['jasmine'],
browsers : ['ChromeCanary'],
plugins : [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine'
],
junitReporter : {
outputFile: 'test_out/unit.xml',
suite: 'unit'
}
});
};
Two questions:
What could be causing this behavior?
What else could I tinker with to get the e2e test to run on Canary?
I was able to get this working with Chrome Canary by simply reusing the Chrome browserName but providing an alternate binary path. Here's the snippet that will work for your example above.
capabilities: {
'browserName': 'Chrome',
'ChromeOptions': {
'binary': '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'
}
Probably easier to abstract this into a separate browsers.js file so you can use both canary and chrome like this.
exports.chrome = {
name: 'Chrome',
browserName: 'chrome',
chromeOptions: {
'args': [
'incognito',
'disable-extensions',
'start-maximized',
'enable-crash-reporter-for-testing'
]
}
};
exports.chromeCanary = {
name: 'ChromeCanary',
browserName: 'chrome',
chromeOptions: {
'binary': 'C:/Users/gattridg/AppData/Local/Google/Chrome SxS/Application/chrome.exe',
'args': [
'incognito',
'disable-extensions',
'start-maximized',
'enable-crash-reporter-for-testing'
]
}
};
Then in your protractor.conf.js
var browsers = require('./browsers'),
multiCapabilities: [
browsers.chrome
browsers.chromeCanary
],

Resources