Skip to content

Commit

Permalink
fix: improve code in runner (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Feb 21, 2022
1 parent 3d68273 commit da5521e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/PuppeteerRunnerExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class PuppeteerRunnerExtension extends RunnerExtension {
for (const f of frames) {
if (f.isOOPFrame() && f.url() === step.target) {
targetFrame = f;
break;
}
}
if (!targetFrame) {
Expand Down Expand Up @@ -119,20 +120,20 @@ export class PuppeteerRunnerExtension extends RunnerExtension {
if (typeableInputTypes.has(inputType)) {
const textToType = await element.evaluate(
(el: Element, newValue: string) => {
/* c8 ignore next 10 */
/* c8 ignore next 13 */
const input = el as HTMLInputElement;
if (
newValue.length > input.value.length &&
newValue.startsWith(input.value)
newValue.length <= input.value.length ||
!newValue.startsWith(input.value)
) {
const originalValue = input.value;
// Move cursor to the end of the common prefix.
input.value = '';
input.value = originalValue;
return newValue.substring(originalValue.length);
return newValue;
}
const originalValue = input.value;
// Move cursor to the end of the common prefix.
input.value = '';
return newValue;
input.value = originalValue;
return newValue.substring(originalValue.length);
},
step.value
);
Expand Down

0 comments on commit da5521e

Please sign in to comment.