Giter Club home page Giter Club logo

grunt-mocha-webdriver's People

Contributors

binarykitchen avatar chriswren avatar jmreidy avatar kevinsheedy avatar krinkle avatar pdehaan avatar saadtazi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grunt-mocha-webdriver's Issues

Publish 1.0.0 to npm

Could you please publish 1.0.0 to npm? Thanks for making this tool, looking forward to checking it out!

Fatal error: spawn ENOENT

Task:

mochaWebdriver: {
      options: {
        reporter: 'spec'
      },
      sauce: {
        src: ['app/javascripts/test/index.html'],
        options: {
          username: 'Jester',
          key: '...',
          testName: 'test',
          concurrency: 1,
          browsers: [
            {browserName: 'internet explorer', platform: 'Windows 7', version: '9'},
            {browserName: 'internet explorer', platform: 'Windows 7', version: '8'},
            {browserName: 'chrome', platform: 'Windows 7', version: ''}
          ]
        }
      }
    },

Log:
vagrant@precise32:/vagrant$ grunt -verbose test:crossbrowser
...
Running "mochaWebdriver:sauce" (mochaWebdriver) task
Verifying property mochaWebdriver.sauce exists in config...OK
Files: app/javascripts/test/index.html
=> Connecting to Saucelabs ...
=> Sauce Labs trying to open tunnel
Fatal error: spawn ENOENT

Extrapolate core functionality

This plugin has matured far beyond its original implementation; it can now run a mocha test suite against Phantom, Sauce Labs, and Selenium, with configuration options for each.

I'm wondering if this plugin should be refactored to remove its grunt dependency. That is to say, remove the core functionality into a moch-integration lib, that can be invoked by this task (via grunt), via a different task runner (gulp-mocha-integration?), or even be used standalone. What do people think? (Especially you, @saadtazi?)

Is the 'prerun' option supported?

So that I can use "prerun": "http://url.to/your/file.bat" to adjust some registry settings of Internet Explorers, i.E. to enable SSL/TLS before each test?

How to exit PhantomJS every time

It looks like my e2e tests do not kill the PhantomJS process. How can we exit PhantomJS every time, no matter if the tests were successful or crashed in the middle?

Here an example:

Running webdriver tests against PhantomJS.
>> Error starting PhantomJS
Warning: [ERROR - 2014-04-27T04:32:14.022Z] GhostDriver - main.fail - {"message":"Could not start Ghost Driver","line":82,"sourceId":153982448,"sourceURL":":/ghostdriver/main.js","stack":"Error: Could not start Ghost Driver\n    at :/ghostdriver/main.js:82","stackArray":[{"sourceURL":":/ghostdriver/main.js","line":82}]}
 Use --force to continue.

I had to find the process and manually kill PhantomJS so that I can run it again.

On a side note, I never call browser.quit() in my tests because I were told that this grunt task is doing it automatically. Or am I wrong?

Security enhancement: protect the information sent from scripts

Hi,
According to this FAQ item, you can send encrypted selenium commands (jsonWire calls) through the tunnel instead of http://ondemand.saucelabs.com/ (not encrypted).

I propose the following implementation, let me know if you're ok:

  • Add a secureCommandsoption (boolean - default false). (not sure I like the option name... if you have a suggestion, feel free to share)
  • Change
     else if (opts.hostname) {
        runTestsOnSelenium(fileGroup, opts, next);
      }

by

     else if (opts.hostname && !secureCommands) {
        runTestsOnSelenium(fileGroup, opts, next);
      }

to fallback to saucelabs when secureCommands is true

  • Use hostname and port options instead of ondemand.saucelabs.com when secureCommands is true

Thank you

multiple async tests with the promise api

I try to write functional tests in mocha-webdriver that simulate keyboard inputs in text fields and then test the value of the affected fields. I implemented the tests using the Promise API. Unfortunately, only one test runs successful, the other one dies saying:

  1) GMSC provides a login screen for the application accepts input in the passw
ord field:
     Error: Element is not currently interactable and may not be manipulated

Here is my code - what is my mistake?

function typeEachChar(el, text){
    var chars = text.split('');
    var typePromise = el.type(chars[0]);
    for (var i = 1; i < chars.length; i++){
        typePromise = typePromise.type(chars[i]);
    }
    return typePromise;
}

