Comments (17)
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.
@philipbeadle This is superb! Thanks a lot!
from gauge-js.
Will definitely be giving this a shot today! Might be worth adding this to the README? What do you guys think?
from gauge-js.
@ivanbportugal There's a new release with the latest fixes. 😄 You may want to do:
$ gauge --update js
from gauge-js.
Also, the docs have been updated with information on async operations.
from gauge-js.
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.
@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.
demo will be here very soon
https://github.com/philipbeadle/gauge-js-angular-webdriver-demo
from gauge-js.
😺 👍 🍻
from gauge-js.
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.
@philipbeadle Nice! Do you mind if we add it as an example for gauge-js
to the README?
from gauge-js.
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.
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.
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.
@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.
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.
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)
- Switch gauge-js to pure javascript grpc
- Unable to SetReadDeadLine on runner: set tcp 127.0.0.1:51101: use of closed network connection HOT 3
- Unable to add JS webdriver for gauge. HOT 2
- OpenBrowser failures are not reported correctly. HOT 2
- package.json can't be in directory above
- Incomplete Stacktraces on test failures
- Taiko confirm(func) doesn't work with gauge-js HOT 4
- Array parameters become non-array when passed from inside a step HOT 4
- multi-threads for js runner HOT 3
- AfterSuite hook receives a "null context value HOT 1
- AfterSuite hook receives a "null" context value HOT 4
- js runner quit unexpectedly. Check logs for more details HOT 1
- Feature request: access table data by column name instead of column index HOT 3
- How to use same table parameters used for a Gauge spec across multiple senarios? HOT 1
- example.spec has an error in ## Display number of items HOT 1
- Unable to install Gauge Js plugin HOT 2
- Unable to install Gauge Js plugin on mac HOT 7
- Unable to run async functions within a step table HOT 6
- NodeJs 16 Gauge-JS plugin installation takes an hour of time in Ubuntu Container HOT 3
- Failed to install plugin 'js' for Gauge HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gauge-js.