Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ When('I refresh page', async function () {
* Press button
* @param {string} key - key to press
* @example I press 'Enter' key
* @example I press 'Control+C' keys
*/
When('I press {string} key', async function (key: string) {
When('I press {string} key(s)', async function (key: string) {
await page.press('body', key);
});

Expand All @@ -126,8 +127,9 @@ When('I press {string} key', async function (key: string) {
* @param {string} key - key to press
* @param {number} num - number of times
* @example I press 'Enter' key 5 times
* @example I press 'Control+V' keys 5 times
*/
When('I press {string} key {int} time(s)', async function (key: string, num: number) {
When('I press {string} key(s) {int} time(s)', async function (key: string, num: number) {
for (let i: number = 0; i < num; i++) {
await page.keyboard.press(key);
}
Expand Down
17 changes: 16 additions & 1 deletion test-e2e/apps/actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
</div>

<div id="ignoreHierarchyComponent"></div>

<div contenteditable="true" id="contentEditable">this is content editable text</div>
<div>
<pre id="keywordevent"></pre>
</div>
<script>
const action = document.querySelector('#action');
const button = document.querySelector('#button');
Expand All @@ -60,6 +63,7 @@
const pressCounter = document.querySelector('#pressCounter');
const confirm = document.querySelector('#confirm');
const prompt = document.querySelector('#prompt');
const keywordEvent = document.querySelector('#keywordevent');
let presses = 0;

button.addEventListener('click', function () {
Expand Down Expand Up @@ -92,6 +96,17 @@
})
});

body.addEventListener('keydown', function (event) {
keywordEvent.innerText = JSON.stringify({
code: event.code,
keyCode: event.keyCode,
metaKey: event.metaKey,
shiftKey: event.shiftKey,
ctrlKey: event.ctrlKey,
altKey: event.altKey
});
});

body.addEventListener('keypress', function () {
action.innerText = 'keypress'
});
Expand Down
5 changes: 5 additions & 0 deletions test-e2e/features/actions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ Feature: actions
When I press 'w' key
Then I expect text of 'Action' to be equal 'keypress'

Scenario: press key with modifier
And I press 'Alt+a' key
Then I expect text of 'Key Dump' to contain '"keyCode":65'
Then I expect text of 'Key Dump' to contain '"altKey":true'

Scenario Outline: press <Key> key multiple times
When I press '<Key>' key <Times> time<Postfix>
Then I expect text of 'Press Counter' to be equal '<Result>'
Expand Down
2 changes: 1 addition & 1 deletion test-e2e/page_object/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class App {

IgnoreHierarchyComponent = $(new IgnoreHierarchyComponent('#ignoreHierarchyComponent'));
ComponentWithoutSelector = $(new ComponentWithoutSelector());

KeyDump = $('#keywordevent');
}

class IgnoreHierarchyComponent extends Component {
Expand Down
7 changes: 4 additions & 3 deletions test-e2e/webui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ const common = {
memory: new Memory(),
pageObject: new App(),
parallel: 4,
publishQuiet: true
publishQuiet: true,
retry: 1
}

export default common;

export const debug = {
...common,
retry: 0,
tags: '@debug',
browser: {
logLevel: 'warn',
Expand All @@ -42,6 +44,5 @@ export const debug = {
dir: 'customDir',
attach: true
}
},
retry: 1
}
}