function acceptsInput (el, testText){
    return el.then(function(el){
         return typeEachChar(el, testText);
    }).then(function(){
        return el.getAttribute('value');
    }).then(function (val){
        return assert.equal(val, testText);
    })
}

describe('MyApp', function () {

    describe('provides a login screen for the application', function () {

        it('accepts input in the password field', function (done) {
            var browser = this.browser;
            var loginPage = browser.get('http://localhost/myapp/');
            acceptsInput(loginPage.elementById('Login'),'login').then(done, done);
        });

        it('accepts input in the password field', function (done) {
            var browser = this.browser;
            var loginPage = browser.get('http://localhost/myapp/');
            acceptsInput(loginPage.elementById('Password'),'password').then(done, done);
        });

    });
});

selenium launcher dependency causes failures when behind a firewall that blocks git protocol

attempting to install grunt-mocha-webdriver from behind the firewall at work causes failures as the git:// protocol is blocked. attempted to use the following:

git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://

however npm still tries to pull down the dependency over git://

changing the dependency to git+https:// seems like it would resolve the problem

Support for wd 0.2.2 and chai-as-promised

wd 0.2.2 has a new way of working with chai-as-promised, which is advertised in their examples as being the "preferred" way.

See this example: https://github.com/admc/wd/blob/master/examples/promise/mocha-specs.js#L19 . I'm not sure if this type of example is compatible with grunt-mocha-webdriver.

I tried to get this running in the current version (with wd manually upgraded to 0.2.2), but ran into errors, probably because I wasn't able to get a handle to the wd object to call chaiAsPromised.transferPromiseness = wd.transferPromiseness;

How to redirect all console.log from browser to std.out?

Similar like

        self.browser.on('status', function(info){
          console.log('\x1b[36m%s\x1b[0m', info);
        });

I want to read any console output the browser makes. No matter if console.log, console.warn, console.error etc.

How can we do this?

Fatal error: undefined is not a function

I get this in my e2e tests without a stack trace. Difficult to find the bug.

Any chance we could tweak the grunt plugin to add additional debugging information when a fatal error occurs?

Release patch version to npm

Could you release a patch version with the updates?

Thanks for merging them in and making this really useful grunt plugin!

Asynchronous assertion failures force exit

I've noticed that if any asynchronous assertions error then the process exits and is not handled by Mocha.

For example:

beforeEach(function (done) {
  this.browser.get('http://www.google.com', done);
});

it('should fail', function (done) {
  this.browser.title(function (error, title) {
    assert.equal(title, "Not Google");
    done();
  });
});

It seems to be related to this plugin since I can't seem to recreate with grunt-mocha-test.

PhantomJS instance still running when grunt test failed

Whenever one of my PhantomJS based e2e tests fails, I can see that PhantomJS is still running with:

$ ps aux | grep phantom
1000     18230  6.6  2.2 2234488 136576 pts/3  Sl   16:24   0:09 /home/michael.heuberger/projects/binarykitchen/code/xxx/node_modules/phantomjs/lib/phantom/bin/phantomjs --webdriver 4444 --ignore-ssl-errors yes

This means, whenever I try to test again, I cannot run the tests without killing it first.

If I don't kill, then I see this error:

Running "mochaWebdriver:client" (mochaWebdriver) task
Running webdriver tests against PhantomJS.
>> Error starting PhantomJS
Warning: [ERROR - 2013-12-10T03:25:41.118Z] GhostDriver - Main - Could not start Ghost Driver => {
  "message": "Could not start Ghost Driver",
  "line": 82,
  "sourceId": 140310677564928,
  "sourceURL": ":/ghostdriver/main.js",
  "stack": "Error: Could not start Ghost Driver\n    at :/ghostdriver/main.js:82",
  "stackArray": [
    {
      "sourceURL": ":/ghostdriver/main.js",
      "line": 82
    }
  ]
}
 Use --force to continue.

Aborted due to warnings.

Can't we configure PhantomJS to kill whenever a test fails?

Automatically restart Sauce Connect

Sometimes it's extremely slow, takes ages to open a simple site: www.google.co.nz

Sauce Lab's support commented on this in a ticket of mine:

Whenever tests using Sauce Connect don't work against any URL, including a URL that is on the Internet, it could be a problem with Sauce Connect, and often restarting Sauce Connect resolves this issue. Are you still seeing this?

So, can we somehow set a timeout and restart Sauce Connect when URLs take too long to load?

Extra logging for all browser instances

