@qawolf/web
Advanced tools
Comparing version 0.7.3 to 0.7.5
@@ -13,2 +13,3 @@ "use strict"; | ||
const compare_1 = require("./compare"); | ||
const findCss_1 = require("./findCss"); | ||
const query_1 = require("./query"); | ||
@@ -24,2 +25,6 @@ const serialize_1 = require("../serialize"); | ||
const docSelector = serialize_1.htmlSelectorToDocSelector(selector.html); | ||
const nodeName = docSelector.node.name; | ||
if (nodeName === "body" || nodeName === "html") { | ||
return findCss_1.findCss({ css: nodeName }, options); | ||
} | ||
let topElementMatch = null; | ||
@@ -26,0 +31,0 @@ let threshold = options.timeoutMs ? 100 : 75; |
import { Action, DocSelector } from "@qawolf/types"; | ||
declare type QueryDataElementsOptions = { | ||
action?: Action; | ||
dataAttribute?: string; | ||
@@ -12,5 +11,5 @@ dataValue?: string; | ||
export declare const queryActionElements: (action?: "click" | "type" | "scroll" | "select" | undefined) => Element[]; | ||
export declare const queryDataElements: ({ action, dataAttribute, dataValue }: QueryDataElementsOptions) => Element[]; | ||
export declare const queryDataElements: ({ dataAttribute, dataValue }: QueryDataElementsOptions) => Element[]; | ||
export declare const queryElements: (selector: DocSelector, { action, dataAttribute }: QueryElementsOptions) => Element[]; | ||
export declare const queryVisibleElements: (selector: string) => Element[]; | ||
export {}; |
@@ -8,9 +8,4 @@ "use strict"; | ||
}; | ||
exports.queryDataElements = ({ action, dataAttribute, dataValue }) => { | ||
let dataSelector = `[${dataAttribute}='${dataValue}']`; | ||
if (action === "type") { | ||
const selector = `input${dataSelector},select${dataSelector},textarea${dataSelector},[contenteditable="true"]${dataSelector}`; | ||
return exports.queryVisibleElements(selector); | ||
} | ||
return exports.queryVisibleElements(dataSelector); | ||
exports.queryDataElements = ({ dataAttribute, dataValue }) => { | ||
return exports.queryVisibleElements(`[${dataAttribute}='${dataValue}']`); | ||
}; | ||
@@ -22,3 +17,2 @@ exports.queryElements = (selector, { action, dataAttribute }) => { | ||
return exports.queryDataElements({ | ||
action, | ||
dataAttribute, | ||
@@ -25,0 +19,0 @@ dataValue |
@@ -339,5 +339,9 @@ var qawolf = (function (exports) { | ||
var sleep = function (milliseconds) { | ||
return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); }); | ||
}; | ||
var sleep = function (milliseconds) { return __awaiter(void 0, void 0, Promise, function () { | ||
return __generator(this, function (_a) { | ||
if (milliseconds <= 0) | ||
return [2 /*return*/]; | ||
return [2 /*return*/, new Promise(function (resolve) { return setTimeout(resolve, milliseconds); })]; | ||
}); | ||
}); }; | ||
var waitFor = function (valueFunction, timeoutMs, sleepMs) { | ||
@@ -417,9 +421,4 @@ if (sleepMs === void 0) { sleepMs = 500; } | ||
var queryDataElements = function (_a) { | ||
var action = _a.action, dataAttribute = _a.dataAttribute, dataValue = _a.dataValue; | ||
var dataSelector = "[" + dataAttribute + "='" + dataValue + "']"; | ||
if (action === "type") { | ||
var selector = "input" + dataSelector + ",select" + dataSelector + ",textarea" + dataSelector + ",[contenteditable=\"true\"]" + dataSelector; | ||
return queryVisibleElements(selector); | ||
} | ||
return queryVisibleElements(dataSelector); | ||
var dataAttribute = _a.dataAttribute, dataValue = _a.dataValue; | ||
return queryVisibleElements("[" + dataAttribute + "='" + dataValue + "']"); | ||
}; | ||
@@ -432,3 +431,2 @@ var queryElements = function (selector, _a) { | ||
return queryDataElements({ | ||
action: action, | ||
dataAttribute: dataAttribute, | ||
@@ -784,3 +782,3 @@ dataValue: dataValue | ||
var findHtml = function (selector, options) { return __awaiter(void 0, void 0, void 0, function () { | ||
var docSelector, topElementMatch, threshold, elementMatch; | ||
var docSelector, nodeName, topElementMatch, threshold, elementMatch; | ||
return __generator(this, function (_a) { | ||
@@ -794,2 +792,7 @@ switch (_a.label) { | ||
docSelector = htmlSelectorToDocSelector(selector.html); | ||
nodeName = docSelector.node.name; | ||
if (nodeName === "body" || nodeName === "html") { | ||
// use css selector for top level nodes | ||
return [2 /*return*/, findCss({ css: nodeName }, options)]; | ||
} | ||
topElementMatch = null; | ||
@@ -796,0 +799,0 @@ threshold = options.timeoutMs ? 100 : 75; |
@@ -12,5 +12,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sleep = (milliseconds) => { | ||
exports.sleep = (milliseconds) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (milliseconds <= 0) | ||
return; | ||
return new Promise(resolve => setTimeout(resolve, milliseconds)); | ||
}; | ||
}); | ||
exports.waitFor = (valueFunction, timeoutMs, sleepMs = 500) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -17,0 +19,0 @@ const startTime = Date.now(); |
{ | ||
"name": "@qawolf/web", | ||
"description": "qawolf web library", | ||
"version": "0.7.3", | ||
"version": "0.7.5", | ||
"license": "BSD-3.0", | ||
@@ -30,3 +30,3 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@qawolf/types": "^0.7.2", | ||
"@qawolf/types": "^0.7.5", | ||
"rollup": "^1.23.1", | ||
@@ -37,3 +37,3 @@ "rollup-plugin-commonjs": "^10.1.0", | ||
}, | ||
"gitHead": "37c507373ee226bf39ebf7c04a0d29582e76e0ef" | ||
"gitHead": "ed7a68fb816e8fa2581dfa3faa7dedf87fb50ac5" | ||
} |
import { DocSelector, FindElementOptions, Selector } from "@qawolf/types"; | ||
import { DocMatch, matchDocSelector } from "./compare"; | ||
import { findCss } from "./findCss"; | ||
import { queryElements } from "./query"; | ||
@@ -24,2 +25,8 @@ import { htmlSelectorToDocSelector, nodeToDocSelector } from "../serialize"; | ||
const nodeName = docSelector.node.name; | ||
if (nodeName === "body" || nodeName === "html") { | ||
// use css selector for top level nodes | ||
return findCss({ css: nodeName }, options); | ||
} | ||
let topElementMatch: ElementMatch | null = null; | ||
@@ -26,0 +33,0 @@ |
@@ -5,3 +5,2 @@ import { Action, DocSelector } from "@qawolf/types"; | ||
type QueryDataElementsOptions = { | ||
action?: Action; | ||
dataAttribute?: string; | ||
@@ -24,13 +23,6 @@ dataValue?: string; | ||
export const queryDataElements = ({ | ||
action, | ||
dataAttribute, | ||
dataValue | ||
}: QueryDataElementsOptions): Element[] => { | ||
let dataSelector = `[${dataAttribute}='${dataValue}']`; | ||
if (action === "type") { | ||
const selector = `input${dataSelector},select${dataSelector},textarea${dataSelector},[contenteditable="true"]${dataSelector}`; | ||
return queryVisibleElements(selector); | ||
} | ||
return queryVisibleElements(dataSelector); | ||
return queryVisibleElements(`[${dataAttribute}='${dataValue}']`); | ||
}; | ||
@@ -46,3 +38,2 @@ | ||
return queryDataElements({ | ||
action, | ||
dataAttribute, | ||
@@ -49,0 +40,0 @@ dataValue |
@@ -1,2 +0,4 @@ | ||
export const sleep = (milliseconds: number): Promise<void> => { | ||
export const sleep = async (milliseconds: number): Promise<void> => { | ||
if (milliseconds <= 0) return; | ||
return new Promise(resolve => setTimeout(resolve, milliseconds)); | ||
@@ -3,0 +5,0 @@ }; |
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
144195
3042