mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
feat(screenshot): Add screenshot function to e2e test (button and checkbox) (#2532)
* Add screenshot function to e2e test (button and checkbox) * Add reporter for jasmine * Change directory to constant, and use variable to store name
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
import {browser, by, element} from 'protractor';
|
||||
import {screenshot} from '../../screenshot';
|
||||
|
||||
|
||||
describe('button', function () {
|
||||
describe('disabling behavior', function () {
|
||||
beforeEach(function() {
|
||||
browser.get('/button');
|
||||
});
|
||||
|
||||
it('should prevent click handlers from executing when disabled', function () {
|
||||
element(by.id('test-button')).click();
|
||||
expect(element(by.id('click-counter')).getText()).toEqual('1');
|
||||
screenshot('clicked once');
|
||||
|
||||
element(by.id('disable-toggle')).click();
|
||||
element(by.id('test-button')).click();
|
||||
expect(element(by.id('click-counter')).getText()).toEqual('1');
|
||||
screenshot('click disabled');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {browser, by, element, Key} from 'protractor';
|
||||
import {screenshot} from '../../screenshot';
|
||||
|
||||
describe('checkbox', function () {
|
||||
|
||||
@@ -12,15 +13,18 @@ describe('checkbox', function () {
|
||||
let checkboxEl = element(by.id('test-checkbox'));
|
||||
let inputEl = element(by.css('input[id=input-test-checkbox]'));
|
||||
|
||||
screenshot('start');
|
||||
checkboxEl.click();
|
||||
inputEl.getAttribute('checked').then((value: string) => {
|
||||
expect(value).toBeTruthy('Expect checkbox "checked" property to be true');
|
||||
});
|
||||
screenshot('checked');
|
||||
|
||||
checkboxEl.click();
|
||||
inputEl.getAttribute('checked').then((value: string) => {
|
||||
expect(value).toBeFalsy('Expect checkbox "checked" property to be false');
|
||||
});
|
||||
screenshot('unchecked');
|
||||
});
|
||||
|
||||
it('should toggle the checkbox when pressing space', () => {
|
||||
@@ -28,12 +32,14 @@ describe('checkbox', function () {
|
||||
|
||||
inputEl.getAttribute('checked').then((value: string) => {
|
||||
expect(value).toBeFalsy('Expect checkbox "checked" property to be false');
|
||||
screenshot('start');
|
||||
});
|
||||
|
||||
inputEl.sendKeys(Key.SPACE);
|
||||
|
||||
inputEl.getAttribute('checked').then((value: string) => {
|
||||
expect(value).toBeTruthy('Expect checkbox "checked" property to be true');
|
||||
screenshot('pressed space');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user