Currently I duplicate these lines in every test file:

        self.browser.on('status', function(info){
          console.log('\x1b[36m%s\x1b[0m', info);
        });

        self.browser.on('command', function(meth, path, data){
          console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || '');
        });

This is not so nice. I would love to add that once at the beginning for all tests. In a init test file or in the grunt config if that's possible. Any ideas?

Get the selenium log?

Hello there

Would it be possible to display Sauce Lab's remote selenium log locally whenever a test has failed?

How to call quit() when aborting with CTRL-C?

Hello again

Not sure if this can be done, but according to http://support.saucelabs.com/entries/35517624-Test-did-not-see-a-new-command-for-90-seconds-Timing-out- driver.quit() should be always called to avoid time out error messages.

But when I abort test runs with CTRL-C, then this won't happend and the next run will be very weird, timeouts can happen by random. Not sure what to do here and how to call quit() in those cases?

Or should I call quit() at the top of my grunt script to ensure it's really exited before the init process?

[feature] See a progress bar

For long running E2E tests with Saucelabs this would be very nice.

Currently, when you run a test that takes more than 8 minutes, all you see is just:

Running "mochaWebdriver:sauce" (mochaWebdriver) task
=> Connecting to Sauce Labs ...
>> Connected to Sauce Labs.

and nothing else. And after 8 minutes, lots of log lines appear and you begin to analyse. Not user-friendly. Hence I think a progress bar would be a nice-to-have-feature.

Log methods not working with this driver

According to http://code.google.com/p/selenium/wiki/JsonWireProtocol#POST_/session/:sessionId/log I tried

this.browser.log('browser', cb);

// later in async
console.log(logs);

But I am getting this error in Grunt

Uncaught AssertionError: expected {"message":"Not JSON response","data":"Invalid Command Method - Request => {\"headers\":{\"Accept\":\"application/json\",\"Connection\":\"keep-alive\",\"Content-Length\":\"18\",\"Content-Type\":\"application/json; charset=UTF-8\",\"host\":\"127.0.0.1:4444\"},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"post\":\"{\\\"type\\\":\\\"browser\\\"}\",\"url\":\"/log\",\"urlParsed\":{\"anchor\":\"\",\"query\":\"\",\"file\":\"log\",\"directory\":\"/\",\"path\":\"/log\",\"relative\":\"/log\",\"port\":\"\"... to equal undefined

All I want is to read the console.log outputs from PhantomJS ... any clues?

.setWindowSize no effect on latest PhantomJS

With the latest PhantomJS v1.9.10, setting the windows size does not work anymore. Here my snippet:

    wd.addPromiseMethod(
        'isLogged',
        function() {
            return this
                .setWindowSize(e2eConfig.tablet.width, e2eConfig.tablet.height)
                .waitForElementByCssSelector('nav .myAccount .button').text() // test fails here
                .then(function(text) {
                    expect(text).to.equal('My Account');
                })
                .elementsByCssSelector('nav menu li ul li')
                .then(function(elements) {
                    expect(elements).to.be.an('array');
                    expect(elements).to.have.length(3);
                });
        }
    );

The test fails because it is still stuck with its initial size (mobile). There is no resize effect. Why?

Access to mocha options within tests

In my mocha options (grunt) I have a timeout of 3000 I want to reuse for the waitForElementByCss calls.

So that I can adjust that number at one place only for 30 test files.

And in the test files, it would be great if I can access that number somehow like that:

this.browser.waitForElementByCss('nav', this.options.timeout, cb);

Any chance the mocha options could be exposed?

Using mocha-as-promised

label:improvement

Suggested Improvement (RFC?)

I stumbled upon this usage of mocha-as-promised in wd's examples.

It's currently impossible to use mocha-as-promised without modifying the mocha runner to get access to the mocha instance.

What I'm proposing is to either:

a. expose Mocha somehow
b. add a flag to instrument mocha with mocha-as-promised as part of the task config. Example

I'm available to do the work but wanted to check with you if one of the solutions is preferable.

Thanks

ECONNREFUSED on file upload

When doing this:

browser.uploadFile(VIDEO_PATH + 'hamster-andele.wmv').nodeify(done);

I get this error

     Error: connect ECONNREFUSED
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19

I am running local PhantomJS tests here. All I want is to upload that video file. It exists and the above path is correct.

Any ideas why it is not working?

Run against local selenium instances

I came across this project as I was re-working a custom grunt task for running functional mocha tests, but the one feature that was missing was the ability to run tests against a local instance of Selenium.

I was able to quickly throw together a grunt task for doing that, which ended up borrowing some code from this project and one of the other grunt mocha test runners.

Since the grunt config for the task I wrote and this project are nearly identical, I was thinking that it would be a good idea to add in a local Selenium option to this project, but wanted to check before I spent any time putting together a pull request.

Feedback appreciated!

Grunt task hangs on ECONNREFUSED

This is interesting. When an ECONNREFUSED occurs, all other tests cases come with the same error and the grunt task never stops:

  1) Create video upload file to server:
     Error: connect ECONNREFUSED
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19


  2) Create video logout:
     Error: connect ECONNREFUSED

     at errnoException (net.js:904:11)
      at Object.afterConnect [as oncomplete] (net.js:895:19)

  3) Delete account (user) login:
     Error: connect ECONNREFUSED

     at errnoException (net.js:904:11)
      at Object.afterConnect [as oncomplete] (net.js:895:19)

  4) Delete account (user) delete:
     Error: connect ECONNREFUSED
    at errn
  Exception (net.js:904:11)
      at Object.afterConnect [as oncomplete] (net.js:895:19)

  5) Delete account (user) unable to login:
     Error: connect ECONNREFUSED
    at errno
  xception (net.js:904:11)
      at Object.afterConnect [as oncomplete] (net.js:895:19)

