How I can start IE in 32bit mode in webdriver.io - node.js

I am running an WebDriver.io test using gulp-wdio npm pakage
on selenium-standalone
The Code that I run in gulp is:
gulp.task('e2e', function () {
return gulp.src('wdio.conf.js')
.pipe(wdio({
wdio: {
specs: './test/features/**/*.feature'
}
}));
});
And my wdio.conf.js define browsers this way:
capabilities: [
{
browserName: 'internet explorer',
version: 'ANY'
}
],
How ever the typing is very slow, i had found on the internet that running 32 bit version of the web-driver resolves the issue, how ever I can't find how to configure the capabilities or some other place to run the IE32 bit driver by default...
Any help will be appreciated #:-)

After 2 days of research I had found the solution !!!
There is a configuration file that need to be supplied to the selenium standalone
as shown in this Example
so our final setup is done in this way:
We have a configuration file called wdio.browsers.setup.js that contains the browsers setup:
module.exports = {
baseURL: 'https://selenium-release.storage.googleapis.com',
version: '3.3.1',
drivers: {
chrome: {
version: '2.29',
arch: process.arch,
// - Recent versions of the driver: https://sites.google.com/a/chromium.org/chromedriver/
baseURL: 'https://chromedriver.storage.googleapis.com'
},
ie: {
version: '3.0.0',
arch: 'ia32',
// - Recent versions of the driver: http://selenium-release.storage.googleapis.com/index.html
baseURL: 'https://selenium-release.storage.googleapis.com'
},
firefox: {
version: '0.15.0',
arch: process.arch,
baseURL: 'https://github.com/mozilla/geckodriver/releases/download'
}
}
};
and then inside wdio.conf.js we load it and assign to a special parameters
let browsersSetup = require('./wdio.browsers.setup');
exports.config = {
seleniumArgs: browsersSetup,
seleniumInstallArgs: browsersSetup,
After that all is working fine #:-)
Note: if you have your web-driver installed globally remove the global setup first it's located in:
C:\Users\%USERNAME%\AppData\Roaming\npm
Then you can run the local installation using:
./node_modules/.bin/selenium-standalone install --config=../../wdio.browsers.setup.js

Please find the below working solution for IE browser to install 32 bit:
services: ["selenium-standalone"],
seleniumArgs: {
drivers: {`enter code here`
ie: {
version: "3.4.0", // or whatever latest is
arch: "ia32", // forces use of 32 bit driver
baseURL: "https://selenium-release.storage.googleapis.com"
},
},
},
seleniumInstallArgs: {
drivers: {
ie: {
version: "3.4.0", // or whatever latest is
arch: "ia32", // forces use of 32 bit driver
baseURL: "https://selenium-release.storage.googleapis.com"
},
},
},

Related

How to configure Nightwatch.js with geckodriver to install metamask on browser startup

So we are trying to configure NightWatch so that the resulting opened firefox browser window, comes pre-installed with a extension (MetaMask) - so that tests can use Metamask to test out simple wallet transactions.
I'm fairly certain this is possible using geckodriver.
Our current nightwatch.conf.js file is:
const pathToGeckoDriver = require('geckodriver').path;
module.exports = {
src_folders: ['src/tests'],
page_objects_path: ['src/pages'],
custom_commands_path: ['src/custom-commands'],
webdriver: {
start_process: true,
server_path: pathToGeckoDriver,
},
test_settings: {
default: {
launch_url: 'https://some-website.com',
end_session_on_fail: false,
desiredCapabilities: {
browserName: 'firefox',
acceptInsecureCerts: true,
javascriptEnabled: true,
firefoxOptions: {
args: ['-profile', 'nightwatch'], // tried making a "nightwatch" profile for firefox and setting this profile at startup. no luck. :(
add_extension: ['metamask-10.2.2-an+fx.xpi'], // tried various versions of this line, no luck. :(
},
},
},
},
};
We have downloaded the extension XPI file and placed it in the same dir as the nightwatch.conf.js file.
Has anyone managed to get geckodriver to boot with an extension installed via Nightwatch config?

Error code 135, Error message Could not fingd update-config.json. Run webdriver-manager update to download the binaries

I am trying to execute my tests in nodejs using protractor.
Example protractor protractor.conf
When I run protractor protractor.conf, I get error Error code 135, Error message Could not fingd update-config.json. Run webdriver-manager update to download the binaries
I ran the following command but still get the above error message
webdriver-manager update -- proxy http://
protractor.conf.js
/*global jasmine */
var SpecReporter = require('jasmine-spec-reporter');
var TfsReporter = require('jasmine-tfs-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/tests/*spec.js'
],
capabilities: {
'browserName': 'chrome',
/*'browserName': 'phantomjs',
'phantomjs.binary.path': require('phantomjs-prebuilt').path,
'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG']*/
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
useAllAngular2AppRoots: false,
beforeLaunch: function() {
require('ts-node').register({
project: '../PartyAndIndustryDataMigration'
});
},
onPrepare: function() {
jasmine.getEnv().addReporter(new SpecReporter());
jasmine.getEnv().addReporter(new TfsReporter());
}
};
I'm not 100% sure (and cannot it check now), but shouldn't command look like that:
webdriver-manager update --proxy http:// (without space between -- and proxy)?
I guess chrome driver & update-config.json couldn't downloaded at the time of webdriver-manager update.
Just for verification go to
node_modules\protractor\node_modules\webdriver-manager\selenium\
location and look if everything downloaded properly?
If there is problem on downloading chrome driver you can check chrome-response.xml in same location for reason. One reason could be chrome driver website is in blacklisted or behind the proxy.
1.Open Command prompt or terminal.
2.Go to your project root directory.
3.Enter the below command and hit Enter key.
node node_modules/protractor/bin/webdriver-manager update
This command will update the WebDriver Manager.

Node JS + Grunt-sonar-runner + Code Coverage not showing

I created a REST service in node js and wrote the test cases using mocha. I have been able to generate the code coverage using istanbul and is working absolutely fine. Now my requirement is to show the code coverage using Sonar. The code compliance violations are getting listed as expected. But the code coverage is not getting generated in sonar. I doubt there is something wrong with the gruntfile.js configuration. Currently, I generate the code compliance violation by copying the source inside the grunt-sonar-runner folder within node_modules and execute grunt-sonar-runner. My current folder structure is as shown below :
<ProjectRoot>
|--server.js
|--[test]
|--|--serverTest.js
|--[node_modules]
|--|--[grunt-sonar-runner]
|--|--|--[src]
|--|--|--|--server.js
In the gruntfile.js,
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'test/*.js'
],
options: {
jshintrc: '.jshintrc'
}
},
// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp']
},
// Configuration to be run (and then tested).
sonarRunner: {
analysis: {
options: {
debug: true,
separator: '\n',
sonar: {
host: {
url: 'http://localhost:9000'
},
jdbc: {
url: 'jdbc:h2:tcp://localhost:9092/sonar',
username: 'sonar',
password: 'sonar'
},
projectKey: 'sonar:grunt-sonar-runner:0.1.0',
projectName: 'Grunt Sonar Runner',
projectVersion: '0.10',
sources: ['src'].join(','),
language: 'js',
sourceEncoding: 'UTF-8'
}
}
},
dryRun: {
options: {
dryRun: true,
debug: true,
separator: '\n',
sonar: {
host: {
url: 'http://localhost:9000'
},
jdbc: {
url: 'jdbc:mysql://localhost:3306/sonar',
username: 'sonar',
password: 'sonar'
},
projectKey: 'sonar:grunt-sonar-runner:0.1.0',
projectName: 'Grunt Sonar Runner',
projectVersion: '0.10',
sources: ['src'].join(','),
exclusions: '**/R.js'
}
}
}
},
// Unit tests.
mochaTest: {
test: {
options: {
reporter: 'spec'
},
src: ['test/**/*.js'],
}
}
});
we have two sections --> analysis and dryRun. What is this dryRun ?
Just outside that, we have a key called mochaTest.
While running mocha with istanbul, I am getting coverage reports generated in the project root inside a folder called coverage. Unfortunately it is not getting listed in sonar. Any help would be appreciated.
Thanks in Advance,
Noble
Just had to define a sonar-roject.properties in the project root folder. Inside that properties file, we can specify the relative path to the lcov.info generated by istanbul. After starting up the sonar qube server, just run sonar-runner (provided sonar runner is present in the system path). Sonar reports will be visible in sonar dashboard

