2020-06-11 20:42:52 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
|
*
|
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
*
|
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
export type ActionName =
|
|
|
|
|
|
'goto' |
|
|
|
|
|
|
'fill' |
|
|
|
|
|
|
'press' |
|
|
|
|
|
|
'select';
|
|
|
|
|
|
|
2020-06-12 03:18:33 +02:00
|
|
|
|
export type ActionBase = {
|
|
|
|
|
|
signals: Signal[],
|
|
|
|
|
|
frameUrl?: string,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export type ClickAction = ActionBase & {
|
2020-06-11 20:42:52 +02:00
|
|
|
|
name: 'click',
|
|
|
|
|
|
selector: string,
|
|
|
|
|
|
button: 'left' | 'middle' | 'right',
|
|
|
|
|
|
modifiers: number,
|
|
|
|
|
|
clickCount: number,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-06-12 03:18:33 +02:00
|
|
|
|
export type CheckAction = ActionBase & {
|
2020-06-11 20:42:52 +02:00
|
|
|
|
name: 'check',
|
|
|
|
|
|
selector: string,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-06-12 03:18:33 +02:00
|
|
|
|
export type UncheckAction = ActionBase & {
|
2020-06-11 20:42:52 +02:00
|
|
|
|
name: 'uncheck',
|
|
|
|
|
|
selector: string,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2020-06-12 03:18:33 +02:00
|
|
|
|
export type FillAction = ActionBase & {
|
2020-06-11 20:42:52 +02:00
|
|
|
|
name: 'fill',
|
|
|
|
|
|
selector: string,
|
2020-06-12 03:18:33 +02:00
|
|
|
|
text: string,
|
2020-06-11 20:42:52 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-06-12 03:18:33 +02:00
|
|
|
|
export type NavigateAction = ActionBase & {
|
2020-06-11 20:42:52 +02:00
|
|
|
|
name: 'navigate',
|
2020-06-12 03:18:33 +02:00
|
|
|
|
url: string,
|
2020-06-11 20:42:52 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-06-12 03:18:33 +02:00
|
|
|
|
export type PressAction = ActionBase & {
|
2020-06-11 20:42:52 +02:00
|
|
|
|
name: 'press',
|
|
|
|
|
|
selector: string,
|
2020-06-12 03:18:33 +02:00
|
|
|
|
key: string,
|
|
|
|
|
|
modifiers: number,
|
2020-06-11 20:42:52 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-06-12 03:18:33 +02:00
|
|
|
|
export type SelectAction = ActionBase & {
|
2020-06-11 20:42:52 +02:00
|
|
|
|
name: 'select',
|
|
|
|
|
|
selector: string,
|
|
|
|
|
|
options: string[],
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export type Action = ClickAction | CheckAction | UncheckAction | FillAction | NavigateAction | PressAction | SelectAction;
|
|
|
|
|
|
|
|
|
|
|
|
// Signals.
|
|
|
|
|
|
|
|
|
|
|
|
export type NavigationSignal = {
|
|
|
|
|
|
name: 'navigation',
|
|
|
|
|
|
url: string,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export type Signal = NavigationSignal;
|
|
|
|
|
|
|
|
|
|
|
|
export function actionTitle(action: Action): string {
|
|
|
|
|
|
switch (action.name) {
|
|
|
|
|
|
case 'check':
|
|
|
|
|
|
return 'Check';
|
|
|
|
|
|
case 'uncheck':
|
|
|
|
|
|
return 'Uncheck';
|
|
|
|
|
|
case 'click': {
|
|
|
|
|
|
if (action.clickCount === 1)
|
|
|
|
|
|
return 'Click';
|
|
|
|
|
|
if (action.clickCount === 2)
|
|
|
|
|
|
return 'Double click';
|
|
|
|
|
|
if (action.clickCount === 3)
|
|
|
|
|
|
return 'Triple click';
|
|
|
|
|
|
return `${action.clickCount}× click`;
|
|
|
|
|
|
}
|
|
|
|
|
|
case 'fill':
|
|
|
|
|
|
return 'Fill';
|
|
|
|
|
|
case 'navigate':
|
2020-06-12 03:18:33 +02:00
|
|
|
|
return 'Go to';
|
2020-06-11 20:42:52 +02:00
|
|
|
|
case 'press':
|
|
|
|
|
|
return 'Press';
|
|
|
|
|
|
case 'select':
|
|
|
|
|
|
return 'Select';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|