I have configured webstorm for using protractor, but when I launch my test suit, it does not recognize this param from my config file:
// conf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
capabilities: {
browserName: 'firefox'
}
};
In console it says serving "conf.js" at http:// 127.0.0.1:8080. What could be the reason for that? Why it does not use address for my selenium?
Here is the configuration I have. But it does not use correct URL
The JavaScript file parameter in the webstrom / intellij windown has to point to Protractor's cli.js file under node_modules/protractor
Related
I'm trying to use WebStorm in order to debug protractor e2e test, My objective is to be able to put breakpoints in the code of the tests. I'm new to this, so I'm probably doing something wrong.
As stated on the protractor tutorial, I updated the webdriver-manager and start it using this command in a cmd Terminal (I'm working on Windows):
webdriver-manager start
This is my protractor-conf.js file:
var ScreenshotReporter = require('./screenshotReporter.js');
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
//baseUrl: 'http://localhost:9000',
framework: 'jasmine2',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
specs: ['**/*_spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
},
onPrepare: function() {
jasmine.getEnv().addReporter(new ScreenshotReporter("test-e2e/screenshotFailures/"));
}
};
I created a configuration in WebStorm like this:
Node interpreter: C:\Program Files\nodejs\node.exe
Working directory: C:*******\ref-app
Javascript file: node_modules\protractor\lib\cli.js
Application parameters: test-e2e/protractor-conf.js
And after I tried several things:
Run Protactor using Run Button in WebStorm:
Failed: Angular could not be found on the page / : retries looking for angular exceeded
Debug Protractor using Debug Button in WebStorm:
I can see this in the WebStorm console but nothing happens after:
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Started
F
Modify protractor-conf.js to add baseUrl
baseUrl: 'http://localhost:9000',
Then start a local webserver on port 9000
If I run Protractor using Run Button in WebStorm, it is working fine but I can't setup breakpoints
If I Debug Prtoractor using Debug Button in WebStorm, I can just see this in the console but nothing happen after:
Using the selenium server at http://localhost:4444/wd/hub
[launcher] Running 1 instances of WebDriver
Started
EDIT:
AS I say in my comment below, I'm using:
protractor 3.1.0
WebStorm 11.0.3
WHen I'm trying to debug using webstorm, it opens a Chrome windows but the screen is completely blank and in the URL, you have : data:, (I don't think it is useful but I don't know what to try)
Any idea what I'm doing wrong ?
you can run node in the --inspect-brk mode, and attach a remote debugger, for example the chrome dev-tools:
start your app with ng serve and run
node --inspect-brk ./node_modules/protractor/bin/protractor ./protractor.conf.js
now node waits for a debugger to attach.
Then you can open chrome://inspect/#devices. There your app should appear.
Finally click inspect at the target / your app and voila you can use now breakpoints and debugger; statements.
Trying to run a protractor test with the firefox browser. This is my config file:
// An example configuration file.
exports.config = {
//directConnect: true,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'firefox'
},
//chromeOnly:false,
// Framework to use. Jasmine 2 is recommended.
framework: 'jasmine2',
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['example_spec_backup.js'],
seleniumServerJar: 'C:/Users/myname/protractor/protractor-master/chromedriver_win_26.0.1383.0/selenium-server-standalone-2.46.0.jar',
baseUrl: 'http://localhost:9000/',
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
Failed: Angular could not be found on the page http://www.angularjs.org/ : retries looking for angular exceeded.
This is one of the tests:
it('should greet the named user', function() {
browser.get('http://www.angularjs.org');
element(by.model('yourName')).sendKeys('Julie');
var greeting = element(by.binding('yourName'));
expect(greeting.getText()).toEqual('Hello Julie!');
});
When I start the test firefox goes to the angularjs.org but somehow the test returns an error?
You can read the protractor referenceConfig.js
To connect directly to Drivers
Boolean. If true, Protractor will connect directly to the browser Drivers
at the locations specified by chromeDriver and firefoxPath. Only Chrome
and Firefox are supported for direct connect.
directConnect: false,
Path to the firefox application binary. If null, will attempt to find
firefox in the default locations.
firefoxPath: null,
As you are getting Angular could not be found on the page
1.This may be because you're using an old version of Angular. which does not support Protractor.
2.You need some way of waiting until not only the element is present, but Angular is loaded on the page.One thing you could just do is to manually wait until angular is present:
browser.wait(function() {
return browser.executeScript('return !!window.angular');
});
You are not starting the selenium server for firefox browser to invoke. Add below line in your config file before capabilities -
seleniumAddress: 'http://localhost:4444/wd/hub',
Hope this helps.
I'm using Protractor to run end-to-end JS tests within my Rails app. The following spec is failing:
# my_ctrl_spec.js.coffee
describe 'MyCtrl', ->
it 'does a thing', ->
expect( browser ).toBeTruthy()
browser.get '/'
The spec passes with the last line commented out, but actually trying to navigate WebDriver gives me "Error 403 Forbidden for Proxy" on the rendered page.
Here is my protractor_conf.js file:
require('coffee-script/register');
exports.config = {
capabilities: {
'browserName': 'chrome',
},
specs: ['spec/javascripts/e2e/**/*_spec.js.coffee'],
seleniumAddress: 'http://localhost:4444/wd/hub',
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.44.0.jar',
baseUrl: 'http://localhost:4444',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
I'm also getting some errors telling me that "retries looking for angular exceeded," but I think that's because of the 403 error, not vice-versa.
Some system deets:
Mac OS X 10.9.5
Selenium 2.44.0
Protractor 1.4.0
Can anyone see anything wrong with my setup?
I think you used baseUrl the wrong way: it should be the URL of the page you want to test, not the selenium adress.
If you use a webserver it could be http://localhost:8000 for example, if the page is already online just put its URL ;)
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: 'http://localhost:9876',
Take a look at protractor/referenceConf.js for more info.
In the (now deprecated) angular scenario test runner, there was an option to create a runner.html page that would run the tests in an iFrame while reporting the progress, step-by-step, in the main page.
Is there any way to get a similar step-by-step log for protractor tests? It does not need to be in an html page (console or log file would be fine).
For that you can use the jasmine-spec-reporter for protractor. You'll have a visual feedback of all your passing and non-passing tests :
Easy to configure and looks really good in the console.
Hope this helps.
Since v1.0.0-rc2 you can see failures in real time:
In your protractor config, add a jasmineNodeOpts object with realtimeFailure option to true:
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
specs: [
'e2e/**/*.js'
],
multiCapabilities: [
{'browserName': 'firefox'},
{'browserName': 'chrome'}
],
baseUrl: 'http://localhost:8000',
onPrepare: function() {},
jasmineNodeOpts: {
realtimeFailure: true
}
};
The full list of jasmine options is here: minijasminenode
And the well detailed reference config file for protractor here: referenceConf.js
I'm building a SaaS solution using AngularJS / JBOSS, hosted on a AWS EC2 instance; all our functionality is covered by unit and e2e tests. All the tests run fine locally. We can't figure out how to run them on AWS. Our AWS installation includes a headless CHROME, installed according to these instructions:
Steps to Reproduce
Set up chrome/firefox in linux based x86_64 EC2 instance
Launch webdriver-manager start
On a separate terminal window, launch protractor
Observed Behavior
1. The following error is shown on the webdriver terminal:
/usr/local/lib/node_modules/protractor/selenium/chromedriver: error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory
06:41:15.140 WARN - Exception thrown
Expected Behavior
1. The protractor test is executed without errors
Additional resources:
1. Protractor configuration file
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['../test/e2e/**/*.js'],
// A base URL for your application under test. Calls to browser.get()
// with relative paths will be prepended with this.
baseUrl: 'http://localhost:8080/markodojo_solution/#/a3bc8692-5af4-4a4d-b21b-4e6f87dc2a32',
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
isVerbose: true,
defaultTimeoutInterval: 30000
},
//Options to output testreuslts in xml format
onPrepare: function() {
// The require statement must be down here, since jasmine-reporters
// needs jasmine to be in the global and protractor does not guarantee
// this until inside the onPrepare function.
require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmine.JUnitXmlReporter('xmloutput', true, true));
}
};
Thanks in advance for any assistance!
Go with Headless Chrome option
This greatly simplifies the workflow and having to use more system resources.
Follow the broad steps below:
Chrome install. Assuming you already have Chrome installed there. However if not following steps to install Chrome on linux EC2
Change your protractor options to something like below. The important thing is --headless. Additionally keep in mind that headless mode requires the browser size be specified upfront:-
chromeOptions: {
args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
}