fix(codegen): add timeout to our actions, catch errors (#5188)
This commit is contained in:
parent
ff6b2b1dd4
commit
321a873d8a
|
|
@ -608,7 +608,7 @@ export class Recorder {
|
||||||
|
|
||||||
private async _performAction(action: actions.Action) {
|
private async _performAction(action: actions.Action) {
|
||||||
this._performingAction = true;
|
this._performingAction = true;
|
||||||
await window.playwrightRecorderPerformAction(action);
|
await window.playwrightRecorderPerformAction(action).catch(e => {});
|
||||||
this._performingAction = false;
|
this._performingAction = false;
|
||||||
|
|
||||||
// Action could have changed DOM, update hovered model selectors.
|
// Action could have changed DOM, update hovered model selectors.
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,11 @@ export class CodeGenerator {
|
||||||
this._currentAction = action;
|
this._currentAction = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
performedActionFailed(action: ActionInContext) {
|
||||||
|
if (this._currentAction === action)
|
||||||
|
this._currentAction = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
didPerformAction(actionInContext: ActionInContext) {
|
didPerformAction(actionInContext: ActionInContext) {
|
||||||
const { action, pageAlias } = actionInContext;
|
const { action, pageAlias } = actionInContext;
|
||||||
let eraseLastAction = false;
|
let eraseLastAction = false;
|
||||||
|
|
|
||||||
|
|
@ -194,21 +194,27 @@ export class RecorderSupplement {
|
||||||
action
|
action
|
||||||
};
|
};
|
||||||
this._generator.willPerformAction(actionInContext);
|
this._generator.willPerformAction(actionInContext);
|
||||||
if (action.name === 'click') {
|
try {
|
||||||
const { options } = toClickOptions(action);
|
const kActionTimeout = 5000;
|
||||||
await frame.click(controller, action.selector, options);
|
if (action.name === 'click') {
|
||||||
|
const { options } = toClickOptions(action);
|
||||||
|
await frame.click(controller, action.selector, { ...options, timeout: kActionTimeout });
|
||||||
|
}
|
||||||
|
if (action.name === 'press') {
|
||||||
|
const modifiers = toModifiers(action.modifiers);
|
||||||
|
const shortcut = [...modifiers, action.key].join('+');
|
||||||
|
await frame.press(controller, action.selector, shortcut, { timeout: kActionTimeout });
|
||||||
|
}
|
||||||
|
if (action.name === 'check')
|
||||||
|
await frame.check(controller, action.selector, { timeout: kActionTimeout });
|
||||||
|
if (action.name === 'uncheck')
|
||||||
|
await frame.uncheck(controller, action.selector, { timeout: kActionTimeout });
|
||||||
|
if (action.name === 'select')
|
||||||
|
await frame.selectOption(controller, action.selector, [], action.options.map(value => ({ value })), { timeout: kActionTimeout });
|
||||||
|
} catch (e) {
|
||||||
|
this._generator.performedActionFailed(actionInContext);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (action.name === 'press') {
|
|
||||||
const modifiers = toModifiers(action.modifiers);
|
|
||||||
const shortcut = [...modifiers, action.key].join('+');
|
|
||||||
await frame.press(controller, action.selector, shortcut);
|
|
||||||
}
|
|
||||||
if (action.name === 'check')
|
|
||||||
await frame.check(controller, action.selector);
|
|
||||||
if (action.name === 'uncheck')
|
|
||||||
await frame.uncheck(controller, action.selector);
|
|
||||||
if (action.name === 'select')
|
|
||||||
await frame.selectOption(controller, action.selector, [], action.options.map(value => ({ value })));
|
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
actionInContext.committed = true;
|
actionInContext.committed = true;
|
||||||
this._timers.delete(timer);
|
this._timers.delete(timer);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue