I have this testing file of an html button:
const { Given, When, Then } = require('cucumber');
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const chai = require('chai');
const expect = chai.expect;
chai.use(require('chai-dom'));
Given('I go to the project', {timeout: 90 * 1000},function(callback) {
browser.driver.manage().window().maximize();
browser.get('http://localhost:8080/#/').then(callback);
});
//WHEN i FILL A FORM
When('I put a BLANK id',{timeout: 90 * 1000}, function( callback) {
element(by.css("*[id='field_identificador']")).click();
element(by.css("*[id='field_identificador']")).sendKeys('').then(callback);
});
Then(' button Save should be DISabled', function() {
const dom = new JSDOM(` <button id="ref_button" type="submit" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary"> `);
dom.window.document.getElementById("ref_button").should.have.attr('disabled');
}
When I do the same thing with jasmine it works. But now I am using Chai to write the expectations. And it appears to not fing th disabled attribute. The error is this:** AssertionError: expected [object HTMLButtonElement] to have an attribute 'disabled'**
Aucun commentaire:
Enregistrer un commentaire