angular protractor test how to open test page in firefox - angularjs

Chrome on my Macbook Pro has been restricted by company policy, so no chrome extensions can be added.
I'm using protractor to do angualrjs e2e test, and when I run the command to test, Chrome prompts an error dialog:
Failed to load extension from: /private/var/folders/fs/xrgskh8502ddg026py0f61j9v7q1z6/T/.org.chromium.Chromium.TQYyRX/internal. Loading of unpacked extensions is disabled by the administrator.
Now I suppose to have two solutions:
Try to bypass the restriction. (still failed to break it yet)
Try to change protractor to open in other browser, e.g. Firefox

change in your protractor.conf file
capabilities: {
"browserName": "firefox"
},
chromeOnly: false,

Related

Unable to open browser with specified URL using Selenium Webdriver

Unable to open firefox browser with specified url in selenium webdriver. Only the browser is opening without the url.
Firefox version is 47.
Selenium version is 2.53.
There are two ways to solve your problem.
1- You can downgrade your firefox by reinstalling and select Never check for updates (not recommended: security risk) in your firefox by nevigate through
Open Menu->Options->Advanced.
2- if you want to working with current version of firefox which is 47 you should try with MarionetteDriver...by following this
If you have any problem with this let me know...:)

Debugging protractor using WebStorm

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.

how to keep opened developer tools while running a selenium nightwatch.js test?

I am starting to write e2e tests using nightwatch.js and I noticed some errors that I would like to inspect manually in the target browser's console (developer tools). but always when I open the developer console, it is automatically closed by the browser. is this a intended feature of either selenium or nightwatch.js, and, if it is the case, how can I disable it?
I'm successfully using this config in nightwatch:
...
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true,
chromeOptions: {
'args': ['incognito', 'disable-extensions', 'auto-open-devtools-for-tabs']
}
}
},
...
Unfortunately it doesn't seem to be possible. See here:
When you open the DevTools window, ChromeDriver is automatically
disconnected. When ChromeDriver receives a command, if disconnected,
it will attempt to close the DevTools window and reconnect.
Chrome's DevTools only allows one debugger per page. As of 2.x,
ChromeDriver is now a DevTools debugging client. Previous versions of
ChromeDriver used a different automation API that is no longer
supported in Chrome 29.
See also this question.
You might be able to achieve this using Node Inspector: https://github.com/node-inspector/node-inspector
Put a debugger statement where you want the test to pause and run node-debug ./node_modules/.bin/nightwatch --config path/to/nightwatch.json --test yourTest.js

How to run protractor to validate CHROME on AWS

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

How to test e2e google chrome extension with karma?

I've found fantastic unit/e2e test tools karma.
And I wrote simple chrome extension with angular. I want to write automated tests for it, but not only unit tests, end-to-end tests too.
I wrote something like this (will open my angular extension-options page):
it('Go to options page', function() {
browser().navigateTo('chrome-extension://aopgehikihpnclbfeohobanjecpiefho/html/application.html#/options');
});
I removed '--user-data-dir' and '--disable-default-apps' for karma-chrome-launcher, (because I want that my extension stays in chrome during "karma tests")
but I've got next error message "Sandbox Error: Application document not accessible.":
browser navigate to 'chrome-extension://aopgehikihpnclbfeohobanjecpiefho/html/application.html#/options'
http://localhost:9876/base/tests/e2e/scenario.js?1372429335000:9:5:
Sandbox Error: Application document not accessible.
Chrome 27.0 (Windows): Executed 2 of 2 (2 FAILED) (0.254 secs / 0.139 secs)
Chrome option --no-sandbox deprecated long time ago.
I'm sure I'm not wrong, the options page opens ok, but from chrome "omnibox".
chrome-extension://aopgehikihpnclbfeohobanjecpiefho/html/application.html#/options
Sandbox Error means no way for end-to-end tests for google chrome extensions via karma?
Can I set chrome to special "non-secure" mode just for tests?
Thanks,
i don't think karma scenario runner is capable to do that. You can try Protractor, it uses WebDriver and karma scenario runner will be replaced with it.
What if you tried setting a proxy? Like
proxies = {
'/': 'chrome-extension://aopgehikihpnclbfeohobanjecpiefho/'
};
in your karma-e2e.conf.js file and then
browser().navigateTo('/html/application.html#/options');
in the test?

Resources