@qawolf/web
Advanced tools
Comparing version 0.5.13 to 0.5.14
import { Event } from "@qawolf/types"; | ||
export declare const isKeyEvent: (event: Event | null) => boolean | null; | ||
export declare const isPasteEvent: (event: Event | null) => boolean | null; | ||
export declare const isTypeEvent: (event: Event | null) => boolean | null; |
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.isPasteEvent = (event) => event && event.isTrusted && event.name === "paste"; | ||
exports.isTypeEvent = (event) => exports.isKeyEvent(event) || exports.isPasteEvent(event); | ||
//# sourceMappingURL=event.js.map |
@@ -11,3 +11,3 @@ import * as element from "./element"; | ||
export declare type Match = Match; | ||
declare const isKeyEvent: (event: import("@qawolf/types").Event | null) => boolean | null, isPasteEvent: (event: import("@qawolf/types").Event | null) => boolean | null; | ||
declare const isKeyEvent: (event: import("@qawolf/types").Event | null) => boolean | null, isPasteEvent: (event: import("@qawolf/types").Event | null) => boolean | null, isTypeEvent: (event: import("@qawolf/types").Event | null) => boolean | null; | ||
declare const compareArrays: (base?: string[] | null | undefined, compare?: string[] | null | undefined) => number, compareDescriptorKey: (key: "alt" | "ariaLabel" | "classList" | "dataValue" | "href" | "iconContent" | "id" | "inputType" | "isContentEditable" | "labels" | "name" | "parentText" | "placeholder" | "src" | "tagName" | "innerText" | "title" | "xpath", targetValue: string | boolean | string[] | null | undefined, compareValue: string | boolean | string[] | null | undefined) => { | ||
@@ -21,3 +21,3 @@ key: "alt" | "ariaLabel" | "classList" | "dataValue" | "href" | "iconContent" | "id" | "inputType" | "isContentEditable" | "labels" | "name" | "parentText" | "placeholder" | "src" | "tagName" | "innerText" | "title" | "xpath"; | ||
declare const sleep: (milliseconds: number) => Promise<void>, waitFor: <T>(valueFn: () => T | null, timeoutMs: number, sleepMs?: number) => Promise<T | null>, waitUntil: (booleanFn: () => boolean | Promise<boolean>, timeoutMs: number, sleepMs?: number) => Promise<void>; | ||
export { compareArrays, compareDescriptorKey, compareDescriptors, countPresentKeys, isKeyEvent, isNil, isPasteEvent, sleep, waitFor, waitUntil }; | ||
export { compareArrays, compareDescriptorKey, compareDescriptors, countPresentKeys, isKeyEvent, isNil, isPasteEvent, isTypeEvent, sleep, waitFor, waitUntil }; | ||
declare const webExports: { | ||
@@ -24,0 +24,0 @@ element: typeof element; |
@@ -19,5 +19,6 @@ "use strict"; | ||
const xpath = __importStar(require("./xpath")); | ||
const { isKeyEvent, isPasteEvent } = event; | ||
const { isKeyEvent, isPasteEvent, isTypeEvent } = event; | ||
exports.isKeyEvent = isKeyEvent; | ||
exports.isPasteEvent = isPasteEvent; | ||
exports.isTypeEvent = isTypeEvent; | ||
const { compareArrays, compareDescriptorKey, compareDescriptors, countPresentKeys, isNil } = match; | ||
@@ -24,0 +25,0 @@ exports.compareArrays = compareArrays; |
@@ -243,2 +243,5 @@ var qawolf = (function (exports) { | ||
}; | ||
var isTypeEvent = function (event) { | ||
return isKeyEvent(event) || isPasteEvent(event); | ||
}; | ||
@@ -248,3 +251,4 @@ var event = /*#__PURE__*/Object.freeze({ | ||
isKeyEvent: isKeyEvent, | ||
isPasteEvent: isPasteEvent | ||
isPasteEvent: isPasteEvent, | ||
isTypeEvent: isTypeEvent | ||
}); | ||
@@ -785,3 +789,3 @@ | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
var start, startScroll; | ||
var start, startScroll, isScrolled; | ||
return __generator(this, function (_a) { | ||
@@ -796,26 +800,29 @@ switch (_a.label) { | ||
console.log("scroll to", value, element); | ||
isScrolled = function () { | ||
return element.scrollLeft === value.x && element.scrollTop === value.y; | ||
}; | ||
_a.label = 1; | ||
case 1: | ||
if (!(element.scrollLeft !== value.x || element.scrollTop !== value.y)) return [3 /*break*/, 3]; | ||
if (Date.now() - start > timeoutMs) { | ||
console.log("scroll timeout exceeded", { | ||
x: element.scrollLeft, | ||
y: element.scrollTop | ||
}); | ||
if (element.scrollLeft === startScroll.x && | ||
element.scrollTop === startScroll.y) { | ||
throw new Error("could not scroll"); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
element.scroll(value.x, value.y); | ||
return [4 /*yield*/, sleep(100)]; | ||
case 2: | ||
_a.sent(); | ||
element.scroll(value.x, value.y); | ||
return [3 /*break*/, 1]; | ||
_a.label = 3; | ||
case 3: | ||
console.log("scroll succeeeded", { | ||
if (!isScrolled() && Date.now() - start < timeoutMs) return [3 /*break*/, 1]; | ||
_a.label = 4; | ||
case 4: | ||
if (isScrolled()) { | ||
console.log("scroll succeeeded"); | ||
return [2 /*return*/]; | ||
} | ||
console.log("scroll timeout exceeded", { | ||
x: element.scrollLeft, | ||
y: element.scrollTop | ||
}); | ||
// only throw an error if it could not scroll at all | ||
if (element.scrollLeft === startScroll.x && | ||
element.scrollTop === startScroll.y) { | ||
throw new Error("could not scroll"); | ||
} | ||
return [2 /*return*/]; | ||
@@ -828,3 +835,3 @@ } | ||
// export the isomorphic (node & browser) module for node | ||
var isKeyEvent$1 = isKeyEvent, isPasteEvent$1 = isPasteEvent; | ||
var isKeyEvent$1 = isKeyEvent, isPasteEvent$1 = isPasteEvent, isTypeEvent$1 = isTypeEvent; | ||
var compareArrays$1 = compareArrays, compareDescriptorKey$1 = compareDescriptorKey, compareDescriptors$1 = compareDescriptors, countPresentKeys$1 = countPresentKeys, isNil$1 = isNil; | ||
@@ -855,2 +862,3 @@ var sleep$1 = sleep, waitFor$1 = waitFor, waitUntil$1 = waitUntil; | ||
exports.isPasteEvent = isPasteEvent$1; | ||
exports.isTypeEvent = isTypeEvent$1; | ||
exports.sleep = sleep$1; | ||
@@ -857,0 +865,0 @@ exports.waitFor = waitFor$1; |
@@ -20,22 +20,20 @@ "use strict"; | ||
console.log("scroll to", value, element); | ||
while (element.scrollLeft !== value.x || element.scrollTop !== value.y) { | ||
if (Date.now() - start > timeoutMs) { | ||
console.log("scroll timeout exceeded", { | ||
x: element.scrollLeft, | ||
y: element.scrollTop | ||
}); | ||
if (element.scrollLeft === startScroll.x && | ||
element.scrollTop === startScroll.y) { | ||
throw new Error("could not scroll"); | ||
} | ||
return; | ||
} | ||
const isScrolled = () => element.scrollLeft === value.x && element.scrollTop === value.y; | ||
do { | ||
element.scroll(value.x, value.y); | ||
yield wait_1.sleep(100); | ||
element.scroll(value.x, value.y); | ||
} while (!isScrolled() && Date.now() - start < timeoutMs); | ||
if (isScrolled()) { | ||
console.log("scroll succeeeded"); | ||
return; | ||
} | ||
console.log("scroll succeeeded", { | ||
console.log("scroll timeout exceeded", { | ||
x: element.scrollLeft, | ||
y: element.scrollTop | ||
}); | ||
if (element.scrollLeft === startScroll.x && | ||
element.scrollTop === startScroll.y) { | ||
throw new Error("could not scroll"); | ||
} | ||
}); | ||
//# sourceMappingURL=scroll.js.map |
{ | ||
"name": "@qawolf/web", | ||
"description": "qawolf web library", | ||
"version": "0.5.13", | ||
"version": "0.5.14", | ||
"license": "BSD-3.0", | ||
@@ -33,3 +33,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "1f45cf076bcbf323229d5e263e0b8ecf40440a7a" | ||
"gitHead": "cb40ac9ea6354977f96a234a0557381fab20bc53" | ||
} |
@@ -10,1 +10,4 @@ import { Event } from "@qawolf/types"; | ||
event && event.isTrusted && event.name === "paste"; | ||
export const isTypeEvent = (event: Event | null) => | ||
isKeyEvent(event) || isPasteEvent(event); |
@@ -15,3 +15,3 @@ import * as element from "./element"; | ||
// export the isomorphic (node & browser) module for node | ||
const { isKeyEvent, isPasteEvent } = event; | ||
const { isKeyEvent, isPasteEvent, isTypeEvent } = event; | ||
const { | ||
@@ -33,2 +33,3 @@ compareArrays, | ||
isPasteEvent, | ||
isTypeEvent, | ||
sleep, | ||
@@ -35,0 +36,0 @@ waitFor, |
@@ -17,27 +17,27 @@ import { ScrollValue } from "@qawolf/types"; | ||
while (element.scrollLeft !== value.x || element.scrollTop !== value.y) { | ||
if (Date.now() - start > timeoutMs) { | ||
console.log("scroll timeout exceeded", { | ||
x: element.scrollLeft, | ||
y: element.scrollTop | ||
}); | ||
const isScrolled = () => | ||
element.scrollLeft === value.x && element.scrollTop === value.y; | ||
if ( | ||
element.scrollLeft === startScroll.x && | ||
element.scrollTop === startScroll.y | ||
) { | ||
throw new Error("could not scroll"); | ||
} | ||
do { | ||
element.scroll(value.x, value.y); | ||
await sleep(100); | ||
} while (!isScrolled() && Date.now() - start < timeoutMs); | ||
return; | ||
} | ||
await sleep(100); | ||
element.scroll(value.x, value.y); | ||
if (isScrolled()) { | ||
console.log("scroll succeeeded"); | ||
return; | ||
} | ||
console.log("scroll succeeeded", { | ||
console.log("scroll timeout exceeded", { | ||
x: element.scrollLeft, | ||
y: element.scrollTop | ||
}); | ||
// only throw an error if it could not scroll at all | ||
if ( | ||
element.scrollLeft === startScroll.x && | ||
element.scrollTop === startScroll.y | ||
) { | ||
throw new Error("could not scroll"); | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143314
2758