I currently have a suite of tests which are run in Chrome using grunt-protractor-runner.
I need to get the tests running on IE11 but having problems at the minute.
protractor.conf.js has this:
capabilities: {
'browserName': 'internet explorer',
'platform': 'ANY',
'version': '11'
},
Gruntfile.js has this:
protractor: {
options: {
configFile: 'protractor.conf.js'
},
'internet explorer': {
options: {
args: {
browser: 'internet explorer',
version: '11'
}
}
}
},
I have installed the IE Driver by running:
node C:\git\trove\node_modules\grunt-protractor-runner\node_modules\protractor\bin\webdriver-manager update --ie
And so I have IEDriverServer.exe in the folder with the other drivers (C:\git\trove\node_modules\grunt-protractor-runner\node_modules\protractor\selenium)
I get the below issue:
Running "express:dev" (express) task
Starting background Express server
debugger listening on port 5858
Express server listening on 9000, in test mode
Running "protractor:internet explorer" (protractor) task
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://169.100.24.92:61862/wd/hub
ERROR - Unable to start a WebDriver session.
C:\git\trove\node_modules\grunt-protractor-runner\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113
var template = new Error(this.message);
^
>>
Fatal error: protractor exited with code: 1
I'm not sure what to try - it doesn't give me any useful errors like those I've seen on other posts. I've tried specifying seleniumArgs in protractor.conf.js like so:
seleniumArgs: ['-Dwebdriver.ie.driver=C:\git\trove\node_modules\grunt-protractor-runner\node_modules\protractor\selenium\IEDriverServer.exe'],
But this doesn't help either.
Can anyone please advise?
Dont use the Protractor inside grunt-protractor-runner.
install protractor globally i.e.,:
npm install -g protractor
webdriver-manager update
webdriver-manager update --ie
now start your selenium webdriver server inside cmd window:
webdriver-manager start
In your protractor conf.js file make sure you point to this selenium web driver server i.e.,
seleniumAddress: 'http://localhost:4444/wd/hub',
You can verify this URL from the cmd window where your selenium web driver server is running.
Now you should be able to run your testcases against IE browser as well.
Related
I have been experimenting with javascript frameworks for test automation and one of them is testCafe. I have been able to set up a simple TestCafe project and run some test cases for my application. However, now, the requirement is to have some kinda BDD support built in it. I looked up a few testCafe-cucumber integration projects on GitHub but I can't get them to run. here are a few that I tried:-
1) https://github.com/rquellh/testcafe-cucumber
- I cloned the repo,
- did npm install,
- run the test cases using "npm test",
- blank browser launches but test doesn't run. I see this error in VS code console:
× Before # features\support\hooks.js:46
Error: function timed out, ensure the promise resolves within 20000 milliseconds
at Timeout._onTimeout (C:\Users\Mo\Desktop\TestCafe\github\testCafeBDD\testcafe-cucumber\node_modules\cucumber\src\user_code_runner.js:61:18)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)
× After # features\support\hooks.js:60
ReferenceError: testController is not defined
Then I tried another gitHub project namely this one : https://github.com/kiwigrid/gherkin-testcafe
the run command in readme doesn't work for me, it doesn't even recognize the "gherkin-testcafe".
When I run my TestCafe test cases without the cucumber I have this line in my package.json
"scripts": {
"test": "testcafe chrome Tests/ -e --proxy https.proxy.mycompany.com:8000"
},
the proxy is mentioned because I am behind a proxy and without this the browser launches but does not run any test cases. I found this fix on testCafe site
I am guessing(not sure yet) this could be the issue with cucumber integration as well. None of these frameworks work as they don't set up the proxy anywhere. Can someone point me in the right direction? if the proxy needs to be set up then where in the framework does it need to go- an example would be helpful?
TestCafe/Cucumber integrations rely on starting TestCafe runner programmatically.
In the repo, search for this sequence:
const runner = tc.createRunner();
return runner
.src('./test.js')
.screenshots('reports/screenshots/', true)
.browsers(browser)
.run()
.catch(function(error) {
console.error(error);
});
or search for this sequence:
await runner
.browsers(browsers)
.specs(specs)
.steps(steps)
.concurrency(concurrency)
.startApp(app, appInitDelay)
.tags(tags)
.run(...)
Chain the useProxy method on runner object (do it before the run()method):
const runner = tc.createRunner();
return runner
.src('./test.js')
.screenshots('reports/screenshots/', true)
.browsers(browser)
.useProxy('username:password#proxy.mycorp.com')
.run()
.catch(function(error) {
console.error(error);
});
I am trying to deploy my app via MUP ,everything works fine except when I run command mup deploy. In browser website loads but it does not shows the latest changes I have made. Build files has all changes that I have made.I am using Amazon EC2 for server.
Edit:
In MUP logs it shows that server has started on port 80. I also checked the build file it has latest code but somehow server is not rendering in browser.I am not sure its issue of MUP Or meteor build or amazon EC2 server.
Since I'm having the exact same problem, I can clarify the question.
I'm using Mup build 1.2.8/latest on Windows 10, Meteor v1.4.4.2/latest, deploying to Ubuntu 14.04 on Digital Ocean.
Doing "mup.cmd deploy" builds the bundle, pushes it to the server, starts the app and verifies the deployment, all successfully. The meteor logs as shown by "mup.cmd logs" shows the app started successfully (other than the Kadira warning which should be fixed in the newly deployed version). Browsing to my app doesn't show any of my recent changes (they do show up when running locally). It seems as if the updated container isn't the one running. I've tried starting, stopping and removing the Docker container to no avail.
For reference, here is the mup.js file I'm using (with the names changed to protect the guilty). This file worked to deploy fine 6 weeks ago.
module.exports = {
servers: {
one: {
host: '1.2.3.4',
username: 'Ron',
pem: '/cygwin64/home/Ron/.ssh/id_rsa',
}
},
meteor: {
name: 'MyApp',
path: '../',
servers: {
one: {}
},
buildOptions: {
serverOnly: true,
debug: true,
cleanAfterBuild: true,
buildLocation: '../../output'
},
env: {
// TODO: Change to your app's url
// If you are using ssl, it needs to start with https://
ROOT_URL: 'https://MyApp.com',
MONGO_URL: 'mongodb://localhost/meteor'
},
docker: {
// change to 'kadirahq/meteord' if your app is not using Meteor 1.4
image: 'abernix/meteord:base'
},
// This is the maximum time in seconds it will wait
// for your app to start
// Add 30 seconds if the server has 512mb of ram
// And 30 more if you have binary npm dependencies.
deployCheckWaitTime: 60,
ssl: {
autogenerate: {
email: 'email#example.com',
domains: 'MyApp.com, www.MyApp.com'
}
},
// Show progress bar while uploading bundle to server
// You might need to disable it on CI servers
enableUploadProgressBar: true
},
mongo: {
port: 27017,
version: '3.4.1',
servers: {
one: {}
}
}
};
EDIT::
I deleted all of the containers and images except mongo, ran "mup setup" and "mup deploy" again with exactly the same results, old version is running. So the problem seems to be with the meteor build portion of mup.
EDIT 2::
I found at least 1 of the problems. I have the buildLocation set to a relative path. At some point Mup changes the current directory which causes multiple copies of the buildLocation to be used. In my case the output of the Meteor build command (the new files) were in one and Mup was deploying to the server from another one that happened to contain the old files. I changed buildLocation to an absolute path and the new version is being deployed. Yeah! But wait, even though Mup says the verification worked, my app never runs and the container keeps restarting. Looking out the logs I suspect that the problem is with the line below. Somehow the path has a backslash in it. I'm not sure where this is coming from.
[192.241.229.15]npm ERR! enoent ENOENT: no such file or directory,
chmod
'/bundle/bundle/programs/server/npm/node_modules/sshpk/bin\sshpk-conv'
SOLUTION:: Thanks to Parth Mahida I was inspired to remove the /opt/MyApp directory on the server, as well as removing and reinstalling the sshpk NPM package on my build machine then redid Mup setup and Mup deploy and everything worked again. No idea how the sshpk package became corrupt, but at this point I don't care.
Below is my gruntfile.js . I can run the protractor tests on UI using 'grunt protractor:run command.
However, when i try running command ' grunt protractor-xvfb' so that i can run my tests in headless mode, the browser still launches and tests execute in the same way as using grunt protractor:run command.
What i am expecting is that the tests run in background.
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
protractor: {
options: {
keepAlive: true,
configFile: "../spike-protractor/app/Conf/conf.js",
noColor: false,
args: {
baseUrl: 'https://xxx/xxx/'
}
},
run: {}
},
shell: {
xvfb: {
command: 'Xvfb :99 -ac -screen 0 1600x1200x24',
options: {
async: true
}
}
},
env: {
xvfb: {
DISPLAY: ':99'
}
}
});
grunt.loadNpmTasks('grunt-protractor-runner');
grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.registerTask('protractor-chrome', ['protractor:chrome']);
grunt.registerTask('protractor-xvfb', [
'shell:xvfb',
'env:xvfb',
'protractor:run',
'shell:xvfb:kill'
]);
}
I tried commenting out line code 'protractor:run'from grunt.registerTask and running grunt protractor-xvfb gives me the below output which is correct as per code. This executes so fast as if nothing happened. i think there is something that i am missing in config/code to achieve headless testing .
Running "shell:xvfb" (shell) task
Running "env:xvfb" (env) task
Running "shell:xvfb:kill" (shell) task
Done.
how do i actually proceed on doing headless testing using xvfb + grunt+ protractor ?
Is probably more practical for your use case to go with Zalenium if you want headless Chrome or Firefox testing, video recording, VNC live preview, local dashboard.html among other features.
You can get started with the one-liner:
curl -sSL https://raw.githubusercontent.com/dosel/t/i/p | bash -s start
And/or also watch the presentation:
https://www.youtube.com/watch?v=W5qMsVrob6I
You did not specify to run your conf.js properly.
Remove the part
grunt.registerTask('protractor-chrome', ['protractor:chrome']);
from your gruntfile.js specified in your question.
Edit your gruntfile.js and add below:
grunt.registerTask('protractor-xvfb', [
'shell:xvfb',
'env:xvfb',
'protractor:run',
'shell:xvfb:kill'
]);
Once you add it if you want to run without xvfb use command "grunt protractor:run".
If you want to run using xvfb then use command "grunt protractor-xvfb"
I found a workaround for this to use the below command and specify conf.js -
xvfb-run --server-args='-screen 0, 1600x1200x24' protractor app/Conf/conf.js
Doing this allows to me run my tests in headless mode.
Even if you are not using Grunt in your project, you can directly do npm install xvfb and use this command... pass it to teamcity command line parameters and it will work there as well.
What am I doing wrong? I'm trying to deploy my Telescope app. I'm using this to do that: https://github.com/arunoda/meteor-up. It gives me an error when I try to deploy using Mup. Here's my mup.json config file:
{
// Server authentication info
"servers": [
{
"host": "52.25.228.14",
"username": "ec2-user",
//"password": "password"
// or pem file (ssh based authentication)
"pem": "~/Documents/appname/appname.pem"
}
],
// Install MongoDB in the server, does not destroy local MongoDB on future setup
"setupMongo": true,
// WARNING: Node.js is required! Only skip if you already have Node.js installed on server.
"setupNode": true,
// WARNING: If nodeVersion omitted will setup 0.10.36 by default. Do not use v, only version number.
"nodeVersion": "0.10.36",
// Install PhantomJS in the server
"setupPhantom": true,
// Show a progress bar during the upload of the bundle to the server.
// Might cause an error in some rare cases if set to true, for instance in Shippable CI
"enableUploadProgressBar": true,
// Application name (No spaces)
"appName": "appname",
// Location of app (local directory)
"app": "~/Documents/appname/Telescope",
// Configure environment
"env": {
"ROOT_URL": "ec2-52-25-228-14.us-west-2.compute.amazonaws.com"
},
// Meteor Up checks if the app comes online just after the deployment
// before mup checks that, it will wait for no. of seconds configured below
"deployCheckWaitTime": 15
}
Common pitfalls :
Are sure you ran mup setup before deploying ?
Try using a relative path to setup the app location, ie replace ~/Documents/appname/Telescope by . if your mup.json is located at the root of your Telescope instance.
I did run mup setup, did use http://, and tried many times to get it to connect/deploy.
I gave up and just went with a Wordpress theme and am customizing it how I want it. The other way was way too complicated. It didn't allow me to do what I wanted in a timely manner. Thanks for trying to help though guys.
I'm trying to run end-to-end tests with WebDriver and Protractor. No problem when I run it manually with:
webdriver-manager start
and then
protractor test-UI/e2e/conf.js
Now I would like to launch them from a grunt command, so I tried with grunt-shell, joining them with '&&'. But as WebDriver waits, tests are never started. Did someone try this before?
Thanks.
There is a fork of Grunt-shell called Grunt-shell-spawn (Github Repo) which allows you to run background processes asynchronously. This happens to work very well with starting the selenium webdriver server helping to automate the protractor testing process. There are a few grunt plugins specifically for starting the webdriver server but from my experience they all have small bugs that cause errors once the tests are finished or require you to mark a flag keepAlive: true which means it will not kill the webdriver server process forcing you to ctrl+c or close and re-open the command prompt which can cause a lot of issues when devs are using the functional tests and with continuous integration (CI) servers. Grunt-shell-spawn has the ability to kill the process as you can see at the end of my 'test' task which is really invaluable for maintaining consistency and ease of use.
'use strict';
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-protractor-runner');
var path = require('path');
grunt.initConfig({
...
...
...
shell: {
updateserver: {
options: {
stdout: true
},
command: "node " + path.resolve('node_modules/protractor/bin/webdriver-manager') + ' update --standalone --chrome'
},
startserver: {
options: {
stdout:false,
stdin: false,
stderr: false,
async:true
},
command: 'node ' + path.resolve('node_modules/protractor/bin/webdriver-manager') + ' start --standalone'
},
});
grunt.registerTask('test',[
'shell:updateserver',
'shell:startserver',
'protractor:e2e',
'shell:startserver:kill'
]);
You can to install grunt-protractor-runner
npm install grunt-protractor-runner --save-dev
Check this blog with details
http://www.codeorbits.com/blog/2014/01/26/angularjs-end-to-end-testing-with-protractor-easy-set-up-with-yeoman/
Try running grunt --verbose to see more details on whats happening.