@applitools/driver
Advanced tools
Comparing version 1.0.7 to 1.1.0
@@ -7,19 +7,25 @@ { | ||
"version": "file:../dry-run.tgz", | ||
"integrity": "sha512-HyFiAetTZmMS1IbKZrHKlJG0tOhbze0pZPDDjFKB/Q4g68Q2+bqZw1SOqrc1bRlnHtNJ8T8FAU1+rlmtbsInqw==", | ||
"integrity": "sha512-u+leMyDOpfDemMXOEueO0V5KC3o9LULKXjfGutDhvtUwx9b0dRUQ8pO32hdoVybZTRFKD24+1yrs6EyDuzLoXQ==", | ||
"requires": { | ||
"@applitools/snippets": "2.1.3", | ||
"@applitools/utils": "1.2.0" | ||
"@applitools/snippets": "2.1.4", | ||
"@applitools/types": "1.0.6", | ||
"@applitools/utils": "1.2.1" | ||
} | ||
}, | ||
"@applitools/snippets": { | ||
"version": "2.1.3", | ||
"resolved": "https://registry.npmjs.org/@applitools/snippets/-/snippets-2.1.3.tgz", | ||
"integrity": "sha512-c4efLfVK/yHBPJnNjqO8GcEd98m276NgPhUy+b7aIf2MazbQq2kYMnDUsONeKXS8SucnPyuhFO1JL6xkq9bnYw==" | ||
"version": "2.1.4", | ||
"resolved": "https://registry.npmjs.org/@applitools/snippets/-/snippets-2.1.4.tgz", | ||
"integrity": "sha512-Jmp+DM9Kj24+ByMaqoKxhMNsefsSshN5+MLyMyrFurb1FGRGoSMmAT5bZCI7zKFG02pxZmjBmenMhpNQbzZR/A==" | ||
}, | ||
"@applitools/types": { | ||
"version": "1.0.6", | ||
"resolved": "https://registry.npmjs.org/@applitools/types/-/types-1.0.6.tgz", | ||
"integrity": "sha512-g0dC0+l8lPVsdblloVSX26rFTt6t3RAZnf5G0hZtjPDjT89oICtPytGRNmSqG7Sm1+DhywmEwtL+07ZzWE9uXw==" | ||
}, | ||
"@applitools/utils": { | ||
"version": "1.2.0", | ||
"resolved": "https://registry.npmjs.org/@applitools/utils/-/utils-1.2.0.tgz", | ||
"integrity": "sha512-NzynRgRavbTns5M85DJXXaMY/57xBte3F/tnK5nr3DSBhKTQnkjXIFwryPU5bVwEcpoGEVF0T1Gyq37WnDe38Q==" | ||
"version": "1.2.1", | ||
"resolved": "https://registry.npmjs.org/@applitools/utils/-/utils-1.2.1.tgz", | ||
"integrity": "sha512-lIHYqgirhkyL+xAc9+FwidAvcI7apB/6Y7uyVimHdTRjjIwAqoazymwYiFZiia+q81F/smPLvMw2RUwU6wi13w==" | ||
} | ||
} | ||
} |
@@ -6,2 +6,12 @@ # Change Log | ||
## 1.1.0 - 2021/8/4 | ||
- add types support | ||
- add default implementation for element comparison | ||
- add native device automation support | ||
- updated to @applitools/types@1.0.5 (from 1.0.4) | ||
- updated to @applitools/snippets@2.1.4 (from 2.1.3) | ||
- updated to @applitools/types@1.0.6 (from 1.0.5) | ||
- updated to @applitools/utils@1.2.1 (from 1.2.0) | ||
## 1.0.7 - 2021/6/8 | ||
@@ -8,0 +18,0 @@ |
{ | ||
"name": "@applitools/driver", | ||
"version": "1.0.7", | ||
"version": "1.1.0", | ||
"description": "Applitools universal framework wrapper", | ||
@@ -26,3 +26,4 @@ "keywords": [ | ||
}, | ||
"main": "./index.js", | ||
"main": "./dist/index.js", | ||
"types": "./types/index.d.ts", | ||
"directories": { | ||
@@ -33,3 +34,5 @@ "lib": "./src", | ||
"scripts": { | ||
"lint": "eslint . --ext .js", | ||
"lint": "eslint '**/*.ts' '**/*.js'", | ||
"build": "tsc", | ||
"test": "mocha --no-timeouts -r ts-node/register ./test/**/*.spec.ts", | ||
"deps": "bongo deps", | ||
@@ -46,8 +49,14 @@ "preversion": "bongo preversion", | ||
"dependencies": { | ||
"@applitools/snippets": "2.1.3", | ||
"@applitools/utils": "1.2.0" | ||
"@applitools/snippets": "2.1.4", | ||
"@applitools/types": "1.0.6", | ||
"@applitools/utils": "1.2.1" | ||
}, | ||
"devDependencies": { | ||
"@applitools/sdk-release-kit": "0.13.0", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.3.3", | ||
"@typescript-eslint/eslint-plugin": "^4.28.3", | ||
"@typescript-eslint/parser": "^4.28.3", | ||
"eslint": "^7.9.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-mocha-no-only": "^1.1.1", | ||
@@ -57,3 +66,6 @@ "eslint-plugin-node": "^11.1.0", | ||
"husky": "^4.3.7", | ||
"prettier": "1.19.0" | ||
"mocha": "^9.0.3", | ||
"prettier": "^2.3.2", | ||
"ts-node": "^10.1.0", | ||
"typescript": "^4.3.5" | ||
}, | ||
@@ -60,0 +72,0 @@ "engines": { |
const utils = require('@applitools/utils') | ||
const snippets = require('@applitools/snippets') | ||
/** | ||
* Returns viewport size of current context | ||
* @param {Logger} logger | ||
* @param {EyesContext} context | ||
* @return {RectangleSize} viewport size | ||
*/ | ||
async function getViewportSize(logger, context) { | ||
logger.verbose('EyesUtils.getViewportSize()') | ||
let size | ||
if (!context.driver.isNative) { | ||
size = await context.execute(snippets.getViewportSize) | ||
} else { | ||
const rect = await context.driver.getWindowSize() | ||
size = {width: rect.width, height: rect.height} | ||
if (size.height > size.width) { | ||
const orientation = await context.driver.getOrientation() | ||
if (orientation === 'landscape') { | ||
size = {width: size.height, height: size.width} | ||
} | ||
} | ||
} | ||
logger.verbose('Done! Viewport size: ', size) | ||
return size | ||
async function getViewportSize({driver}) { | ||
return driver.mainContext.execute(snippets.getViewportSize) | ||
} | ||
/** | ||
* Set viewport size of the window | ||
* @param {Logger} logger | ||
* @param {EyesContext} context | ||
* @param {RectangleSize} requiredViewportSize - required viewport size to set | ||
*/ | ||
async function setViewportSize(logger, context, requiredViewportSize) { | ||
async function setViewportSize({driver, size, logger}) { | ||
// First we will set the window size to the required size. | ||
// Then we'll check the viewport size and increase the window size accordingly. | ||
const requiredViewportSize = size | ||
logger.verbose(`setViewportSize(${requiredViewportSize})`) | ||
let actualViewportSize = await getViewportSize(logger, context) | ||
let actualViewportSize = await driver.getViewportSize() | ||
logger.verbose(`Initial viewport size: ${actualViewportSize}`) | ||
@@ -45,3 +20,3 @@ // If the viewport size is already the required size | ||
let actualWindowSize = await context.driver.getWindowSize() | ||
actualViewportSize = await getViewportSize(logger, context) | ||
actualViewportSize = await driver.getViewportSize() | ||
logger.verbose(`actualWindowSize: ${actualWindowSize}, actualViewportSize: ${actualViewportSize}`) | ||
@@ -60,3 +35,3 @@ | ||
await utils.general.sleep(sleep) | ||
actualViewportSize = await getViewportSize(logger, context) | ||
actualViewportSize = await driver.getViewportSize() | ||
if (utils.geometry.equals(actualViewportSize, requiredViewportSize)) return true | ||
@@ -90,45 +65,9 @@ logger.verbose( | ||
} | ||
/** | ||
* Get content size of the specified element | ||
* @param {Logger} _logger | ||
* @param {EyesContext} context | ||
* @param {EyesElement} element | ||
* @returns {Promise<Region>} element content size | ||
*/ | ||
async function getElementContentSize(_logger, context, element) { | ||
try { | ||
const {width = 0, height = 0} = await context.execute(snippets.getElementContentSize, [element]) | ||
return {width, height} | ||
} catch (err) { | ||
throw new Error('Failed to extract element size!', err) | ||
} | ||
async function getElementContentSize({context, element}) { | ||
return context.execute(snippets.getElementContentSize, [element]) | ||
} | ||
/** | ||
* Get element client rect relative to the current context | ||
* @param {Logger} _logger | ||
* @param {EyesContext} context | ||
* @param {EyesElement} element | ||
* @return {Promise<Region>} element client rect | ||
*/ | ||
async function getElementClientRect(_logger, context, element) { | ||
const rect = await context.execute(snippets.getElementRect, [element, true]) | ||
return rect | ||
async function getElementRegion({context, element, withBorders = true}) { | ||
return context.execute(snippets.getElementRect, [element, withBorders]) | ||
} | ||
/** | ||
* Get element rect relative to the current context | ||
* @param {Logger} _logger | ||
* @param {EyesContext} context | ||
* @param {EyesElement} element | ||
* @return {Promise<Region>} element rect | ||
*/ | ||
async function getElementRect(_logger, context, element) { | ||
const rect = await context.execute(snippets.getElementRect, [element, false]) | ||
return rect | ||
} | ||
/** | ||
* Get device pixel ratio | ||
* @param {Logger} _logger | ||
* @param {EyesContext} context | ||
* @return {Promise<number>} device pixel ratio | ||
*/ | ||
async function getPixelRatio(_logger, context) { | ||
@@ -139,4 +78,3 @@ const pixelRatio = await context.execute(snippets.getPixelRatio) | ||
async function getUserAgent(_logger, context) { | ||
const userAgent = await context.execute(snippets.getUserAgent) | ||
return userAgent | ||
return context.execute(snippets.getUserAgent) | ||
} | ||
@@ -147,9 +85,2 @@ async function getInnerOffset(_logger, context, element) { | ||
} | ||
/** | ||
* Get current context scroll position of the specified element or default scrolling element | ||
* @param {Logger} _logger | ||
* @param {EyesContext} context | ||
* @param {EyesElement} [element] - element to extract scroll position | ||
* @return {Promise<Location>} scroll position | ||
*/ | ||
async function getScrollOffset(_logger, context, element) { | ||
@@ -159,23 +90,5 @@ const {x = 0, y = 0} = await context.execute(snippets.getElementScrollOffset, [element]) | ||
} | ||
/** | ||
* Set current context scroll position for the specified element or default scrolling element | ||
* @param {Logger} _logger | ||
* @param {EyesContext} context | ||
* @param {Location} location - required scroll position | ||
* @param {EyesElement} [element] - element to set scroll position | ||
* @return {Promise<Location>} actual scroll position after set | ||
*/ | ||
async function scrollTo(_logger, context, offset, element) { | ||
return context.execute(snippets.scrollTo, [ | ||
element, | ||
{x: Math.round(offset.x), y: Math.round(offset.y)}, | ||
]) | ||
return context.execute(snippets.scrollTo, [element, {x: Math.round(offset.x), y: Math.round(offset.y)}]) | ||
} | ||
/** | ||
* Get translate position of the specified element or default scrolling element | ||
* @param {Logger} _logger | ||
* @param {EyesContext} context | ||
* @param {EyesElement} [element] - element to extract translate position | ||
* @return {Promise<Location>} translate position | ||
*/ | ||
async function getTranslateOffset(_logger, context, element) { | ||
@@ -193,6 +106,3 @@ return context.execute(snippets.getElementTranslateOffset, [element]) | ||
async function translateTo(_logger, context, offset, element) { | ||
return context.execute(snippets.translateTo, [ | ||
element, | ||
{x: Math.round(offset.x), y: Math.round(offset.y)}, | ||
]) | ||
return context.execute(snippets.translateTo, [element, {x: Math.round(offset.x), y: Math.round(offset.y)}]) | ||
} | ||
@@ -226,6 +136,3 @@ /** | ||
async function getTransforms(_logger, context, element) { | ||
return context.execute(snippets.getElementStyleProperties, [ | ||
element, | ||
['transform', '-webkit-transform'], | ||
]) | ||
return context.execute(snippets.getElementStyleProperties, [element, ['transform', '-webkit-transform']]) | ||
} | ||
@@ -250,6 +157,3 @@ /** | ||
async function getOverflow(_logger, context, element) { | ||
const {overflow} = await context.execute(snippets.getElementStyleProperties, [ | ||
element, | ||
['overflow'], | ||
]) | ||
const {overflow} = await context.execute(snippets.getElementStyleProperties, [element, ['overflow']]) | ||
return overflow | ||
@@ -266,6 +170,3 @@ } | ||
try { | ||
const original = await context.execute(snippets.setElementStyleProperties, [ | ||
element, | ||
{overflow}, | ||
]) | ||
const original = await context.execute(snippets.setElementStyleProperties, [element, {overflow}]) | ||
await utils.general.sleep(200) | ||
@@ -354,3 +255,3 @@ return original.overflow | ||
const info = await context.execute(snippets.getChildFramesInfo) | ||
return info.map(([element, isCORS, src]) => ({element, isCORS, src})) | ||
return info | ||
} | ||
@@ -371,4 +272,3 @@ | ||
getElementContentSize, | ||
getElementClientRect, | ||
getElementRect, | ||
getElementRegion, | ||
getPixelRatio, | ||
@@ -375,0 +275,0 @@ getUserAgent, |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
230727
23
4199
3
15
2
+ Added@applitools/types@1.0.6
+ Added@applitools/snippets@2.1.4(transitive)
+ Added@applitools/types@1.0.6(transitive)
+ Added@applitools/utils@1.2.1(transitive)
- Removed@applitools/snippets@2.1.3(transitive)
- Removed@applitools/utils@1.2.0(transitive)
Updated@applitools/snippets@2.1.4
Updated@applitools/utils@1.2.1