To verify that our web site is behaving correctly for our users, I create a functional testing system I am trying. I node Holds a group of JS modules and helpers together in an attempt to get a framework that provides simple, concise test without a pile of nested function callback and I believe that promises can be provided , Therefore my package.json <"^ 4.3.0", "grunt": "^ 0.4.5", "", "official", "gruntfile.js
looks like this:
Module Export = function (grunt) {grunt.initConfig ({webdriver: {// webdriver.io for use with option: {desired) Deprecated: {browserName: 'phantomjs' // no Xvfb required}}, Chrome: {test: ['Chrome /*.js'], option: {desired capabilities: {browser name: 'chrome'}}}}}, Grunt.loadNpmTasks; Grunt.registerTask ('default', ['webdriver']);}
and finally chrome / My test case looks like this in login.js
:
'strict use'; Var chai = is required ('tea'), chiaaprmaj = is required ('Promise in the form of tea'), emphasis; ChaiAspromised.transferPromiseness = browser.transferPromiseness; Chai.use (chaiAsPromised); Assert = chai.assert; Description ('login test', function () (it verifies that the user can log in, function (done) {browser. Url ('https: // localhost /') .setValue ('# userauth_username ',' Foo ') .setValue (' # userauth_password ',' password ') .submitForm (' # form_users_login ') .then (function () {browser.getText (' # auth-user-id ', function (error, Value) {console log (value);}); assert.becomes (browser .getText ('# auth-user-id'), 'foo')}}) // call (done);});});
When I run content webdriver: chrome
on the command line, then I see that it is Chrome It logs and logs in to the website. Auth-user-id 'span is displaying the user's ID correctly after logging, but for some reason browser.getText ()
Is not returning and therefore the test has failed. To give me time to chat with the page in Chrome, go to .submitForm ()
. Followed by a .pause (100) < / Code>, so I know that this is a problem
It seems Land that he is the best and easiest way to do what I want. I'm not sure that I need chai-as-promised
, but maybe I'll move the login function into an included file and promise to enter that as the tea to enter Before the entry is done
var chai = is required ('tea'), cheespromised = requires ('tea-w-promise'), emphasis Say, hope; ChaiAspromised.transferPromiseness = browser.transferPromiseness; Chai.use (chaiAsPromised); Assert = chai.assert; Expectation = Chai. expect; Description ('login test', function () (it verifies that the user can log in, function (done) {browser. Url ('https: // localhost /') .setValue ('# userauth_username ('# Auth-user-id') .gettext ('# auth-user-id'). Then (function (text) {//console.log('Username: '+ text); assert.equal (text,' foo ');}) .saveScreenshot (' out.png ') .Call (done)} (; Login) should not display logincontrol after login, function (done) {browser .isVisible ('# logincontrols'). Then (function (bool) {hope (boo L) .to.be.false;}). Call (done)}; (The login section should be displayed after login ', function (done) {browser .isVisible (' # loggedin '). Then (function (Bo ol) {hope (bool) .to.be.true;}) .col (done)};});
And for the fulfillment, I see:
70mms) after logincontrol is not displayed Should not ✓ should appear connected section after English (58 MMS) 3 pass (8 S)
No comments:
Post a Comment