Loading dependencies outside of the Intern directory when running tests through Selenium

I have a project where Intern unit tests are supposed to be in a different directory tree than the source code under test. Somewhat like this:
projectRoot
projectRoot/src
projectRoot/tests
projectRoot/tests/intern.js
projectRoot/tests/node_modules/intern
projectRoot/tests/MyTestSuite.js
In the Intern configuration file, I define an AMD package that uses relative paths with ../ to reach src from the unit test suites. Here's an example configuration:
define({
environments: [ { browserName: 'chrome', platform: 'WINDOWS' }],
webdriver: { host: 'localhost', port: 4444 },
useSauceConnect: false,
loader: {
packages: [
{ name: 'testSuites', location: '.' },
{ name: 'externalDep', location: '../src' }
]
},
suites: [ 'testSuites/MyTestSuite' ]
});
And a matching unit test suite
define([ "intern!tdd", "intern/chai!assert","externalDep/ExternalDep"],
function(tdd, assert, ExternalDep) {
tdd.suite("Suite that has external dependency", function() {
tdd.test("Test if external dependency is loaded correctly", function() {
assert(ExternalDep === "hello");
});
});
}
);
This works fine when tested directly in the browser (client.html) or node (client.js). When fired off through a Selenium Server (with runner.js), however, the client.html running in the browser started by Selenium can't find the external dependencies. In the above example, it tries to request ExternalDep at http://localhost:9000/__intern/src/ExternalDep.js, which is a 404 because the src directory is not within intern.
I suppose that if I put intern.js at the highest common super-directory of both the tests and the source code, it would work. But our project is currently set up in a way which makes that impractical. Is there a way for configuring sources that live beyond the location of the Intern config file, or did I just make a silly mistake?
Thanks!
There is no problem putting the tests in a different directory from the rest of the code, but projectRoot needs to be the working directory from which you start the runner, and you need to change your loader configuration to match.
So, instead of right now where you are starting Intern from projectRoot/tests like this:
…/projectRoot/tests$ ./.bin/intern-runner config=intern
you need to start it from projectRoot:
…/projectRoot$ ./tests/.bin/intern-runner config=tests/intern
…and change your loader configuration:
loader: {
packages: [
{ name: 'testSuites', location: 'tests' },
{ name: 'externalDep', location: 'src' }
]
},

