2015-05-29 17:33:54 -04:00
|
|
|
import {verifyNoBrowserErrors} from 'angular2/src/test_lib/e2e_util';
|
|
|
|
|
|
|
|
describe('key_events', function() {
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
var URL = 'examples/src/key_events/index.html';
|
|
|
|
|
2015-05-29 17:33:54 -04:00
|
|
|
afterEach(verifyNoBrowserErrors);
|
|
|
|
beforeEach(() => { browser.get(URL); });
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
it('should display correct key names', function() {
|
|
|
|
var firstArea = element.all(by.css('.sample-area')).get(0);
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('(none)');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
// testing different key categories:
|
|
|
|
firstArea.sendKeys(protractor.Key.ENTER);
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('enter');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
firstArea.sendKeys(protractor.Key.SHIFT, protractor.Key.ENTER);
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('shift.enter');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
firstArea.sendKeys(protractor.Key.CONTROL, protractor.Key.SHIFT, protractor.Key.ENTER);
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('control.shift.enter');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
firstArea.sendKeys(' ');
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('space');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
2015-06-02 08:37:57 -04:00
|
|
|
// It would not work with a letter which position depends on the keyboard layout (ie AZERTY vs
|
|
|
|
// QWERTY), see https://code.google.com/p/chromedriver/issues/detail?id=553
|
|
|
|
firstArea.sendKeys('u');
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('u');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
firstArea.sendKeys(protractor.Key.CONTROL, 'b');
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('control.b');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
firstArea.sendKeys(protractor.Key.F1);
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('f1');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
firstArea.sendKeys(protractor.Key.ALT, protractor.Key.F1);
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('alt.f1');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
firstArea.sendKeys(protractor.Key.CONTROL, protractor.Key.F1);
|
2015-05-29 17:33:54 -04:00
|
|
|
expect(firstArea.getText()).toEqual('control.f1');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
|
|
|
|
// There is an issue with protractor.Key.NUMPAD0 (and other NUMPADx):
|
|
|
|
// chromedriver does not correctly set the location property on the event to
|
|
|
|
// specify that the key is on the numeric keypad (event.location = 3)
|
|
|
|
// so the following test fails:
|
|
|
|
// firstArea.sendKeys(protractor.Key.NUMPAD0);
|
2015-05-29 17:33:54 -04:00
|
|
|
// expect(firstArea.getText()).toEqual('0');
|
feat(keyEvents): support for <div (keyup.enter)="callback()">
This commit adds a plugin for the event manager, to allow a key name to
be appended to the event name (for keyup and keydown events), so that
the callback is only called for that key.
Here are some examples:
(keydown.shift.enter)
(keyup.space)
(keydown.control.shift.a)
(keyup.f1)
Key names mostly follow the DOM Level 3 event key values:
http://www.w3.org/TR/DOM-Level-3-Events-key/#key-value-tables
There are some limitations to be worked on (cf details
in https://github.com/angular/angular/pull/1136) but for now, this
implementation is reliable for the following keys (by "reliable" I mean
compatible with Chrome and Firefox and not depending on the keyboard
layout):
- alt, control, shift, meta (those keys can be combined with other keys)
- tab, enter, backspace, pause, scrolllock, capslock, numlock
- insert, delete, home, end, pageup, pagedown
- arrowup, arrowdown, arrowleft, arrowright
- latin letters (a-z), function keys (f1-f12)
- numbers on the numeric keypad (but those keys are not correctly simulated
by Chromedriver)
There is a sample to play with in examples/src/key_events/.
close #523
close #1136
2015-04-10 07:22:00 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should correctly react to the specified key', function() {
|
|
|
|
var secondArea = element.all(by.css('.sample-area')).get(1);
|
|
|
|
secondArea.sendKeys(protractor.Key.SHIFT, protractor.Key.ENTER);
|
|
|
|
expect(secondArea.getText()).toEqual('You pressed shift.enter!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not react to incomplete keys', function() {
|
|
|
|
var secondArea = element.all(by.css('.sample-area')).get(1);
|
|
|
|
secondArea.sendKeys(protractor.Key.ENTER);
|
|
|
|
expect(secondArea.getText()).toEqual('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not react to keys with more modifiers', function() {
|
|
|
|
var secondArea = element.all(by.css('.sample-area')).get(1);
|
|
|
|
secondArea.sendKeys(protractor.Key.CONTROL, protractor.Key.SHIFT, protractor.Key.ENTER);
|
|
|
|
expect(secondArea.getText()).toEqual('');
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|