diff --git a/src/dom.ts b/src/dom.ts index 925e46c91b6ed..78e43f162d3d9 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -383,12 +383,14 @@ export class ElementHandle extends js.JSHandle { progress.log(apiLog, `elementHandle.fill("${value}")`); assert(helper.isString(value), 'Value must be string. Found value "' + value + '" of type "' + (typeof value) + '"'); await this._page._frameManager.waitForSignalsCreatedBy(progress, options.noWaitAfter, async () => { + progress.log(apiLog, ' waiting for element to be visible, enabled and editable'); const poll = await this._evaluateHandleInUtility(([injected, node, value]) => { return injected.waitForEnabledAndFill(node, value); }, value); const pollHandler = new InjectedScriptPollHandler(progress, poll); const injectedResult = await pollHandler.finish(); const needsInput = handleInjectedResult(injectedResult); + progress.log(apiLog, ' element is visible, enabled and editable'); progress.throwIfAborted(); // Avoid action that has side-effects. if (needsInput) { if (value) @@ -535,7 +537,7 @@ export class ElementHandle extends js.JSHandle { } async _waitForDisplayedAtStablePositionAndEnabled(progress: Progress): Promise { - progress.log(apiLog, ' waiting for element to be displayed, enabled and not moving'); + progress.log(apiLog, ' waiting for element to be visible, enabled and not moving'); const rafCount = this._page._delegate.rafCountForStablePosition(); const poll = this._evaluateHandleInUtility(([injected, node, rafCount]) => { return injected.waitForDisplayedAtStablePositionAndEnabled(node, rafCount); @@ -543,7 +545,7 @@ export class ElementHandle extends js.JSHandle { const pollHandler = new InjectedScriptPollHandler(progress, await poll); const injectedResult = await pollHandler.finish(); handleInjectedResult(injectedResult); - progress.log(apiLog, ' element is displayed and does not move'); + progress.log(apiLog, ' element is visible, enabled and does not move'); } async _checkHitTargetAt(point: types.Point): Promise { diff --git a/src/injected/injectedScript.ts b/src/injected/injectedScript.ts index 9b4cbd01b7bb7..a6b7f8653780a 100644 --- a/src/injected/injectedScript.ts +++ b/src/injected/injectedScript.ts @@ -161,12 +161,18 @@ export default class InjectedScript { }; }); + let lastLog = ''; const progress: types.InjectedScriptProgress = { canceled: false, log: (message: string) => { + lastLog = message; currentLogs.push(message); logReady(); }, + logRepeating: (message: string) => { + if (message !== lastLog) + progress.log(message); + }, }; // It is important to create logs promise before running the poll to capture logs from the first run. @@ -225,14 +231,16 @@ export default class InjectedScript { } waitForEnabledAndFill(node: Node, value: string): types.InjectedScriptPoll> { - return this.poll('raf', () => { + return this.poll('raf', progress => { if (node.nodeType !== Node.ELEMENT_NODE) return { status: 'error', error: 'Node is not of type HTMLElement' }; const element = node as HTMLElement; if (!element.isConnected) return { status: 'notconnected' }; - if (!this.isVisible(element)) + if (!this.isVisible(element)) { + progress.logRepeating(' element is not visible - waiting...'); return false; + } if (element.nodeName.toLowerCase() === 'input') { const input = element as HTMLInputElement; const type = (input.getAttribute('type') || '').toLowerCase(); @@ -245,10 +253,14 @@ export default class InjectedScript { if (isNaN(Number(value))) return { status: 'error', error: 'Cannot type text into input[type=number].' }; } - if (input.disabled) + if (input.disabled) { + progress.logRepeating(' element is disabled - waiting...'); return false; - if (input.readOnly) + } + if (input.readOnly) { + progress.logRepeating(' element is readonly - waiting...'); return false; + } if (kDateTypes.has(type)) { value = value.trim(); input.focus(); @@ -261,10 +273,14 @@ export default class InjectedScript { } } else if (element.nodeName.toLowerCase() === 'textarea') { const textarea = element as HTMLTextAreaElement; - if (textarea.disabled) + if (textarea.disabled) { + progress.logRepeating(' element is disabled - waiting...'); return false; - if (textarea.readOnly) + } + if (textarea.readOnly) { + progress.logRepeating(' element is readonly - waiting...'); return false; + } } else if (!element.isContentEditable) { return { status: 'error', error: 'Element is not an ,