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?
Related
While running multiple test suits on CBT via jenkins parallel, Jenkins get slower and page takes more time to load on CBT and hence it shows below error(which is intermittent)
Error: Angular could not be found on the page Https:xxx.xyz.com If this is not an Angular application, you may need to turn off waiting for Angular.
If is not angular application, you need to turn of wait for angular. Usually login pages are not angular:
browser.waitForAngularEnabled(false);
To check if is angular, open dev tools and in console just write "angular", if page is angular will return object, if not will return "Uncaught ReferenceError: angular is not defined".
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,
I'm writing a suite of Protractor tests from the ground up for a new Angular webapp. My team has asked me to run my tests against their Test server instance. I've got my config file and a basic test spec set up, but as soon as I hit the main page and do a simple expect() statement, I get "Timed out waiting for Protractor to synchronize with the page after 11 seconds."
Here's my test:
describe('the home page', function() {
it('should display the correct user name', function(){
expect(element(by.binding('user.name')).getText()).toContain(browser.params.login.user);
});
});
I cloned the dev team's git repo, set it up on my localhost, changed my baseUrl and ran my Protractor test against it locally. Passed without a hitch.
After some conversation with the dev team, I've determined that it's not a $http or $timeout issue. We use both of those services, but not repeatedly (I don't think they're "polling"). None of them should happen more than once, and all the timeouts are a half-second long.
What else could cause Protractor to time out like that? I wish it failed on my localhost so I could go tweak the code until I find out what's causing the problem, but it doesn't.
I have discovered the solution: check for console errors.
Turns out, one of our $http requests wasn't coming back because my Protractor tests were accessing the page via https, but one of our xhtml endpoints was at a non-secured location. This resulted in a very helpful console error which I had not yet seen, because it only occurred when accessing the site with WebDriver.
The error text: "The page at [url] was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint. This request has been blocked; the content must be served over HTTPS."
I modified my baseUrl to access the site via regular http, and now everything is working fine.
I have an integration test that is failing for the reason:
"Timeout::Error: timeout while waiting for angular"
I have run the test with selenium so that I can see what happens, and the page loads perfectly fine. I threw a debugger in my test so that I can browse around the app with the test fixtures-- and everything works perfectly...
Yet in the debugger, as soon as I type "page", to query what capybara thinks it sees, I get:
[5] pry(#<RSpec::Core::ExampleGroup::Nested_1>)> page
Timeout::Error: timeout while waiting for angular
from /Users/me/.rvm/gems/ruby-2.0.0-p451#my_app/gems/capybara-angular-0.0.4/lib/capybara/angular/waiter.rb:30:in `timeout!'
So basically it's lying to me because angular is fully loaded, api calls are happening and responding with json, the templates are getting interpolated... What the... ?
This gem has been updated to 0.1.0, which fixes the problem you are describing. Cheers!
Issue & Pull Request: https://github.com/wrozka/capybara-angular/issues/11
I am using protractor along with PhantomJs for e2e testing of my angular app.
Currently I am testing a login form. All the test work fine when I am simply checking
whether the form loaded correctly
username/password fields are empty
errors are displayed when you enter incorrect authentication information.
So far phantomJs and protractor have been quiet cooperative
However the below mentioned test cases simply fails all the time in protractor. I have tried various permutation and combinations but to no avail.
when the user enters correct authentication information in the login form, the angular app will change the route to dashboard section. i.e the url in the browser window would change from
http://localhost:12345/#/signin/
to
http://localhost:12345/#/dashboard
When I run the below give test, I know that the authentication was successful because the server logs display a success response object sent. Upon receiving this response, the angular app should have changed the route to /dashboard. However protractor fails to capture this change in route.
My test looks like below:
describe("SignOn Page - Performing authentication with valid credentials ",function(){
var ptor;
beforeEach(function(){
ptor = protractor.getInstance();
ptor.get('#/signon');
ptor.findElement(protractor.By.id('username')).sendKeys('joe');
ptor.findElement(protractor.By.id('password')).sendKeys('pass');
element(by.partialButtonText('Sign In')).click();
ptor.waitForAngular();
});
it("should re-direct user to dashboard page once the user enters correct authentication information",function(){
ptor = protractor.getInstance();
expect(ptor.getCurrentUrl()).toContain('dashboard');
expect(ptor.getTitle()).toContain('dashboard');
});
});
My question to this forum is, does protractor have issues changing states ? I am using ui.router in my angular application ?
I had the same issue because I was using phantomJS 1.9.x and not the 2.x
So you need to uninstall phantomjs 1.9
npm remove -g phantomjs
and install phantomJS 2.x
npm install -g phantomjs2
Hope it's also solve your issue