mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-01 08:34:02 +03:00
fix(recorder): align apiName with the real one (#33567)
This commit is contained in:
parent
88082b417a
commit
099dd80806
@ -225,8 +225,8 @@ export class Recorder implements InstrumentationListener, IRecorder {
|
|||||||
this._highlightedElement = {};
|
this._highlightedElement = {};
|
||||||
this._mode = mode;
|
this._mode = mode;
|
||||||
this._recorderApp?.setMode(this._mode);
|
this._recorderApp?.setMode(this._mode);
|
||||||
this._contextRecorder.setEnabled(this._mode === 'recording' || this._mode === 'assertingText' || this._mode === 'assertingVisibility' || this._mode === 'assertingValue' || this._mode === 'assertingSnapshot');
|
this._contextRecorder.setEnabled(this._isRecording());
|
||||||
this._debugger.setMuted(this._mode === 'recording' || this._mode === 'assertingText' || this._mode === 'assertingVisibility' || this._mode === 'assertingValue');
|
this._debugger.setMuted(this._isRecording());
|
||||||
if (this._mode !== 'none' && this._mode !== 'standby' && this._context.pages().length === 1)
|
if (this._mode !== 'none' && this._mode !== 'standby' && this._context.pages().length === 1)
|
||||||
this._context.pages()[0].bringToFront().catch(() => {});
|
this._context.pages()[0].bringToFront().catch(() => {});
|
||||||
this._refreshOverlay();
|
this._refreshOverlay();
|
||||||
@ -292,7 +292,7 @@ export class Recorder implements InstrumentationListener, IRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onBeforeCall(sdkObject: SdkObject, metadata: CallMetadata) {
|
async onBeforeCall(sdkObject: SdkObject, metadata: CallMetadata) {
|
||||||
if (this._omitCallTracking || this._mode === 'recording' || this._mode === 'assertingText' || this._mode === 'assertingVisibility' || this._mode === 'assertingValue')
|
if (this._omitCallTracking || this._isRecording())
|
||||||
return;
|
return;
|
||||||
this._currentCallsMetadata.set(metadata, sdkObject);
|
this._currentCallsMetadata.set(metadata, sdkObject);
|
||||||
this._updateUserSources();
|
this._updateUserSources();
|
||||||
@ -304,7 +304,7 @@ export class Recorder implements InstrumentationListener, IRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onAfterCall(sdkObject: SdkObject, metadata: CallMetadata) {
|
async onAfterCall(sdkObject: SdkObject, metadata: CallMetadata) {
|
||||||
if (this._omitCallTracking || this._mode === 'recording' || this._mode === 'assertingText' || this._mode === 'assertingVisibility' || this._mode === 'assertingValue')
|
if (this._omitCallTracking || this._isRecording())
|
||||||
return;
|
return;
|
||||||
if (!metadata.error)
|
if (!metadata.error)
|
||||||
this._currentCallsMetadata.delete(metadata);
|
this._currentCallsMetadata.delete(metadata);
|
||||||
@ -354,7 +354,7 @@ export class Recorder implements InstrumentationListener, IRecorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateCallLog(metadatas: CallMetadata[]) {
|
updateCallLog(metadatas: CallMetadata[]) {
|
||||||
if (this._mode === 'recording' || this._mode === 'assertingText' || this._mode === 'assertingVisibility' || this._mode === 'assertingValue')
|
if (this._isRecording())
|
||||||
return;
|
return;
|
||||||
const logs: CallLog[] = [];
|
const logs: CallLog[] = [];
|
||||||
for (const metadata of metadatas) {
|
for (const metadata of metadatas) {
|
||||||
@ -370,6 +370,10 @@ export class Recorder implements InstrumentationListener, IRecorder {
|
|||||||
this._recorderApp?.updateCallLogs(logs);
|
this._recorderApp?.updateCallLogs(logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _isRecording() {
|
||||||
|
return ['recording', 'assertingText', 'assertingVisibility', 'assertingValue', 'assertingSnapshot'].includes(this._mode);
|
||||||
|
}
|
||||||
|
|
||||||
private _readSource(fileName: string): string {
|
private _readSource(fileName: string): string {
|
||||||
try {
|
try {
|
||||||
return fs.readFileSync(fileName, 'utf-8');
|
return fs.readFileSync(fileName, 'utf-8');
|
||||||
|
@ -72,11 +72,11 @@ export async function frameForAction(pageAliases: Map<Page, string>, actionInCon
|
|||||||
|
|
||||||
export function callMetadataForAction(pageAliases: Map<Page, string>, actionInContext: actions.ActionInContext): { callMetadata: CallMetadata, mainFrame: Frame } {
|
export function callMetadataForAction(pageAliases: Map<Page, string>, actionInContext: actions.ActionInContext): { callMetadata: CallMetadata, mainFrame: Frame } {
|
||||||
const mainFrame = mainFrameForAction(pageAliases, actionInContext);
|
const mainFrame = mainFrameForAction(pageAliases, actionInContext);
|
||||||
const { method, params } = traceParamsForAction(actionInContext);
|
const { method, apiName, params } = traceParamsForAction(actionInContext);
|
||||||
|
|
||||||
const callMetadata: CallMetadata = {
|
const callMetadata: CallMetadata = {
|
||||||
id: `call@${createGuid()}`,
|
id: `call@${createGuid()}`,
|
||||||
apiName: 'page.' + method,
|
apiName,
|
||||||
objectId: mainFrame.guid,
|
objectId: mainFrame.guid,
|
||||||
pageId: mainFrame._page.guid,
|
pageId: mainFrame._page.guid,
|
||||||
frameId: mainFrame.guid,
|
frameId: mainFrame.guid,
|
||||||
|
@ -24,7 +24,7 @@ export function buildFullSelector(framePath: string[], selector: string) {
|
|||||||
|
|
||||||
const kDefaultTimeout = 5_000;
|
const kDefaultTimeout = 5_000;
|
||||||
|
|
||||||
export function traceParamsForAction(actionInContext: recorderActions.ActionInContext): { method: string, params: any } {
|
export function traceParamsForAction(actionInContext: recorderActions.ActionInContext): { method: string, apiName: string, params: any } {
|
||||||
const { action } = actionInContext;
|
const { action } = actionInContext;
|
||||||
|
|
||||||
switch (action.name) {
|
switch (action.name) {
|
||||||
@ -32,7 +32,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
const params: channels.FrameGotoParams = {
|
const params: channels.FrameGotoParams = {
|
||||||
url: action.url,
|
url: action.url,
|
||||||
};
|
};
|
||||||
return { method: 'goto', params };
|
return { method: 'goto', apiName: 'page.goto', params };
|
||||||
}
|
}
|
||||||
case 'openPage':
|
case 'openPage':
|
||||||
case 'closePage':
|
case 'closePage':
|
||||||
@ -50,7 +50,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
clickCount: action.clickCount,
|
clickCount: action.clickCount,
|
||||||
position: action.position,
|
position: action.position,
|
||||||
};
|
};
|
||||||
return { method: 'click', params };
|
return { method: 'click', apiName: 'locator.click', params };
|
||||||
}
|
}
|
||||||
case 'press': {
|
case 'press': {
|
||||||
const params: channels.FramePressParams = {
|
const params: channels.FramePressParams = {
|
||||||
@ -58,7 +58,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
strict: true,
|
strict: true,
|
||||||
key: [...toKeyboardModifiers(action.modifiers), action.key].join('+'),
|
key: [...toKeyboardModifiers(action.modifiers), action.key].join('+'),
|
||||||
};
|
};
|
||||||
return { method: 'press', params };
|
return { method: 'press', apiName: 'locator.press', params };
|
||||||
}
|
}
|
||||||
case 'fill': {
|
case 'fill': {
|
||||||
const params: channels.FrameFillParams = {
|
const params: channels.FrameFillParams = {
|
||||||
@ -66,7 +66,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
strict: true,
|
strict: true,
|
||||||
value: action.text,
|
value: action.text,
|
||||||
};
|
};
|
||||||
return { method: 'fill', params };
|
return { method: 'fill', apiName: 'locator.fill', params };
|
||||||
}
|
}
|
||||||
case 'setInputFiles': {
|
case 'setInputFiles': {
|
||||||
const params: channels.FrameSetInputFilesParams = {
|
const params: channels.FrameSetInputFilesParams = {
|
||||||
@ -74,21 +74,21 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
strict: true,
|
strict: true,
|
||||||
localPaths: action.files,
|
localPaths: action.files,
|
||||||
};
|
};
|
||||||
return { method: 'setInputFiles', params };
|
return { method: 'setInputFiles', apiName: 'locator.setInputFiles', params };
|
||||||
}
|
}
|
||||||
case 'check': {
|
case 'check': {
|
||||||
const params: channels.FrameCheckParams = {
|
const params: channels.FrameCheckParams = {
|
||||||
selector,
|
selector,
|
||||||
strict: true,
|
strict: true,
|
||||||
};
|
};
|
||||||
return { method: 'check', params };
|
return { method: 'check', apiName: 'locator.check', params };
|
||||||
}
|
}
|
||||||
case 'uncheck': {
|
case 'uncheck': {
|
||||||
const params: channels.FrameUncheckParams = {
|
const params: channels.FrameUncheckParams = {
|
||||||
selector,
|
selector,
|
||||||
strict: true,
|
strict: true,
|
||||||
};
|
};
|
||||||
return { method: 'uncheck', params };
|
return { method: 'uncheck', apiName: 'locator.uncheck', params };
|
||||||
}
|
}
|
||||||
case 'select': {
|
case 'select': {
|
||||||
const params: channels.FrameSelectOptionParams = {
|
const params: channels.FrameSelectOptionParams = {
|
||||||
@ -96,7 +96,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
strict: true,
|
strict: true,
|
||||||
options: action.options.map(option => ({ value: option })),
|
options: action.options.map(option => ({ value: option })),
|
||||||
};
|
};
|
||||||
return { method: 'selectOption', params };
|
return { method: 'selectOption', apiName: 'locator.selectOption', params };
|
||||||
}
|
}
|
||||||
case 'assertChecked': {
|
case 'assertChecked': {
|
||||||
const params: channels.FrameExpectParams = {
|
const params: channels.FrameExpectParams = {
|
||||||
@ -105,7 +105,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
isNot: !action.checked,
|
isNot: !action.checked,
|
||||||
timeout: kDefaultTimeout,
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', apiName: 'expect.toBeChecked', params };
|
||||||
}
|
}
|
||||||
case 'assertText': {
|
case 'assertText': {
|
||||||
const params: channels.FrameExpectParams = {
|
const params: channels.FrameExpectParams = {
|
||||||
@ -115,7 +115,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
isNot: false,
|
isNot: false,
|
||||||
timeout: kDefaultTimeout,
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', apiName: 'expect.toContainText', params };
|
||||||
}
|
}
|
||||||
case 'assertValue': {
|
case 'assertValue': {
|
||||||
const params: channels.FrameExpectParams = {
|
const params: channels.FrameExpectParams = {
|
||||||
@ -125,7 +125,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
isNot: false,
|
isNot: false,
|
||||||
timeout: kDefaultTimeout,
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', apiName: 'expect.toHaveValue', params };
|
||||||
}
|
}
|
||||||
case 'assertVisible': {
|
case 'assertVisible': {
|
||||||
const params: channels.FrameExpectParams = {
|
const params: channels.FrameExpectParams = {
|
||||||
@ -134,7 +134,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
isNot: false,
|
isNot: false,
|
||||||
timeout: kDefaultTimeout,
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', apiName: 'expect.toBeVisible', params };
|
||||||
}
|
}
|
||||||
case 'assertSnapshot': {
|
case 'assertSnapshot': {
|
||||||
const params: channels.FrameExpectParams = {
|
const params: channels.FrameExpectParams = {
|
||||||
@ -144,7 +144,7 @@ export function traceParamsForAction(actionInContext: recorderActions.ActionInCo
|
|||||||
isNot: false,
|
isNot: false,
|
||||||
timeout: kDefaultTimeout,
|
timeout: kDefaultTimeout,
|
||||||
};
|
};
|
||||||
return { method: 'expect', params };
|
return { method: 'expect', apiName: 'expect.toMatchAriaSnapshot', params };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,10 +49,9 @@ export const ActionListView: React.FC<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const renderAction = (sdkLanguage: Language, action: actionTypes.ActionInContext) => {
|
export const renderAction = (sdkLanguage: Language, action: actionTypes.ActionInContext) => {
|
||||||
const { method, params } = traceParamsForAction(action);
|
const { method, apiName, params } = traceParamsForAction(action);
|
||||||
const locator = params.selector ? asLocator(sdkLanguage || 'javascript', params.selector) : undefined;
|
const locator = params.selector ? asLocator(sdkLanguage || 'javascript', params.selector) : undefined;
|
||||||
|
|
||||||
const apiName = `page.${method}`;
|
|
||||||
return <>
|
return <>
|
||||||
<div className='action-title' title={apiName}>
|
<div className='action-title' title={apiName}>
|
||||||
<span>{apiName}</span>
|
<span>{apiName}</span>
|
||||||
|
Loading…
Reference in New Issue
Block a user