[WAITING FOREVER HERE, NOTHING HAPPENS, HANGING]

Sauce Labs doesn't like the Promise chain syntax?

I just started with grunt-mocha-webdriver yesterday and saw the update for using the 2.0 syntax today, cool! I switched my basic tests over and they worked in PhantomJS. When I run against SauceLabs though, I now get errors like:

>> Connected to Saucelabs. Fatal error: Object [object Promise] has no method 'elementById'

Is this a sign that my stuff isn't written correctly or could there be a deeper issue? Thanks.

[feature request] allow custom reporter when using saucelabs or selenium

The idea is to be able to specify custom reporter when test are run in saucelabs or selenium mode.
For example, I would like to create a teamcity reporter, similar to this, but I will probably have to adapt it so it works with grunt-mocha-webdriver:

  • pass the browser,
  • if (suite.root) then output test suite started on browserName.

That team-city reporter doesn't have to live in grunt-mocha-webdriver. Please let me know your preference... I think outside is better...

Once the first one is done, then it would be easy for anyone to create other reporters (jenkins...).

I can give it a try but I would like to have your input first. any thoughts/limitations/concerns?

Expose "wd" object to tests/requires

The wd object is useful for a few reasons:

  1. Ability to monkey patch custom functions onto the browser object
  2. Ability to use constants such as wd.SPECIAL_KEYS.Tab when sending keystrokes

It would be great if the wd object could be set on the mocha context, so it could be accessed via this.wd just in the same way that we can access the browser object using this.browser.

If it could be exposed in such a way that it would be available to a "setup" file (used in the "requires" declaration as a prerequisite) that would be even better, since this is where I prefer to do my monkey-patching.

Use SauceLabs without Sauce Connect tunnel?

The docs say:

secureCommands

Type: Boolean (Default: false)

If true, it will use saucelabs, with default hostname set to 127.0.0.1 and port set to 4445
in order to send selenium commands through Sauce Connect tunnel (more info
here).

However even when this is set to false, Sauce Connect is used. Is there a way to connect to SauceLabs and run the tests there without Sauce Connect?

Order of Specs

Just wondering if I can use this plugin to execute specs in a specific order. When I set up the tunnel manually and manually execute my mocha tasks, it works. But through this plugin, it seems to execute out of order.

For instance (pseudocode):

it("should be able to log in")
it("should open the profile page")
it("should edit the user email")
it("should save the page")
it("should log out")

When I look at the sauce report page, it is showing that it tried to execute the 2nd "it" before the 1st.

Compatibility with Grunt 0.3.x?

Is this implementation compatible with Grunt 0.3.x versions?
I'm currently running 0.3.17

Currently I'm getting an error:

TypeError: Cannot read property 'length' of undefined

at this section of grunt-mocha-wd.js:

grunt.util.async.forEachSeries(this.files, function (fileGroup, next) {
if (opts.usePhantom) {
runTestsOnPhantom(fileGroup, opts, next);
}
}, this.async());

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.