Generating istanbul code coverage reports for jasmine tests run (via grunt) on a browserify bundle in phantomjs

The title says it all really. Despite trawling the internet I haven't found a single example of a solution to this problem.
Here are some near misses
https://github.com/amitayd/grunt-browserify-jasmine-node-example - grunt, browserify and jasmine
https://github.com/gotwarlost/istanbul/issues/59#issuecomment-18799734 - browserify and istanbul
Here is my in-progress code https://github.com/wheresrhys/on-guard/tree/browserify (note it's the 'browserify' branch - Gruntfile.js is a bit of a mess but will tidy it up shortly). My initial investigations using console.log indicate that somehow bundle.src.js is being loaded in the page but when the tests are run (and passed!) the code in bundle.src.js isn't being run, so I have a feeling it might be an aliasing problem... though one that's limited to phantomjs as when I open the specrunner in chrome the code is getting run.
I'm using grunt-browserify + browserify-istanbul + grunt-contrib-jasmine + grunt-template-jasmine-istanbul as solution. This solution has also excluded third party libraries when building source files using browserify.
Show the code first, I'll explain later,
grunt.initConfig({
browserify: {
// build specs using browserify
specs: {
src: ["spec/**/*Spec.js"],
dest: "spec/build/specs.js",
options: {
debug: true
}
},
// build source files using browserify and browserify-istanbul
dev: {
options: {
debug: true,
browserifyOptions: {
standalone: 'abc'
},
transform: [['browserify-istanbul', {
ignore: ['**/node_modules/**'], // ignore third party libs
defaultIgnore: true
}]]
},
src: ['abc.js'],
dest: 'dist/abc.js'
}
},
connect: {
server: {
options: {
port: 7000
}
}
},
// test using jasmine, generate coverage report using istanbul
jasmine: {
coverage: {
src: ['dist/abc.js'],
options: {
junit: {
path: 'bin/junit'
},
host: 'http://localhost:7000/',
specs: 'spec/build/specs.js',
keepRunner: true,
summary: true,
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
replace: false, // *** this option is very important
coverage: 'bin/coverage/coverage.json',
report: [
{
type: 'html',
options: {
dir: 'spec/coverage/html'
}
}]
}
}
}
}
grunt.registerTask('specs', ['browserify:specs', 'browserify:dev', 'connect', 'jasmine']);
The steps of generating istanbul coverage report can be concluded into three:
Instrument code
Run test
Generate coverage report
In our solution, we use browerify-istanbul in step 1, grunt-contrib-jasmine and runt-template-jasmine-istanbul in step 2 and 3.
browserify-istanbul will let you instrument code in browserify building step, in this way, we can easily ignore third party libs. But the grunt-template-jasmine-istanbul will instrument code again. To avoid this, you can set replace to false in the options.
Refs:
Istanbul steps
broswerify-istanbul
grunt-contrib-jasmine
grunt-template-jasmine-istanbul -- replace option

Resources