Giter VIP home page Giter VIP logo

Comments (17)

philipbeadle avatar philipbeadle commented on May 29, 2024

This is what I did to get webdriver.io checking the google home page title.

package.json

{
  "name": "gauge-test",
  "version": "1.0.0",
  "description": "testing out gauge with webdriver",
  "directories": {
    "test": "gauge specs/"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "chai": "^3.5.0",
    "chai-as-promised": "^5.2.0",
    "webdriverio": "^4.0.3",
    "webdriverjs-angular": "^0.1.3"
  }
}

spec file

#This spec is an example on how to use Asynch operqtions with webdriver.io

Check the title
---------------------------
* Check the title of the Google home page is "Google"

step file

'use strict'

var webdriverio = require('webdriverio');
var options = {
  desiredCapabilities: {
    browserName: 'firefox'
  }
};
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');

chai.use(chaiAsPromised);
expect = chai.expect;
chai.Should();

var assert = require("assert");

gauge.step("Check the title of the Google home page is <vowels>", function (titleGiven, done) {
  webdriverio
    .remote(options)
    .init()
    .url('http://google.com')
    .getTitle().then(function(title) {
      assert.equal(title, titleGiven);
    })
    .end()
    .call(done);
});

then run

npm test

Enjoy.

from gauge-js.

kaustavdm avatar kaustavdm commented on May 29, 2024

@philipbeadle This is superb! Thanks a lot!

from gauge-js.

ivanbportugal avatar ivanbportugal commented on May 29, 2024

Will definitely be giving this a shot today! Might be worth adding this to the README? What do you guys think?

from gauge-js.

kaustavdm avatar kaustavdm commented on May 29, 2024

@ivanbportugal There's a new release with the latest fixes. 😄 You may want to do:

$ gauge --update js

from gauge-js.

kaustavdm avatar kaustavdm commented on May 29, 2024

Also, the docs have been updated with information on async operations.

from gauge-js.

philipbeadle avatar philipbeadle commented on May 29, 2024

thanx so much, youre doing an amazing job with this plugin. I'm building a full blown demo of using gauge-js with a meteor site and webdriver.io. Ill keep you posted.

from gauge-js.

kaustavdm avatar kaustavdm commented on May 29, 2024

@philipbeadle That's lovely. If the demo you are building can be shared, would you mind uploading it as a repo on Github? That way, we can share it with others.

from gauge-js.

philipbeadle avatar philipbeadle commented on May 29, 2024

demo will be here very soon

https://github.com/philipbeadle/gauge-js-angular-webdriver-demo

from gauge-js.

kaustavdm avatar kaustavdm commented on May 29, 2024

😺 👍 🍻

from gauge-js.

philipbeadle avatar philipbeadle commented on May 29, 2024

Demo is up, basic demo showing using Gauge, gauge-js, angular and webdriver.io to do UI testing :)

https://github.com/philipbeadle/gauge-js-angular-webdriver-demo

from gauge-js.

kaustavdm avatar kaustavdm commented on May 29, 2024

@philipbeadle Nice! Do you mind if we add it as an example for gauge-js to the README?

from gauge-js.

philipbeadle avatar philipbeadle commented on May 29, 2024

Please do. I'm going to add to it over the next few weeks and show how to select elements etc and build up a library set hooks etc.

from gauge-js.

ivanbportugal avatar ivanbportugal commented on May 29, 2024

Guys,

How might we get assert errors and gauge messages to show up in the report? The following code (using @philipbeadle example) errors out on the console correctly but doesn't show up on the report. It looks like the closure is not being caught at the gauge js level:

'use strict'

var webdriverio = require('webdriverio');
var options = {
  desiredCapabilities: {
    browserName: 'chrome'
  }
};
var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');

chai.use(chaiAsPromised);
var expect = chai.expect;
chai.Should();

var assert = require("assert");

gauge.step("Check the title of the Google home page is <vowels>", function (titleGiven, done) {
  webdriverio
    .remote(options)
    .init()
    .url('http://google.com')
    .getTitle().then(function(title) {
        gauge.message('just a test message'); // Does NOT show up
        expect(title).to.equal('blah'); // Shows on the console, not on the report
        assert.equal(title, 'blah'); // Shows on the console, not on the report
    })
    .end()
    .call(done);
});

from gauge-js.

ivanbportugal avatar ivanbportugal commented on May 29, 2024

More info: I get the following error in the console. Still digging...

Unable to connect to plugin Html Report 2.0.0. proto: required field "SuiteExecutionResult.SuiteResult.SpecResults.ProtoSpec.Items.Scenario.ScenarioItems.Step.StepExecutionResult.PostHookFailure.StackTrace" not set

from gauge-js.

ivanbportugal avatar ivanbportugal commented on May 29, 2024

@kaustavdm @philipbeadle More info: A workaround might be to use the gauge API to fail a test. How might this be done? gauge.error(e) or gauge.step.fail(e) or done(e) ?

gauge.step("Check the title of the Google home page is <vowels>", function (titleGiven, done) {

    webdriverio
        .remote(options)
        .init()
        .once('error', function(e) {
            gauge.message('Here is the error: ' + e);
            // Would be nice if we could say: gauge.error(e) or gauge.fail(e) ?
            // Or, maybe even done(e)
        })
        .url('http://google.com')
        .getTitle().then(function(title) {
            try{
                gauge.message('just a test message'); // Shows up
                expect(title).to.equal('blah'); // Throws AssertionError
                assert.equal(title, 'blah'); // Throws AssertionError if you comment out the above line
            } catch(e) {
                this.emit('error', e);
            }
        })
        .end()
        .call(done);
});

If you debug, after calling done(e) that param doesn't show up in the err variable here:
Snippet from test.js in your gaugejs library:

var done = function(err) {
  var self = this;
  if(self.finished || self.timedOut) {
    return;
  }
  self.duration = new Date() - self.start;
  self.finished = true;
  clearTimeout(self.timer);

  if(err) {
    self.deferred.reject({
      exception: err,
      duration: self.duration
    });
    return;
  } else{
    self.deferred.resolve({
      duration: self.duration
    });
    return;
  }
};

from gauge-js.

ivanbportugal avatar ivanbportugal commented on May 29, 2024

Sorry for the busy-ness of this, I think I found a solution. I have a fix. Let me do a PR so you can check it out.

from gauge-js.

philipbeadle avatar philipbeadle commented on May 29, 2024

Yes you need to set the timeout property in the js.properties file.

And lastly we need to increase the timeout from 1 second to about 30. Open the tests/env/default/js.properties file and set the timeout to 30 seconds.

Cheers
Phil

from gauge-js.

Related Issues (20)

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.