-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chromedriver with Karma [$100 awarded] #2229
Comments
Where did you download chromedriver2_server? which version? Thanks |
I've tried the one bundled with v0.10.2-osx-x64 as well as 0.9.0 from the links listed on this page: https://github.com/rogerwang/node-webkit/wiki/Chromedriver My initial testing was based on this article: http://www.ng-newsletter.com/posts/practical-protractor.html , replacing the
Based on the the chromedriver wiki page though, I'm pretty unsure I'm approaching this correctly. |
+1 on this... added to the bounty via https://github.com/kalabox/kalabox |
Thanks Mike! ... That's the project Roger, in case you needed any context. Not much there yet. We're trying to get the angularjs testing architecture working with node-webkit before we get too much further. |
Haven't tried with Karma, but this python driver script works for me with 0.10.2: import time
from selenium import webdriver
driver = webdriver.Chrome('/home/roger/Download/node-webkit-v0.10.2-linux-x64/chromedriver') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit() |
very nice! we will def test this out. |
I have solved all the issues with node-webkit + Karma/Protractor I've run into yesterday, so I'll just share my experience. Create a symlink to node-webkit.app/nw.exe/nw depending on your platform (you can create all of them and add to git, this way you'll get support for all platforms) along with node-webkit's chromedriver you have downloaded and it will find the binaries. I use this directory structure:
// karma.conf.js
browsers: ['NodeWebkit'] And a custom launcher for node-webkit: https://github.com/nDmitry/karma-nodewebkit-launcher (you can install it from git as this fork isn't published on npm). |
Protractor works too, but it requires a bit of additional configuration: 'use strict';
exports.config = {
chromeDriver: './support/chromedriver', // relative path to node-webkit's chromedriver
chromeOnly: true, // starting Selenium server isn't required in our case
specs: ['test/e2e/**/*.js'],
baseUrl: 'file:///absolute/path/to/your/project/index.html',
rootElement: 'html', // specify a correct element where you bootstrap your AngularJS app, 'body' by default
onPrepare: function() {
// By default, Protractor use data:text/html,<html></html> as resetUrl, but
// location.replace (see http://git.io/tvdSIQ) from the data: to the file: protocol is not allowed
// (we'll get ‘not allowed local resource’ error), so we replace resetUrl with one
// with the file: protocol (this particular one will open system's root folder)
browser.resetUrl = 'file://';
// This isn't required and used to avoid ‘Cannot extract package’ error showed
// before Protractor have redirected node-webkit to resetUrl.
browser.driver.get('file://');
}
}; |
@nDmitry Thanks for this! I am much closer now. Are there any entries in I've installed the plugin, and I get a webkit looking thing popping up (all white), but it hangs and times out with the error that it cannot start webkit. |
@mikemilano there are no such entries, AFAIR Karma don't need that driver at all, it is for WebDriver/Selenium only. Basically, launchers just define paths to binaries.
Don't know, here is my entire karma.conf.js: 'use strict';
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
// a lot of application files first
'test/unit/**/*.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'js/**/*.js': ['coverage']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['NodeWebkit'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
coverageReporter: {
type : 'html',
dir : 'coverage/',
subdir: function(browser) {
return browser.toLowerCase().split(/[ /-]/)[0];
}
}
});
}; Ensure that you have |
Oh, so is the |
Yeah, the
That's why we need to place the binaries (or symlinks to them) along with |
@nDmitry I got Karma testing successfully, thanks! Now I'm just trying to finish up by getting protractor working. I setup my protractor config as in your example. The only difference is my When I run It's definitely picking up the chromedriver and .app in Can you think of anything else I may be missing? |
file:// is a reset URL (if you don't call What's the output in your console, what does the first spec look like and how do you bootstrap your app (ng-app directive or manual bootstrapping)? |
As a result, when I run The error is: "Error: Angular could not be found on the page file:///dashboard : retries looking for angular exceeded" The app is bootstrapped with config: https://github.com/kalabox/kalabox/blob/master/test/protractor.conf.js |
I got it working by modifying how protractor joins the baseUrl with the destination. I posted an issue about it here: angular/protractor#1266 I'm interested in what your tests look like if you had it working before. This was the only way I could see it working without muddying up my tests. |
Your baseUrl must be an absolute path like |
@nDmitry I'm using Protractor runs But, you have it working so maybe it's an environment thing. It looks like we're good to go. I really appreciate the help. We feel a lot better about using AngularJS with NodeWebkit. |
@mikemilano thanks, it('foo', function() {
// I need to test my authentication mechanism first before Angular has bootstrapped,
// so I redirect WebDriver directly calling get() on a driver instance (otherwise
// Protractor will start its initialization, which I don't want yet)
browser.driver.get('file://' + path.resolve('./index.html'));
// I do all further interactions using the driver and avoiding Protractor's methods
// since they don't relate to Angular
browser.driver.switchTo().frame(driver.findElement(by.css('.frame')));
// more here
// Now I switch back to the main context and call `browser.get()` to initialize
// Protractor
browser.driver.switchTo().defaultContent();
browser.get('#/');
// This one seems important
browser.waitForAngular();
// Now I use Protractor's methods as Angular has bootstrapped
element(by.model('task.description')).getAttribute('placeholder').then(function(value) {
expect(typeof value).toBe('string');
});
}); I guess you should try to call browser.driver.get() with your |
@nDmitry, we bounty-sourced this thing as well so please feel free to claim the bounty! |
@pirog thanks, I just did. |
Accepted the bounty as one of the backers. pinging @mikemilano to follow suit :) |
It is unclear from this thread, what actually fixed the error? I'm seeing the following: UnknownError: unknown error: cannot find Chrome binary The chromedriver binary was downloaded from http://dl.node-webkit.org/, and it has been manually placed in the same directory as my node-webkit binary. My protractor configuration file: // An example configuration file. // Capabilities to be passed to the webdriver instance. // Spec patterns are relative to the current working directly when
}, |
The last piece is the grunt-protractor module. It has a dependency on protractor, so it also has to be using a version of protractor that has the patch. We ended forking both projects to use them until the normal dependencies resolve with the patches that fix it. I think your problem is around 2. above though. |
It hasn't as far as I can see from this path: In case you really want to use node-webkit from a build of your app, the proper path to place chromedriver will be But it's really better to install separate version of node-webkit somewhere and make a symlink. |
Right, also here https://github.com/shama/nodewebkit. Nice point for external nw. |
Hi guys, my karma test is working, but protractor is not working, I'm with this error: Can you help me? samuelcastro:test samuel$ grunt protractor --suite users /Volumes/DATA/DEVELOPMENTS/PROJECTS/app/desktop/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113
Done, without errors. |
I'm still getting "cannot find Chrome binary" errors on Mac OS X 10.10 with Protractor. I've tried linking |
Ah...looks like the name of the Mac app that Chromedriver searches for didn't get changed from |
Got it! You can specify the Chrome binary in 'use strict';
exports.config = {
chromeDriver: './support/chromedriver', // relative path to node-webkit's chromedriver
chromeOnly: true, // starting Selenium server isn't required in our case
capabilities: {
browserName: 'chrome',
chromeOptions: {
// Path to NW.js binary goes here!
binary: process.env.PWD + '/support/nwjs.app/Contents/MacOS/nwjs'
}
},
specs: ['test/e2e/**/*.js'],
baseUrl: 'file://' + process.env.PWD + '/build/',
rootElement: 'html', // specify a correct element where you bootstrap your AngularJS app, 'body' by default
onPrepare: function() {
// By default, Protractor use data:text/html,<html></html> as resetUrl, but
// location.replace (see http://git.io/tvdSIQ) from the data: to the file: protocol is not allowed
// (we'll get ‘not allowed local resource’ error), so we replace resetUrl with one
// with the file: protocol (this particular one will open system's root folder)
browser.resetUrl = 'file://';
// This isn't required and used to avoid ‘Cannot extract package’ error showed
// before Protractor have redirected node-webkit to resetUrl.
browser.driver.get('file://');
}
}; |
This should probably go in the wiki. I'll write something up if folks want it. |
How are you guys dealing with logic that goes through When I run my tests, I'll get |
@brian-mann If I understand you correctly, you're missing the use of the special NW version of Chromedriver. |
I am facing the same issues reported by @samuelcastro (commented on Oct 22, 2014). What is the solution for the above issue? Driver info: chromedriver=2.13, platform=Windows NT 6.1 SP1 x86_64 |
@brian-mann, where you able to solve the issue you faced? I am also not able to run protractor if I use require for nw or other node modules. I am using chrome driver for nw. |
Actually, other node modules like fs, and my custom module which has methods to be invoked are working. When I try, var nw = require("nw.gui"), its also returns, The issue if I access nw.App or anything, the result is a json object which has only strings , the inner contents are not json objects anymore. eg: I get nw.App , but not nw.App.manifest. |
Note to anyone who is trying to run Protractor tests with NWJS 0.13+, with the change over to the chrome-extension:// protocol, I noticed I had to change a couple things:
Once I switched these over and made sure to replace any other references to the "file://" protocol, my tests ran as they did on v0.12. |
Can u please share your conf.js? I would like to refer it since my attempt to run protractor test with nwjs 0.15.4 is failing. Please see my conf.js and let me know if there is anything wrong.(This was working fine with nwjs : 0.12.3).
And here is the error which I am getting :
|
If we're going to update the Helper app binary, why not the main app binary? This relates to nwjs#2229
Should I be able to use
chromedriver2_server
to test node-webkit apps with Karma or Protractor?I'm building a front-end with AngularJS and access node modules directly in the app. I've downloaded the
chromedriver2_server
binary and directed karma & protractor to use it, but it just errors out saying that it can't locate the Chrome binary.I suspect I'm going about it the wrong way though. If it's might be possible to run the recommended AngularJS testing frameworks (karma & protractor) in a node webkit instance, please let me know.
The $100 bounty on this issue has been claimed at Bountysource.
The text was updated successfully, but these errors were encountered: