@applitools/snippets
Advanced tools
Comparing version 1.1.1 to 2.0.0
@@ -7,5 +7,5 @@ { | ||
"version": "file:../dry-run.tgz", | ||
"integrity": "sha512-x669tSw/46iz1FjPEkB8ybKHRo7wQdVMBdvgEhUjhHUiG2PT10fiXdFZGX+BLZEClC1zco9ilHWo+Z9RnwnkqQ==" | ||
"integrity": "sha512-1tAHGA2dFo2jgaNxt57vu7SWcspijvlBk0e7/KB2/390S1KaZET2IDJC+bs133kBKFAXxkr1nchvg3XIYd3n/A==" | ||
} | ||
} | ||
} |
@@ -7,2 +7,8 @@ | ||
## 2.0.0 - 2020/9/14 | ||
- Breaking change: changed snippets argument format from object to array | ||
- Breaking change: changed snippets return value format from object to array | ||
- add ios tests | ||
## 1.1.1 - 2020/8/30 | ||
@@ -9,0 +15,0 @@ |
{ | ||
"blurElement": "function(arg){var s=function(){\"use strict\";return function(e){var t=(void 0===e?{}:e).element,n=void 0===t?document.activeElement:t;return n&&n.blur(),n}}();\nreturn s(arg)}", | ||
"cleanupElementIds": "function(arg){var s=function(){\"use strict\";return function(e){e.elements.forEach((function(e){e.removeAttribute(\"data-eyes-selector\")}))}}();\nreturn s(arg)}", | ||
"focusElement": "function(arg){var s=function(){\"use strict\";return function(n){var t=(void 0===n?{}:n).element;t&&t.focus()}}();\nreturn s(arg)}", | ||
"getChildFramesInfo": "function(arg){var s=function(){\"use strict\";return function(){var r=document.querySelectorAll(\"frame, iframe\");return Array.prototype.map.call(r,(function(r){return{isCORS:!r.contentDocument,element:r,src:r.src}}))}}();\nreturn s(arg)}", | ||
"getContextInfo": "function(arg){var s=function(){\"use strict\";var e=function(e){var t=(void 0===e?{}:e).element,n=\"\",r=t.ownerDocument;if(!r)return n;for(var o=t;o!==r;){var c=Array.prototype.filter.call(o.parentNode.childNodes,(function(e){return e.tagName===o.tagName})).indexOf(o);n=\"/\"+o.tagName+\"[\"+(c+1)+\"]\"+n,o=o.parentNode}return n};return function(){var t,n,r;try{t=window.top.document===window.document}catch(e){t=!1}try{n=!window.parent.document===window.document}catch(e){n=!0}if(!n)try{r=e({element:window.frameElement})}catch(e){r=null}return{isRoot:t,isCORS:n,selector:r,documentElement:document.documentElement}}}();\nreturn s(arg)}", | ||
"blurElement": "function(arg){var s=function(){\"use strict\";return function(t){var n=(void 0===t?[]:t)[0],r=void 0===n?document.activeElement:n;return r&&r.blur(),r}}();\nreturn s(arg)}", | ||
"cleanupElementIds": "function(arg){var s=function(){\"use strict\";return function(t){t[0].forEach((function(t){t.removeAttribute(\"data-eyes-selector\")}))}}();\nreturn s(arg)}", | ||
"focusElement": "function(arg){var s=function(){\"use strict\";return function(n){var r=(void 0===n?[]:n)[0];r&&r.focus()}}();\nreturn s(arg)}", | ||
"getChildFramesInfo": "function(arg){var s=function(){\"use strict\";return function(){var r=document.querySelectorAll(\"frame, iframe\");return Array.prototype.map.call(r,(function(r){return[r,!r.contentDocument,r.src]}))}}();\nreturn s(arg)}", | ||
"getContextInfo": "function(arg){var s=function(){\"use strict\";var t=function(t){var n=(void 0===t?[]:t)[0],e=\"\",r=n.ownerDocument;if(!r)return e;for(var o=n;o!==r;){var a=Array.prototype.filter.call(o.parentNode.childNodes,(function(t){return t.tagName===o.tagName})).indexOf(o);e=\"/\"+o.tagName+\"[\"+(a+1)+\"]\"+e,o=o.parentNode}return e};return function(){var n,e,r;try{n=window.top.document===window.document}catch(t){n=!1}try{e=!window.parent.document===window.document}catch(t){e=!0}if(!e)try{r=t([window.frameElement])}catch(t){r=null}return[document.documentElement,r,n,e]}}();\nreturn s(arg)}", | ||
"getDocumentSize": "function(arg){var s=function(){\"use strict\";return function(){var t=document.documentElement.scrollWidth,e=document.documentElement.scrollHeight,n=document.documentElement.clientHeight,c=document.body.scrollWidth,o=document.body.scrollHeight,d=document.body.clientHeight;return{width:Math.max(t,c),height:Math.max(n,e,d,o)}}}();\nreturn s(arg)}", | ||
"getElementComputedStyleProperties": "function(arg){var s=function(){\"use strict\";return function(e){var t=void 0===e?{}:e,r=t.element,n=t.properties,o=void 0===n?[]:n,u=window.getComputedStyle(r);return console.log(r),u?o.map((function(e){return u.getPropertyValue(e)})):[]}}();\nreturn s(arg)}", | ||
"getElementContentSize": "function(arg){var s=function(){\"use strict\";return function(t){var i=(void 0===t?{}:t).element;return{width:Math.max(i.clientWidth,i.scrollWidth),height:Math.max(i.clientHeight,i.scrollHeight)}}}();\nreturn s(arg)}", | ||
"getElementFixedAncestor": "function(arg){var s=function(){\"use strict\";return function(e){for(var t=(void 0===e?{}:e).element;t.offsetParent&&t.offsetParent!==document.body&&t.offsetParent!==document.documentElement;)t=t.offsetParent;return\"fixed\"===window.getComputedStyle(t).getPropertyValue(\"position\")?t:null}}();\nreturn s(arg)}", | ||
"getElementInnerOffset": "function(arg){var s=function(){\"use strict\";var e=function(e){var r=(void 0===e?{}:e).element;return r?{x:r.scrollLeft,y:r.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}};var r=function(e){var r=void 0===e?{}:e,t=r.element,n=r.properties;return(void 0===n?[]:n).reduce((function(e,r){return e[r]=t.style[r],e}),{})};var t=function(e){var t=(void 0===e?{}:e).element,n=void 0===t?document.scrollingElement||document.documentElement:t,o=r({element:n,properties:[\"transform\",\"webkitTransform\"]}),i=Object.keys(o).reduce((function(e,r){if(o[r]){var t=o[r].match(/^translate\\s*\\(\\s*(\\-?[\\d, \\.]+)px\\s*(,\\s*(-?[\\d, \\.]+)px)?\\s*\\)/);if(!t)throw new Error(\"Can't parse CSS transition: \"+o[r]+\"!\");var n=t[1],i=void 0!==t[3]?t[3]:0;e.push({x:Math.round(-parseFloat(n)),y:Math.round(-parseFloat(i))})}return e}),[]);if(!i.every((function(e){return i[0].x===e.x||i[0].y===e.y})))throw new Error(\"Got different css positions!\");return i[0]||{x:0,y:0}};return function(r){var n=(void 0===r?{}:r).element,o=e({element:n}),i=t({element:n});return{x:o.x+i.x,y:o.y+i.y}}}();\nreturn s(arg)}", | ||
"getElementProperties": "function(arg){var s=function(){\"use strict\";return function(r){var e=void 0===r?{}:r,n=e.element,t=e.properties;return(void 0===t?[]:t).reduce((function(r,e){return r[e]=n[e],r}),{})}}();\nreturn s(arg)}", | ||
"getElementRect": "function(arg){var s=function(){\"use strict\";var e=function(e){for(var t=(void 0===e?{}:e).element;t.offsetParent&&t.offsetParent!==document.body&&t.offsetParent!==document.documentElement;)t=t.offsetParent;return\"fixed\"===window.getComputedStyle(t).getPropertyValue(\"position\")?t:null};var t=function(e){var t=(void 0===e?{}:e).element;return t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight};var r=function(e){var t=(void 0===e?{}:e).element;return t?{x:t.scrollLeft,y:t.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}};var n=function(e){var t=void 0===e?{}:e,r=t.element,n=t.properties;return(void 0===n?[]:n).reduce((function(e,t){return e[t]=r.style[t],e}),{})};var o=function(e){var t=(void 0===e?{}:e).element,r=void 0===t?document.scrollingElement||document.documentElement:t,o=n({element:r,properties:[\"transform\",\"webkitTransform\"]}),i=Object.keys(o).reduce((function(e,t){if(o[t]){var r=o[t].match(/^translate\\s*\\(\\s*(\\-?[\\d, \\.]+)px\\s*(,\\s*(-?[\\d, \\.]+)px)?\\s*\\)/);if(!r)throw new Error(\"Can't parse CSS transition: \"+o[t]+\"!\");var n=r[1],i=void 0!==r[3]?r[3]:0;e.push({x:Math.round(-parseFloat(n)),y:Math.round(-parseFloat(i))})}return e}),[]);if(!i.every((function(e){return i[0].x===e.x||i[0].y===e.y})))throw new Error(\"Got different css positions!\");return i[0]||{x:0,y:0}};var i=function(e){var t=(void 0===e?{}:e).element,n=r({element:t}),i=o({element:t});return{x:n.x+i.x,y:n.y+i.y}};return function(r){var n=void 0===r?{}:r,o=n.element,l=n.isClient,a=void 0!==l&&l,d=o.getBoundingClientRect(),s={x:d.left,y:d.top,width:d.width,height:d.height};if(a){var u=window.getComputedStyle(o);s.x+=parseInt(u.getPropertyValue(\"border-left-width\")),s.y+=parseInt(u.getPropertyValue(\"border-top-width\")),s.width=o.clientWidth,s.height=o.clientHeight}var f=e({element:o});if(f){var c=t({element:f});if(f!==o&&c){var v=i({element:f});s.x+=v.x,s.y+=v.y}}else{var m=i();s.x+=m.x,s.y+=m.y}return s}}();\nreturn s(arg)}", | ||
"getElementScrollOffset": "function(arg){var s=function(){\"use strict\";return function(o){var e=(void 0===o?{}:o).element;return e?{x:e.scrollLeft,y:e.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}}}();\nreturn s(arg)}", | ||
"getElementStyleProperties": "function(arg){var s=function(){\"use strict\";return function(e){var r=void 0===e?{}:e,t=r.element,n=r.properties;return(void 0===n?[]:n).reduce((function(e,r){return e[r]=t.style[r],e}),{})}}();\nreturn s(arg)}", | ||
"getElementTranslateOffset": "function(arg){var s=function(){\"use strict\";var r=function(r){var e=void 0===r?{}:r,t=e.element,n=e.properties;return(void 0===n?[]:n).reduce((function(r,e){return r[e]=t.style[e],r}),{})};return function(e){var t=(void 0===e?{}:e).element,n=void 0===t?document.scrollingElement||document.documentElement:t,o=r({element:n,properties:[\"transform\",\"webkitTransform\"]}),s=Object.keys(o).reduce((function(r,e){if(o[e]){var t=o[e].match(/^translate\\s*\\(\\s*(\\-?[\\d, \\.]+)px\\s*(,\\s*(-?[\\d, \\.]+)px)?\\s*\\)/);if(!t)throw new Error(\"Can't parse CSS transition: \"+o[e]+\"!\");var n=t[1],s=void 0!==t[3]?t[3]:0;r.push({x:Math.round(-parseFloat(n)),y:Math.round(-parseFloat(s))})}return r}),[]);if(!s.every((function(r){return s[0].x===r.x||s[0].y===r.y})))throw new Error(\"Got different css positions!\");return s[0]||{x:0,y:0}}}();\nreturn s(arg)}", | ||
"getElementXpath": "function(arg){var s=function(){\"use strict\";return function(e){var r=(void 0===e?{}:e).element,t=\"\",n=r.ownerDocument;if(!n)return t;for(var a=r;a!==n;){var o=Array.prototype.filter.call(a.parentNode.childNodes,(function(e){return e.tagName===a.tagName})).indexOf(a);t=\"/\"+a.tagName+\"[\"+(o+1)+\"]\"+t,a=a.parentNode}return t}}();\nreturn s(arg)}", | ||
"getElementComputedStyleProperties": "function(arg){var s=function(){\"use strict\";return function(t){var e=void 0===t?[]:t,n=e[0],o=e[1],r=void 0===o?[]:o,u=window.getComputedStyle(n);return console.log(n),u?r.map((function(t){return u.getPropertyValue(t)})):[]}}();\nreturn s(arg)}", | ||
"getElementContentSize": "function(arg){var s=function(){\"use strict\";return function(t){var i=(void 0===t?[]:t)[0];return{width:Math.max(i.clientWidth,i.scrollWidth),height:Math.max(i.clientHeight,i.scrollHeight)}}}();\nreturn s(arg)}", | ||
"getElementFixedAncestor": "function(arg){var s=function(){\"use strict\";return function(t){for(var e=(void 0===t?[]:t)[0];e.offsetParent&&e.offsetParent!==document.body&&e.offsetParent!==document.documentElement;)e=e.offsetParent;return\"fixed\"===window.getComputedStyle(e).getPropertyValue(\"position\")?e:null}}();\nreturn s(arg)}", | ||
"getElementInnerOffset": "function(arg){var s=function(){\"use strict\";var r=function(r){var n=(void 0===r?[]:r)[0];return n?{x:n.scrollLeft,y:n.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}};var n=function(r){var n=void 0===r?[]:r,t=n[0],o=n[1];return(void 0===o?[]:o).reduce((function(r,n){return r[n]=t.style[n],r}),{})};var t=function(r){var t=(void 0===r?[]:r)[0],o=void 0===t?document.scrollingElement||document.documentElement:t,e=n([o,[\"transform\",\"webkitTransform\"]]),i=Object.keys(e).reduce((function(r,n){if(e[n]){var t=e[n].match(/^translate\\s*\\(\\s*(\\-?[\\d, \\.]+)px\\s*(,\\s*(-?[\\d, \\.]+)px)?\\s*\\)/);if(!t)throw new Error(\"Can't parse CSS transition: \"+e[n]+\"!\");var o=t[1],i=void 0!==t[3]?t[3]:0;r.push({x:Math.round(-parseFloat(o)),y:Math.round(-parseFloat(i))})}return r}),[]);if(!i.every((function(r){return i[0].x===r.x||i[0].y===r.y})))throw new Error(\"Got different css positions!\");return i[0]||{x:0,y:0}};return function(n){var o=(void 0===n?[]:n)[0],e=r([o]),i=t([o]);return{x:e.x+i.x,y:e.y+i.y}}}();\nreturn s(arg)}", | ||
"getElementProperties": "function(arg){var s=function(){\"use strict\";return function(r){var n=void 0===r?[]:r,t=n[0],u=n[1];return(void 0===u?[]:u).reduce((function(r,n){return r[n]=t[n],r}),{})}}();\nreturn s(arg)}", | ||
"getElementRect": "function(arg){var s=function(){\"use strict\";var t=function(t){for(var e=(void 0===t?[]:t)[0];e.offsetParent&&e.offsetParent!==document.body&&e.offsetParent!==document.documentElement;)e=e.offsetParent;return\"fixed\"===window.getComputedStyle(e).getPropertyValue(\"position\")?e:null};var e=function(t){var e=(void 0===t?[]:t)[0];return e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight};var r=function(t){var e=(void 0===t?[]:t)[0];return e?{x:e.scrollLeft,y:e.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}};var n=function(t){var e=void 0===t?[]:t,r=e[0],n=e[1];return(void 0===n?[]:n).reduce((function(t,e){return t[e]=r.style[e],t}),{})};var o=function(t){var e=(void 0===t?[]:t)[0],r=void 0===e?document.scrollingElement||document.documentElement:e,o=n([r,[\"transform\",\"webkitTransform\"]]),i=Object.keys(o).reduce((function(t,e){if(o[e]){var r=o[e].match(/^translate\\s*\\(\\s*(\\-?[\\d, \\.]+)px\\s*(,\\s*(-?[\\d, \\.]+)px)?\\s*\\)/);if(!r)throw new Error(\"Can't parse CSS transition: \"+o[e]+\"!\");var n=r[1],i=void 0!==r[3]?r[3]:0;t.push({x:Math.round(-parseFloat(n)),y:Math.round(-parseFloat(i))})}return t}),[]);if(!i.every((function(t){return i[0].x===t.x||i[0].y===t.y})))throw new Error(\"Got different css positions!\");return i[0]||{x:0,y:0}};var i=function(t){var e=(void 0===t?[]:t)[0],n=r([e]),i=o([e]);return{x:n.x+i.x,y:n.y+i.y}};return function(r){var n=void 0===r?[]:r,o=n[0],a=n[1],d=void 0!==a&&a,u=o.getBoundingClientRect(),s={x:u.left,y:u.top,width:u.width,height:u.height};if(d){var f=window.getComputedStyle(o);s.x+=parseInt(f.getPropertyValue(\"border-left-width\")),s.y+=parseInt(f.getPropertyValue(\"border-top-width\")),s.width=o.clientWidth,s.height=o.clientHeight}var l=t([o]);if(l){var c=e([l]);if(l!==o&&c){var v=i([l]);s.x+=v.x,s.y+=v.y}}else{var y=i();s.x+=y.x,s.y+=y.y}return s}}();\nreturn s(arg)}", | ||
"getElementScrollOffset": "function(arg){var s=function(){\"use strict\";return function(o){var r=(void 0===o?[]:o)[0];return r?{x:r.scrollLeft,y:r.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}}}();\nreturn s(arg)}", | ||
"getElementStyleProperties": "function(arg){var s=function(){\"use strict\";return function(r){var n=void 0===r?[]:r,t=n[0],u=n[1];return(void 0===u?[]:u).reduce((function(r,n){return r[n]=t.style[n],r}),{})}}();\nreturn s(arg)}", | ||
"getElementTranslateOffset": "function(arg){var s=function(){\"use strict\";var r=function(r){var t=void 0===r?[]:r,n=t[0],e=t[1];return(void 0===e?[]:e).reduce((function(r,t){return r[t]=n.style[t],r}),{})};return function(t){var n=(void 0===t?[]:t)[0],e=void 0===n?document.scrollingElement||document.documentElement:n,o=r([e,[\"transform\",\"webkitTransform\"]]),s=Object.keys(o).reduce((function(r,t){if(o[t]){var n=o[t].match(/^translate\\s*\\(\\s*(\\-?[\\d, \\.]+)px\\s*(,\\s*(-?[\\d, \\.]+)px)?\\s*\\)/);if(!n)throw new Error(\"Can't parse CSS transition: \"+o[t]+\"!\");var e=n[1],s=void 0!==n[3]?n[3]:0;r.push({x:Math.round(-parseFloat(e)),y:Math.round(-parseFloat(s))})}return r}),[]);if(!s.every((function(r){return s[0].x===r.x||s[0].y===r.y})))throw new Error(\"Got different css positions!\");return s[0]||{x:0,y:0}}}();\nreturn s(arg)}", | ||
"getElementXpath": "function(arg){var s=function(){\"use strict\";return function(r){var e=(void 0===r?[]:r)[0],t=\"\",n=e.ownerDocument;if(!n)return t;for(var a=e;a!==n;){var o=Array.prototype.filter.call(a.parentNode.childNodes,(function(r){return r.tagName===a.tagName})).indexOf(a);t=\"/\"+a.tagName+\"[\"+(o+1)+\"]\"+t,a=a.parentNode}return t}}();\nreturn s(arg)}", | ||
"getPixelRatio": "function(arg){var s=function(){\"use strict\";return function(){return window.devicePixelRatio}}();\nreturn s(arg)}", | ||
"getUserAgent": "function(arg){var s=function(){\"use strict\";return function(){return window.navigator.userAgent}}();\nreturn s(arg)}", | ||
"getViewportSize": "function(arg){var s=function(){\"use strict\";return function(){var e=0,t=0;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),{width:e,height:t}}}();\nreturn s(arg)}", | ||
"isElementScrollable": "function(arg){var s=function(){\"use strict\";return function(t){var e=(void 0===t?{}:t).element;return e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight}}();\nreturn s(arg)}", | ||
"markElements": "function(arg){var s=function(){\"use strict\";return function(t){var e=t.elements,n=t.ids;e.forEach((function(t,e){t.setAttribute(\"data-eyes-selector\",n[e])}))}}();\nreturn s(arg)}", | ||
"scrollTo": "function(arg){var s=function(){\"use strict\";return function(o){var l=void 0===o?{}:o,e=l.element,r=void 0===e?document.documentElement:e,t=l.offset;return r.scrollTo?r.scrollTo(t.x,t.y):(r.scrollLeft=t.x,r.scrollTop=t.y),{x:r.scrollLeft,y:r.scrollTop}}}();\nreturn s(arg)}", | ||
"setElementAttribute": "function(arg){var s=function(){\"use strict\";return function(t){var e=t.element,r=t.attr,n=t.value;e.setAttribute(r,n)}}();\nreturn s(arg)}", | ||
"setElementStyleProperties": "function(arg){var s=function(){\"use strict\";return function(e){var t=void 0===e?{}:e,r=t.element,n=t.properties;return Object.keys(n).reduce((function(e,t){return e[t]=r.style[t],r.style[t]=n[t],e}),{})}}();\nreturn s(arg)}", | ||
"translateTo": "function(arg){var s=function(){\"use strict\";var e=function(e){var t=void 0===e?{}:e,r=t.element,n=t.properties;return Object.keys(n).reduce((function(e,t){return e[t]=r.style[t],r.style[t]=n[t],e}),{})};return function(t){var r=void 0===t?{}:t,n=r.offset,o=r.element,s=void 0===o?document.documentElement:o,u=\"translate(\"+-n.x+\"px, \"+-n.y+\"px)\";return e({element:s,properties:{transform:u,webkitTransform:u}}),n}}();\nreturn s(arg)}" | ||
"isElementScrollable": "function(arg){var s=function(){\"use strict\";return function(t){var i=(void 0===t?[]:t)[0];return i.scrollWidth>i.clientWidth||i.scrollHeight>i.clientHeight}}();\nreturn s(arg)}", | ||
"markElements": "function(arg){var s=function(){\"use strict\";return function(t){var e=t[0],r=t[1];e.forEach((function(t,e){t.setAttribute(\"data-eyes-selector\",r[e])}))}}();\nreturn s(arg)}", | ||
"scrollTo": "function(arg){var s=function(){\"use strict\";return function(o){var l=void 0===o?[]:o,r=l[0],c=l[1];return(r=r||document.documentElement).scrollTo?r.scrollTo(c.x,c.y):(r.scrollLeft=c.x,r.scrollTop=c.y),{x:r.scrollLeft,y:r.scrollTop}}}();\nreturn s(arg)}", | ||
"setElementAttributes": "function(arg){var s=function(){\"use strict\";return function(t){var e=void 0===t?[]:t,r=e[0],u=e[1];return Object.keys(u).reduce((function(t,e){return t[e]=r.getAttribute(e),r.setAttribute(e,u[e]),t}),{})}}();\nreturn s(arg)}", | ||
"setElementStyleProperties": "function(arg){var s=function(){\"use strict\";return function(t){var e=void 0===t?[]:t,r=e[0],n=e[1];return Object.keys(n).reduce((function(t,e){return t[e]=r.style[e],r.style[e]=n[e],t}),{})}}();\nreturn s(arg)}", | ||
"translateTo": "function(arg){var s=function(){\"use strict\";var r=function(r){var t=void 0===r?[]:r,n=t[0],e=t[1];return Object.keys(e).reduce((function(r,t){return r[t]=n.style[t],n.style[t]=e[t],r}),{})};return function(t){var n=void 0===t?[]:t,e=n[0],u=n[1];e=e||document.documentElement;var o=\"translate(\"+-u.x+\"px, \"+-u.y+\"px)\";return r([e,{transform:o,webkitTransform:o}]),u}}();\nreturn s(arg)}" | ||
} |
exports.blurElement=function(arg){ | ||
var s=function(){"use strict";return function(e){var t=(void 0===e?{}:e).element,n=void 0===t?document.activeElement:t;return n&&n.blur(),n}}(); | ||
var s=function(){"use strict";return function(t){var n=(void 0===t?[]:t)[0],r=void 0===n?document.activeElement:n;return r&&r.blur(),r}}(); | ||
return s(arg) | ||
} | ||
exports.cleanupElementIds=function(arg){ | ||
var s=function(){"use strict";return function(e){e.elements.forEach((function(e){e.removeAttribute("data-eyes-selector")}))}}(); | ||
var s=function(){"use strict";return function(t){t[0].forEach((function(t){t.removeAttribute("data-eyes-selector")}))}}(); | ||
return s(arg) | ||
} | ||
exports.focusElement=function(arg){ | ||
var s=function(){"use strict";return function(n){var t=(void 0===n?{}:n).element;t&&t.focus()}}(); | ||
var s=function(){"use strict";return function(n){var r=(void 0===n?[]:n)[0];r&&r.focus()}}(); | ||
return s(arg) | ||
} | ||
exports.getChildFramesInfo=function(arg){ | ||
var s=function(){"use strict";return function(){var r=document.querySelectorAll("frame, iframe");return Array.prototype.map.call(r,(function(r){return{isCORS:!r.contentDocument,element:r,src:r.src}}))}}(); | ||
var s=function(){"use strict";return function(){var r=document.querySelectorAll("frame, iframe");return Array.prototype.map.call(r,(function(r){return[r,!r.contentDocument,r.src]}))}}(); | ||
return s(arg) | ||
} | ||
exports.getContextInfo=function(arg){ | ||
var s=function(){"use strict";var e=function(e){var t=(void 0===e?{}:e).element,n="",r=t.ownerDocument;if(!r)return n;for(var o=t;o!==r;){var c=Array.prototype.filter.call(o.parentNode.childNodes,(function(e){return e.tagName===o.tagName})).indexOf(o);n="/"+o.tagName+"["+(c+1)+"]"+n,o=o.parentNode}return n};return function(){var t,n,r;try{t=window.top.document===window.document}catch(e){t=!1}try{n=!window.parent.document===window.document}catch(e){n=!0}if(!n)try{r=e({element:window.frameElement})}catch(e){r=null}return{isRoot:t,isCORS:n,selector:r,documentElement:document.documentElement}}}(); | ||
var s=function(){"use strict";var t=function(t){var n=(void 0===t?[]:t)[0],e="",r=n.ownerDocument;if(!r)return e;for(var o=n;o!==r;){var a=Array.prototype.filter.call(o.parentNode.childNodes,(function(t){return t.tagName===o.tagName})).indexOf(o);e="/"+o.tagName+"["+(a+1)+"]"+e,o=o.parentNode}return e};return function(){var n,e,r;try{n=window.top.document===window.document}catch(t){n=!1}try{e=!window.parent.document===window.document}catch(t){e=!0}if(!e)try{r=t([window.frameElement])}catch(t){r=null}return[document.documentElement,r,n,e]}}(); | ||
return s(arg) | ||
@@ -26,39 +26,39 @@ } | ||
exports.getElementComputedStyleProperties=function(arg){ | ||
var s=function(){"use strict";return function(e){var t=void 0===e?{}:e,r=t.element,n=t.properties,o=void 0===n?[]:n,u=window.getComputedStyle(r);return console.log(r),u?o.map((function(e){return u.getPropertyValue(e)})):[]}}(); | ||
var s=function(){"use strict";return function(t){var e=void 0===t?[]:t,n=e[0],o=e[1],r=void 0===o?[]:o,u=window.getComputedStyle(n);return console.log(n),u?r.map((function(t){return u.getPropertyValue(t)})):[]}}(); | ||
return s(arg) | ||
} | ||
exports.getElementContentSize=function(arg){ | ||
var s=function(){"use strict";return function(t){var i=(void 0===t?{}:t).element;return{width:Math.max(i.clientWidth,i.scrollWidth),height:Math.max(i.clientHeight,i.scrollHeight)}}}(); | ||
var s=function(){"use strict";return function(t){var i=(void 0===t?[]:t)[0];return{width:Math.max(i.clientWidth,i.scrollWidth),height:Math.max(i.clientHeight,i.scrollHeight)}}}(); | ||
return s(arg) | ||
} | ||
exports.getElementFixedAncestor=function(arg){ | ||
var s=function(){"use strict";return function(e){for(var t=(void 0===e?{}:e).element;t.offsetParent&&t.offsetParent!==document.body&&t.offsetParent!==document.documentElement;)t=t.offsetParent;return"fixed"===window.getComputedStyle(t).getPropertyValue("position")?t:null}}(); | ||
var s=function(){"use strict";return function(t){for(var e=(void 0===t?[]:t)[0];e.offsetParent&&e.offsetParent!==document.body&&e.offsetParent!==document.documentElement;)e=e.offsetParent;return"fixed"===window.getComputedStyle(e).getPropertyValue("position")?e:null}}(); | ||
return s(arg) | ||
} | ||
exports.getElementInnerOffset=function(arg){ | ||
var s=function(){"use strict";var e=function(e){var r=(void 0===e?{}:e).element;return r?{x:r.scrollLeft,y:r.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}};var r=function(e){var r=void 0===e?{}:e,t=r.element,n=r.properties;return(void 0===n?[]:n).reduce((function(e,r){return e[r]=t.style[r],e}),{})};var t=function(e){var t=(void 0===e?{}:e).element,n=void 0===t?document.scrollingElement||document.documentElement:t,o=r({element:n,properties:["transform","webkitTransform"]}),i=Object.keys(o).reduce((function(e,r){if(o[r]){var t=o[r].match(/^translate\s*\(\s*(\-?[\d, \.]+)px\s*(,\s*(-?[\d, \.]+)px)?\s*\)/);if(!t)throw new Error("Can't parse CSS transition: "+o[r]+"!");var n=t[1],i=void 0!==t[3]?t[3]:0;e.push({x:Math.round(-parseFloat(n)),y:Math.round(-parseFloat(i))})}return e}),[]);if(!i.every((function(e){return i[0].x===e.x||i[0].y===e.y})))throw new Error("Got different css positions!");return i[0]||{x:0,y:0}};return function(r){var n=(void 0===r?{}:r).element,o=e({element:n}),i=t({element:n});return{x:o.x+i.x,y:o.y+i.y}}}(); | ||
var s=function(){"use strict";var r=function(r){var n=(void 0===r?[]:r)[0];return n?{x:n.scrollLeft,y:n.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}};var n=function(r){var n=void 0===r?[]:r,t=n[0],o=n[1];return(void 0===o?[]:o).reduce((function(r,n){return r[n]=t.style[n],r}),{})};var t=function(r){var t=(void 0===r?[]:r)[0],o=void 0===t?document.scrollingElement||document.documentElement:t,e=n([o,["transform","webkitTransform"]]),i=Object.keys(e).reduce((function(r,n){if(e[n]){var t=e[n].match(/^translate\s*\(\s*(\-?[\d, \.]+)px\s*(,\s*(-?[\d, \.]+)px)?\s*\)/);if(!t)throw new Error("Can't parse CSS transition: "+e[n]+"!");var o=t[1],i=void 0!==t[3]?t[3]:0;r.push({x:Math.round(-parseFloat(o)),y:Math.round(-parseFloat(i))})}return r}),[]);if(!i.every((function(r){return i[0].x===r.x||i[0].y===r.y})))throw new Error("Got different css positions!");return i[0]||{x:0,y:0}};return function(n){var o=(void 0===n?[]:n)[0],e=r([o]),i=t([o]);return{x:e.x+i.x,y:e.y+i.y}}}(); | ||
return s(arg) | ||
} | ||
exports.getElementProperties=function(arg){ | ||
var s=function(){"use strict";return function(r){var e=void 0===r?{}:r,n=e.element,t=e.properties;return(void 0===t?[]:t).reduce((function(r,e){return r[e]=n[e],r}),{})}}(); | ||
var s=function(){"use strict";return function(r){var n=void 0===r?[]:r,t=n[0],u=n[1];return(void 0===u?[]:u).reduce((function(r,n){return r[n]=t[n],r}),{})}}(); | ||
return s(arg) | ||
} | ||
exports.getElementRect=function(arg){ | ||
var s=function(){"use strict";var e=function(e){for(var t=(void 0===e?{}:e).element;t.offsetParent&&t.offsetParent!==document.body&&t.offsetParent!==document.documentElement;)t=t.offsetParent;return"fixed"===window.getComputedStyle(t).getPropertyValue("position")?t:null};var t=function(e){var t=(void 0===e?{}:e).element;return t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight};var r=function(e){var t=(void 0===e?{}:e).element;return t?{x:t.scrollLeft,y:t.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}};var n=function(e){var t=void 0===e?{}:e,r=t.element,n=t.properties;return(void 0===n?[]:n).reduce((function(e,t){return e[t]=r.style[t],e}),{})};var o=function(e){var t=(void 0===e?{}:e).element,r=void 0===t?document.scrollingElement||document.documentElement:t,o=n({element:r,properties:["transform","webkitTransform"]}),i=Object.keys(o).reduce((function(e,t){if(o[t]){var r=o[t].match(/^translate\s*\(\s*(\-?[\d, \.]+)px\s*(,\s*(-?[\d, \.]+)px)?\s*\)/);if(!r)throw new Error("Can't parse CSS transition: "+o[t]+"!");var n=r[1],i=void 0!==r[3]?r[3]:0;e.push({x:Math.round(-parseFloat(n)),y:Math.round(-parseFloat(i))})}return e}),[]);if(!i.every((function(e){return i[0].x===e.x||i[0].y===e.y})))throw new Error("Got different css positions!");return i[0]||{x:0,y:0}};var i=function(e){var t=(void 0===e?{}:e).element,n=r({element:t}),i=o({element:t});return{x:n.x+i.x,y:n.y+i.y}};return function(r){var n=void 0===r?{}:r,o=n.element,l=n.isClient,a=void 0!==l&&l,d=o.getBoundingClientRect(),s={x:d.left,y:d.top,width:d.width,height:d.height};if(a){var u=window.getComputedStyle(o);s.x+=parseInt(u.getPropertyValue("border-left-width")),s.y+=parseInt(u.getPropertyValue("border-top-width")),s.width=o.clientWidth,s.height=o.clientHeight}var f=e({element:o});if(f){var c=t({element:f});if(f!==o&&c){var v=i({element:f});s.x+=v.x,s.y+=v.y}}else{var m=i();s.x+=m.x,s.y+=m.y}return s}}(); | ||
var s=function(){"use strict";var t=function(t){for(var e=(void 0===t?[]:t)[0];e.offsetParent&&e.offsetParent!==document.body&&e.offsetParent!==document.documentElement;)e=e.offsetParent;return"fixed"===window.getComputedStyle(e).getPropertyValue("position")?e:null};var e=function(t){var e=(void 0===t?[]:t)[0];return e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight};var r=function(t){var e=(void 0===t?[]:t)[0];return e?{x:e.scrollLeft,y:e.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}};var n=function(t){var e=void 0===t?[]:t,r=e[0],n=e[1];return(void 0===n?[]:n).reduce((function(t,e){return t[e]=r.style[e],t}),{})};var o=function(t){var e=(void 0===t?[]:t)[0],r=void 0===e?document.scrollingElement||document.documentElement:e,o=n([r,["transform","webkitTransform"]]),i=Object.keys(o).reduce((function(t,e){if(o[e]){var r=o[e].match(/^translate\s*\(\s*(\-?[\d, \.]+)px\s*(,\s*(-?[\d, \.]+)px)?\s*\)/);if(!r)throw new Error("Can't parse CSS transition: "+o[e]+"!");var n=r[1],i=void 0!==r[3]?r[3]:0;t.push({x:Math.round(-parseFloat(n)),y:Math.round(-parseFloat(i))})}return t}),[]);if(!i.every((function(t){return i[0].x===t.x||i[0].y===t.y})))throw new Error("Got different css positions!");return i[0]||{x:0,y:0}};var i=function(t){var e=(void 0===t?[]:t)[0],n=r([e]),i=o([e]);return{x:n.x+i.x,y:n.y+i.y}};return function(r){var n=void 0===r?[]:r,o=n[0],a=n[1],d=void 0!==a&&a,u=o.getBoundingClientRect(),s={x:u.left,y:u.top,width:u.width,height:u.height};if(d){var f=window.getComputedStyle(o);s.x+=parseInt(f.getPropertyValue("border-left-width")),s.y+=parseInt(f.getPropertyValue("border-top-width")),s.width=o.clientWidth,s.height=o.clientHeight}var l=t([o]);if(l){var c=e([l]);if(l!==o&&c){var v=i([l]);s.x+=v.x,s.y+=v.y}}else{var y=i();s.x+=y.x,s.y+=y.y}return s}}(); | ||
return s(arg) | ||
} | ||
exports.getElementScrollOffset=function(arg){ | ||
var s=function(){"use strict";return function(o){var e=(void 0===o?{}:o).element;return e?{x:e.scrollLeft,y:e.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}}}(); | ||
var s=function(){"use strict";return function(o){var r=(void 0===o?[]:o)[0];return r?{x:r.scrollLeft,y:r.scrollTop}:{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset}}}(); | ||
return s(arg) | ||
} | ||
exports.getElementStyleProperties=function(arg){ | ||
var s=function(){"use strict";return function(e){var r=void 0===e?{}:e,t=r.element,n=r.properties;return(void 0===n?[]:n).reduce((function(e,r){return e[r]=t.style[r],e}),{})}}(); | ||
var s=function(){"use strict";return function(r){var n=void 0===r?[]:r,t=n[0],u=n[1];return(void 0===u?[]:u).reduce((function(r,n){return r[n]=t.style[n],r}),{})}}(); | ||
return s(arg) | ||
} | ||
exports.getElementTranslateOffset=function(arg){ | ||
var s=function(){"use strict";var r=function(r){var e=void 0===r?{}:r,t=e.element,n=e.properties;return(void 0===n?[]:n).reduce((function(r,e){return r[e]=t.style[e],r}),{})};return function(e){var t=(void 0===e?{}:e).element,n=void 0===t?document.scrollingElement||document.documentElement:t,o=r({element:n,properties:["transform","webkitTransform"]}),s=Object.keys(o).reduce((function(r,e){if(o[e]){var t=o[e].match(/^translate\s*\(\s*(\-?[\d, \.]+)px\s*(,\s*(-?[\d, \.]+)px)?\s*\)/);if(!t)throw new Error("Can't parse CSS transition: "+o[e]+"!");var n=t[1],s=void 0!==t[3]?t[3]:0;r.push({x:Math.round(-parseFloat(n)),y:Math.round(-parseFloat(s))})}return r}),[]);if(!s.every((function(r){return s[0].x===r.x||s[0].y===r.y})))throw new Error("Got different css positions!");return s[0]||{x:0,y:0}}}(); | ||
var s=function(){"use strict";var r=function(r){var t=void 0===r?[]:r,n=t[0],e=t[1];return(void 0===e?[]:e).reduce((function(r,t){return r[t]=n.style[t],r}),{})};return function(t){var n=(void 0===t?[]:t)[0],e=void 0===n?document.scrollingElement||document.documentElement:n,o=r([e,["transform","webkitTransform"]]),s=Object.keys(o).reduce((function(r,t){if(o[t]){var n=o[t].match(/^translate\s*\(\s*(\-?[\d, \.]+)px\s*(,\s*(-?[\d, \.]+)px)?\s*\)/);if(!n)throw new Error("Can't parse CSS transition: "+o[t]+"!");var e=n[1],s=void 0!==n[3]?n[3]:0;r.push({x:Math.round(-parseFloat(e)),y:Math.round(-parseFloat(s))})}return r}),[]);if(!s.every((function(r){return s[0].x===r.x||s[0].y===r.y})))throw new Error("Got different css positions!");return s[0]||{x:0,y:0}}}(); | ||
return s(arg) | ||
} | ||
exports.getElementXpath=function(arg){ | ||
var s=function(){"use strict";return function(e){var r=(void 0===e?{}:e).element,t="",n=r.ownerDocument;if(!n)return t;for(var a=r;a!==n;){var o=Array.prototype.filter.call(a.parentNode.childNodes,(function(e){return e.tagName===a.tagName})).indexOf(a);t="/"+a.tagName+"["+(o+1)+"]"+t,a=a.parentNode}return t}}(); | ||
var s=function(){"use strict";return function(r){var e=(void 0===r?[]:r)[0],t="",n=e.ownerDocument;if(!n)return t;for(var a=e;a!==n;){var o=Array.prototype.filter.call(a.parentNode.childNodes,(function(r){return r.tagName===a.tagName})).indexOf(a);t="/"+a.tagName+"["+(o+1)+"]"+t,a=a.parentNode}return t}}(); | ||
return s(arg) | ||
@@ -79,24 +79,24 @@ } | ||
exports.isElementScrollable=function(arg){ | ||
var s=function(){"use strict";return function(t){var e=(void 0===t?{}:t).element;return e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight}}(); | ||
var s=function(){"use strict";return function(t){var i=(void 0===t?[]:t)[0];return i.scrollWidth>i.clientWidth||i.scrollHeight>i.clientHeight}}(); | ||
return s(arg) | ||
} | ||
exports.markElements=function(arg){ | ||
var s=function(){"use strict";return function(t){var e=t.elements,n=t.ids;e.forEach((function(t,e){t.setAttribute("data-eyes-selector",n[e])}))}}(); | ||
var s=function(){"use strict";return function(t){var e=t[0],r=t[1];e.forEach((function(t,e){t.setAttribute("data-eyes-selector",r[e])}))}}(); | ||
return s(arg) | ||
} | ||
exports.scrollTo=function(arg){ | ||
var s=function(){"use strict";return function(o){var l=void 0===o?{}:o,e=l.element,r=void 0===e?document.documentElement:e,t=l.offset;return r.scrollTo?r.scrollTo(t.x,t.y):(r.scrollLeft=t.x,r.scrollTop=t.y),{x:r.scrollLeft,y:r.scrollTop}}}(); | ||
var s=function(){"use strict";return function(o){var l=void 0===o?[]:o,r=l[0],c=l[1];return(r=r||document.documentElement).scrollTo?r.scrollTo(c.x,c.y):(r.scrollLeft=c.x,r.scrollTop=c.y),{x:r.scrollLeft,y:r.scrollTop}}}(); | ||
return s(arg) | ||
} | ||
exports.setElementAttribute=function(arg){ | ||
var s=function(){"use strict";return function(t){var e=t.element,r=t.attr,n=t.value;e.setAttribute(r,n)}}(); | ||
exports.setElementAttributes=function(arg){ | ||
var s=function(){"use strict";return function(t){var e=void 0===t?[]:t,r=e[0],u=e[1];return Object.keys(u).reduce((function(t,e){return t[e]=r.getAttribute(e),r.setAttribute(e,u[e]),t}),{})}}(); | ||
return s(arg) | ||
} | ||
exports.setElementStyleProperties=function(arg){ | ||
var s=function(){"use strict";return function(e){var t=void 0===e?{}:e,r=t.element,n=t.properties;return Object.keys(n).reduce((function(e,t){return e[t]=r.style[t],r.style[t]=n[t],e}),{})}}(); | ||
var s=function(){"use strict";return function(t){var e=void 0===t?[]:t,r=e[0],n=e[1];return Object.keys(n).reduce((function(t,e){return t[e]=r.style[e],r.style[e]=n[e],t}),{})}}(); | ||
return s(arg) | ||
} | ||
exports.translateTo=function(arg){ | ||
var s=function(){"use strict";var e=function(e){var t=void 0===e?{}:e,r=t.element,n=t.properties;return Object.keys(n).reduce((function(e,t){return e[t]=r.style[t],r.style[t]=n[t],e}),{})};return function(t){var r=void 0===t?{}:t,n=r.offset,o=r.element,s=void 0===o?document.documentElement:o,u="translate("+-n.x+"px, "+-n.y+"px)";return e({element:s,properties:{transform:u,webkitTransform:u}}),n}}(); | ||
var s=function(){"use strict";var r=function(r){var t=void 0===r?[]:r,n=t[0],e=t[1];return Object.keys(e).reduce((function(r,t){return r[t]=n.style[t],n.style[t]=e[t],r}),{})};return function(t){var n=void 0===t?[]:t,e=n[0],u=n[1];e=e||document.documentElement;var o="translate("+-u.x+"px, "+-u.y+"px)";return r([e,{transform:o,webkitTransform:o}]),u}}(); | ||
return s(arg) | ||
} |
{ | ||
"name": "@applitools/snippets", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"main": "./dist/index.js", | ||
@@ -9,3 +9,5 @@ "license": "SEE LICENSE IN LICENSE", | ||
"test": "mocha --no-timeouts --require test/util/hook.js ./test/*.spec.js", | ||
"test:chrome": "mocha --no-timeouts --parallel --jobs 15 ./test/*.spec.js", | ||
"test:chrome": "mocha --no-timeouts --require test/util/hook.js --grep chrome ./test/*.spec.js", | ||
"test:ie": "mocha --no-timeouts --require test/util/hook.js --grep 'internet explorer' ./test/*.spec.js", | ||
"test:ios": "mocha --no-timeouts --require test/util/hook.js --grep 'ios safari' ./test/*.spec.js", | ||
"build": "node ./rollup/cli bundle --format json --format snippet", | ||
@@ -24,15 +26,14 @@ "build:watch": "node ./rollup/cli watch --format json --format snippet", | ||
"@applitools/sdk-shared": "^0.1.0", | ||
"@babel/preset-env": "^7.10.2", | ||
"@rollup/plugin-babel": "^5.0.3", | ||
"@rollup/plugin-commonjs": "^13.0.0", | ||
"@babel/preset-env": "^7.11.5", | ||
"@rollup/plugin-babel": "^5.2.1", | ||
"@rollup/plugin-commonjs": "^15.0.0", | ||
"chalk": "^4.1.0", | ||
"glob": "^7.1.6", | ||
"mocha": "^8.0.1", | ||
"playwright": "^1.1.1", | ||
"rollup": "^2.16.1", | ||
"rollup-plugin-progress": "^1.1.2", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"mocha": "^8.1.3", | ||
"playwright": "1.1.1", | ||
"rollup": "^2.26.11", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"webdriverio": "^6.1.24", | ||
"yargs": "^15.3.1" | ||
"yargs": "^16.0.3" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
function blurElement({element = document.activeElement} = {}) { | ||
function blurElement([element = document.activeElement] = []) { | ||
if (element) element.blur() | ||
@@ -3,0 +3,0 @@ return element |
@@ -1,2 +0,2 @@ | ||
function cleanupElementIds({elements}) { | ||
function cleanupElementIds([elements]) { | ||
elements.forEach(el => { | ||
@@ -3,0 +3,0 @@ el.removeAttribute('data-eyes-selector') |
@@ -1,2 +0,2 @@ | ||
function focusElement({element} = {}) { | ||
function focusElement([element] = []) { | ||
if (element) element.focus() | ||
@@ -3,0 +3,0 @@ } |
function getChildFramesInfo() { | ||
const frames = document.querySelectorAll('frame, iframe') | ||
return Array.prototype.map.call(frames, frameElement => ({ | ||
isCORS: !frameElement.contentDocument, | ||
element: frameElement, | ||
src: frameElement.src, | ||
})) | ||
return Array.prototype.map.call(frames, frameElement => [ | ||
frameElement, | ||
!frameElement.contentDocument, | ||
frameElement.src, | ||
]) | ||
} | ||
module.exports = getChildFramesInfo |
@@ -19,3 +19,3 @@ const getElementXpath = require('./getElementXpath') | ||
try { | ||
selector = getElementXpath({element: window.frameElement}) | ||
selector = getElementXpath([window.frameElement]) | ||
} catch (err) { | ||
@@ -25,5 +25,5 @@ selector = null | ||
} | ||
return {isRoot, isCORS, selector, documentElement: document.documentElement} | ||
return [document.documentElement, selector, isRoot, isCORS] | ||
} | ||
module.exports = getContextInfo |
@@ -1,2 +0,2 @@ | ||
function getElementComputedStyleProperties({element, properties = []} = {}) { | ||
function getElementComputedStyleProperties([element, properties = []] = []) { | ||
const computedStyle = window.getComputedStyle(element) | ||
@@ -3,0 +3,0 @@ console.log(element) |
@@ -1,2 +0,2 @@ | ||
function getElementEntireSize({element} = {}) { | ||
function getElementEntireSize([element] = []) { | ||
return { | ||
@@ -3,0 +3,0 @@ width: Math.max(element.clientWidth, element.scrollWidth), |
@@ -1,2 +0,2 @@ | ||
function findFixedAncestor({element} = {}) { | ||
function findFixedAncestor([element] = []) { | ||
let offsetElement = element | ||
@@ -3,0 +3,0 @@ while ( |
const getElementScrollOffset = require('./getElementScrollOffset') | ||
const getElementTranslateOffset = require('./getElementTranslateOffset') | ||
function getInnerOffset({element} = {}) { | ||
const scroll = getElementScrollOffset({element}) | ||
const translate = getElementTranslateOffset({element}) | ||
function getInnerOffset([element] = []) { | ||
const scroll = getElementScrollOffset([element]) | ||
const translate = getElementTranslateOffset([element]) | ||
return {x: scroll.x + translate.x, y: scroll.y + translate.y} | ||
@@ -8,0 +8,0 @@ } |
@@ -1,2 +0,2 @@ | ||
function getElementProperties({element, properties = []} = {}) { | ||
function getElementProperties([element, properties = []] = []) { | ||
return properties.reduce((properties, property) => { | ||
@@ -3,0 +3,0 @@ properties[property] = element[property] |
@@ -5,3 +5,3 @@ const findFixedAncestor = require('./getElementFixedAncestor') | ||
module.exports = function getElementRect({element, isClient = false} = {}) { | ||
module.exports = function getElementRect([element, isClient = false] = []) { | ||
const elementBoundingClientRect = element.getBoundingClientRect() | ||
@@ -21,7 +21,7 @@ const rect = { | ||
} | ||
const fixedAncestor = findFixedAncestor({element}) | ||
const fixedAncestor = findFixedAncestor([element]) | ||
if (fixedAncestor) { | ||
const isFixedAncestorScrollable = isElementScrollable({element: fixedAncestor}) | ||
const isFixedAncestorScrollable = isElementScrollable([fixedAncestor]) | ||
if (fixedAncestor !== element && isFixedAncestorScrollable) { | ||
const fixedAncestorInnerOffset = getElementInnerOffset({element: fixedAncestor}) | ||
const fixedAncestorInnerOffset = getElementInnerOffset([fixedAncestor]) | ||
rect.x += fixedAncestorInnerOffset.x | ||
@@ -28,0 +28,0 @@ rect.y += fixedAncestorInnerOffset.y |
@@ -1,2 +0,2 @@ | ||
function getScrollOffset({element} = {}) { | ||
function getScrollOffset([element] = []) { | ||
if (element) { | ||
@@ -3,0 +3,0 @@ return {x: element.scrollLeft, y: element.scrollTop} |
@@ -1,2 +0,2 @@ | ||
function getElementStyleProperties({element, properties = []} = {}) { | ||
function getElementStyleProperties([element, properties = []] = []) { | ||
return properties.reduce((style, property) => { | ||
@@ -3,0 +3,0 @@ style[property] = element.style[property] |
const getElementStyleProperties = require('./getElementStyleProperties') | ||
function getTranslateOffset({ | ||
function getTranslateOffset([ | ||
element = document.scrollingElement || document.documentElement, | ||
} = {}) { | ||
const transforms = getElementStyleProperties({ | ||
element, | ||
properties: ['transform', 'webkitTransform'], | ||
}) | ||
] = []) { | ||
const transforms = getElementStyleProperties([element, ['transform', 'webkitTransform']]) | ||
const translates = Object.keys(transforms).reduce((translates, key) => { | ||
@@ -11,0 +8,0 @@ if (transforms[key]) { |
@@ -1,2 +0,2 @@ | ||
function generateElementXpath({element} = {}) { | ||
function generateElementXpath([element] = []) { | ||
let xpath = '' | ||
@@ -3,0 +3,0 @@ const ownerDocument = element.ownerDocument |
@@ -1,2 +0,2 @@ | ||
function isElementScrollable({element} = {}) { | ||
function isElementScrollable([element] = []) { | ||
return element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight | ||
@@ -3,0 +3,0 @@ } |
@@ -1,2 +0,2 @@ | ||
function markElements({elements, ids}) { | ||
function markElements([elements, ids]) { | ||
elements.forEach((el, index) => { | ||
@@ -3,0 +3,0 @@ el.setAttribute('data-eyes-selector', ids[index]) |
@@ -1,2 +0,3 @@ | ||
function scrollTo({element = document.documentElement, offset} = {}) { | ||
function scrollTo([element, offset] = []) { | ||
element = element || document.documentElement | ||
if (element.scrollTo) { | ||
@@ -3,0 +4,0 @@ element.scrollTo(offset.x, offset.y) |
@@ -1,2 +0,2 @@ | ||
function setElementStyleProperties({element, properties} = {}) { | ||
function setElementStyleProperties([element, properties] = []) { | ||
return Object.keys(properties).reduce((original, property) => { | ||
@@ -3,0 +3,0 @@ original[property] = element.style[property] |
const setElementStyleProperties = require('./setElementStyleProperties') | ||
function translateTo({offset, element = document.documentElement} = {}) { | ||
function translateTo([element, offset] = []) { | ||
element = element || document.documentElement | ||
const value = `translate(${-offset.x}px, ${-offset.y}px)` | ||
setElementStyleProperties({ | ||
element, | ||
properties: {transform: value, webkitTransform: value}, | ||
}) | ||
setElementStyleProperties([element, {transform: value, webkitTransform: value}]) | ||
return offset | ||
@@ -10,0 +8,0 @@ } |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {blurElement} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('blur element', async () => { | ||
@@ -28,3 +24,3 @@ await page.goto(url) | ||
assert.ok(isFocused) | ||
await page.evaluate(blurElement, {element}) | ||
await page.evaluate(blurElement, [element]) | ||
const isBlurred = await page.evaluate(element => element !== document.activeElement, element) | ||
@@ -46,42 +42,44 @@ assert.ok(isBlurred) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('blur element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#focusable') | ||
await element.click() | ||
const isFocused = await driver.execute(function(element) { | ||
return element === document.activeElement | ||
}, element) | ||
assert.ok(isFocused) | ||
await driver.execute(blurElement, {element}) | ||
const isBlurred = await driver.execute(function(element) { | ||
return element !== document.activeElement | ||
}, element) | ||
assert.ok(isBlurred) | ||
}) | ||
it('blur element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#focusable') | ||
await element.click() | ||
const isFocused = await driver.execute(function(element) { | ||
return element === document.activeElement | ||
}, element) | ||
assert.ok(isFocused) | ||
await driver.execute(blurElement, [element]) | ||
const isBlurred = await driver.execute(function(element) { | ||
return element !== document.activeElement | ||
}, element) | ||
assert.ok(isBlurred) | ||
}) | ||
it('blur active element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#focusable') | ||
await element.click() | ||
const isFocused = await driver.execute(function(element) { | ||
return element === document.activeElement | ||
}, element) | ||
assert.ok(isFocused) | ||
await driver.execute(blurElement) | ||
const isBlurred = await driver.execute(function(element) { | ||
return element !== document.activeElement | ||
}, element) | ||
assert.ok(isBlurred) | ||
it('blur active element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#focusable') | ||
await element.click() | ||
const isFocused = await driver.execute(function(element) { | ||
return element === document.activeElement | ||
}, element) | ||
assert.ok(isFocused) | ||
await driver.execute(blurElement) | ||
const isBlurred = await driver.execute(function(element) { | ||
return element !== document.activeElement | ||
}, element) | ||
assert.ok(isBlurred) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {cleanupElementIds, markElements} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('cleanupElementIds', async () => { | ||
@@ -26,3 +22,3 @@ await page.goto(url) | ||
const ids = ['aaa', 'bbb', 'ccc'] | ||
await page.evaluate(markElements, {elements, ids}) | ||
await page.evaluate(markElements, [elements, ids]) | ||
const selector = | ||
@@ -32,3 +28,3 @@ '[data-eyes-selector="aaa"],[data-eyes-selector="bbb"],[data-eyes-selector="ccc"]' | ||
assert.strictEqual(markedElements.length, 3) | ||
await page.evaluate(cleanupElementIds, {elements}) | ||
await page.evaluate(cleanupElementIds, [elements]) | ||
const markedElementsAfterCleanup = await page.$$(selector) | ||
@@ -39,26 +35,28 @@ assert.strictEqual(markedElementsAfterCleanup.length, 0) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('cleanupElementIds', async () => { | ||
await driver.url(url) | ||
const elements = await driver.$$('#scrollable,#static,#fixed') | ||
const ids = ['aaa', 'bbb', 'ccc'] | ||
await driver.execute(markElements, {elements, ids}) | ||
const selector = | ||
'[data-eyes-selector="aaa"],[data-eyes-selector="bbb"],[data-eyes-selector="ccc"]' | ||
const markedElements = await driver.$$(selector) | ||
assert.strictEqual(markedElements.length, 3) | ||
await driver.execute(cleanupElementIds, {elements}) | ||
const markedElementsAfterCleanup = await driver.$$(selector) | ||
assert.strictEqual(markedElementsAfterCleanup.length, 0) | ||
it('cleanupElementIds', async () => { | ||
await driver.url(url) | ||
const elements = await driver.$$('#scrollable,#static,#fixed') | ||
const ids = ['aaa', 'bbb', 'ccc'] | ||
await driver.execute(markElements, [elements, ids]) | ||
const selector = | ||
'[data-eyes-selector="aaa"],[data-eyes-selector="bbb"],[data-eyes-selector="ccc"]' | ||
const markedElements = await driver.$$(selector) | ||
assert.strictEqual(markedElements.length, 3) | ||
await driver.execute(cleanupElementIds, [elements]) | ||
const markedElementsAfterCleanup = await driver.$$(selector) | ||
assert.strictEqual(markedElementsAfterCleanup.length, 0) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {focusElement} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('focus element', async () => { | ||
@@ -27,3 +23,3 @@ await page.goto(url) | ||
assert.ok(isBlurred) | ||
await page.evaluate(focusElement, {element}) | ||
await page.evaluate(focusElement, [element]) | ||
const isFocused = await page.evaluate(element => element === document.activeElement, element) | ||
@@ -34,26 +30,28 @@ assert.ok(isFocused) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('focus element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#focusable') | ||
const isBlurred = await driver.execute(function(element) { | ||
return element !== document.activeElement | ||
}, element) | ||
assert.ok(isBlurred) | ||
await driver.execute(focusElement, {element}) | ||
const isFocused = await driver.execute(function(element) { | ||
return element === document.activeElement | ||
}, element) | ||
assert.ok(isFocused) | ||
it('focus element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#focusable') | ||
const isBlurred = await driver.execute(function(element) { | ||
return element !== document.activeElement | ||
}, element) | ||
assert.ok(isBlurred) | ||
await driver.execute(focusElement, [element]) | ||
const isFocused = await driver.execute(function(element) { | ||
return element === document.activeElement | ||
}, element) | ||
assert.ok(isFocused) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,12 +8,20 @@ const {getContextInfo} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
}) | ||
async function isEqualElements(frame, element1, element2) { | ||
return frame.evaluate(([element1, element2]) => element1 === element2, [element1, element2]) | ||
} | ||
after(async () => { | ||
await browser.close() | ||
async function mapResult(result) { | ||
const properties = Array.from(await result.getProperties(), ([_, value]) => | ||
value._objectType === 'node' ? value.asElement() : value.jsonValue(), | ||
) | ||
return Promise.all(properties) | ||
} | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
@@ -25,10 +32,10 @@ | ||
const frame = await page.frame('frame') | ||
const contextInfo = await frame.evaluate(getContextInfo) | ||
const documentElement = await frame.evaluate('document.documentElement') | ||
assert.deepStrictEqual(contextInfo, { | ||
isRoot: false, | ||
isCORS: false, | ||
selector: '/HTML[1]/BODY[1]/DIV[1]/IFRAME[1]', | ||
documentElement, | ||
}) | ||
const expectedDocumentElement = await frame.evaluateHandle('document.documentElement') | ||
const [documentElement, selector, isRoot, isCORS] = await frame | ||
.evaluateHandle(getContextInfo) | ||
.then(mapResult) | ||
assert.strictEqual(isRoot, false) | ||
assert.strictEqual(isCORS, false) | ||
assert.strictEqual(selector, '/HTML[1]/BODY[1]/DIV[1]/IFRAME[1]') | ||
assert.ok(await isEqualElements(page, documentElement, expectedDocumentElement)) | ||
}) | ||
@@ -38,48 +45,56 @@ | ||
await page.goto(url) | ||
const contextInfo = await page.evaluate(getContextInfo) | ||
const documentElement = await page.evaluate('document.documentElement') | ||
assert.deepStrictEqual(contextInfo, { | ||
isRoot: true, | ||
isCORS: false, | ||
selector: null, | ||
documentElement, | ||
}) | ||
const expectedDocumentElement = await page.evaluateHandle('document.documentElement') | ||
const [documentElement, selector, isRoot, isCORS] = await page | ||
.evaluateHandle(getContextInfo) | ||
.then(mapResult) | ||
assert.strictEqual(isRoot, true) | ||
assert.strictEqual(isCORS, false) | ||
assert.strictEqual(selector, null) | ||
assert.ok(await isEqualElements(page, documentElement, expectedDocumentElement)) | ||
}) | ||
}) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
async function isEqualElements(element1, element2) { | ||
return driver.execute( | ||
function(element1, element2) { | ||
return element1 === element2 | ||
}, | ||
element1, | ||
element2, | ||
) | ||
} | ||
}) | ||
it('return context info', async () => { | ||
await driver.url(url) | ||
await driver.switchToFrame(await driver.$('iframe[name="frame"]')) | ||
const contextInfo = await driver.execute(getContextInfo) | ||
const documentElement = await driver.execute('return document.documentElement') | ||
assert.deepStrictEqual(contextInfo, { | ||
isRoot: false, | ||
isCORS: false, | ||
selector: '/HTML[1]/BODY[1]/DIV[1]/IFRAME[1]', | ||
documentElement, | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
}) | ||
it('return top context info', async () => { | ||
await driver.url(url) | ||
const contextInfo = await driver.execute(getContextInfo) | ||
const documentElement = await driver.execute('return document.documentElement') | ||
assert.deepStrictEqual(contextInfo, { | ||
isRoot: true, | ||
isCORS: false, | ||
selector: null, | ||
documentElement, | ||
it('return context info', async () => { | ||
await driver.url(url) | ||
await driver.switchToFrame(await driver.$('iframe[name="frame"]')) | ||
const expectedDocumentElement = await driver.execute('return document.documentElement') | ||
const [documentElement, selector, isRoot, isCORS] = await driver.execute(getContextInfo) | ||
assert.strictEqual(isRoot, false) | ||
assert.strictEqual(isCORS, false) | ||
assert.strictEqual(selector, '/HTML[1]/BODY[1]/DIV[1]/IFRAME[1]') | ||
assert.ok(await isEqualElements(documentElement, expectedDocumentElement)) | ||
}) | ||
it('return top context info', async () => { | ||
await driver.url(url) | ||
const expectedDocumentElement = await driver.execute('return document.documentElement') | ||
const [documentElement, selector, isRoot, isCORS] = await driver.execute(getContextInfo) | ||
assert.strictEqual(isRoot, true) | ||
assert.strictEqual(isCORS, false) | ||
assert.strictEqual(selector, null) | ||
assert.ok(await isEqualElements(documentElement, expectedDocumentElement)) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {getDocumentSize} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('return document size', async () => { | ||
@@ -29,18 +25,20 @@ await page.goto(url) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('return document size', async () => { | ||
await driver.url(url) | ||
const size = await driver.execute(getDocumentSize) | ||
assert.deepStrictEqual(size, {width: 3000, height: 3000}) | ||
it('return document size', async () => { | ||
await driver.url(url) | ||
const size = await driver.execute(getDocumentSize) | ||
assert.deepStrictEqual(size, {width: 3000, height: 3000}) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,21 +8,18 @@ const {getElementComputedStyleProperties} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('return element computed style properties', async () => { | ||
await page.goto(url) | ||
const element = await page.$('#static') | ||
const computedStyleProperties = await page.evaluate(getElementComputedStyleProperties, { | ||
const computedStyleProperties = await page.evaluate(getElementComputedStyleProperties, [ | ||
element, | ||
properties: ['background-color', 'border-top-width'], | ||
}) | ||
['background-color', 'border-top-width'], | ||
]) | ||
assert.deepStrictEqual(computedStyleProperties, ['rgb(0, 128, 128)', '3px']) | ||
@@ -33,22 +29,24 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('return element computed style properties', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const computedStyleProperties = await driver.execute(getElementComputedStyleProperties, { | ||
element, | ||
properties: ['background-color', 'border-top-width'], | ||
it('return element computed style properties', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const computedStyleProperties = await driver.execute(getElementComputedStyleProperties, [ | ||
element, | ||
['background-color', 'border-top-width'], | ||
]) | ||
assert.deepStrictEqual(computedStyleProperties, ['rgb(0, 128, 128)', '3px']) | ||
}) | ||
assert.deepStrictEqual(computedStyleProperties, ['rgb(0, 128, 128)', '3px']) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,18 +8,15 @@ const {getElementContentSize} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('return size of scrollable element', async () => { | ||
await page.goto(url) | ||
const element = await page.$('#scrollable') | ||
const size = await page.evaluate(getElementContentSize, {element}) | ||
const size = await page.evaluate(getElementContentSize, [element]) | ||
assert.deepStrictEqual(size, {width: 600, height: 600}) | ||
@@ -32,3 +28,3 @@ }) | ||
const element = await page.$('#static') | ||
const size = await page.evaluate(getElementContentSize, {element}) | ||
const size = await page.evaluate(getElementContentSize, [element]) | ||
assert.deepStrictEqual(size, {width: 294, height: 294}) | ||
@@ -38,26 +34,33 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
const expectedSizes = { | ||
'internet explorer': {width: 566, height: 566}, | ||
'ios safari': {width: 600, height: 600}, | ||
} | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
describe(name, () => { | ||
let driver | ||
it('return size of scrollable element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
const size = await driver.execute(getElementContentSize, {element}) | ||
assert.deepStrictEqual(size, {width: 566, height: 566}) | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('return size of static element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const size = await driver.execute(getElementContentSize, {element}) | ||
assert.deepStrictEqual(size, {width: 294, height: 294}) | ||
it('return size of scrollable element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
const size = await driver.execute(getElementContentSize, [element]) | ||
assert.deepStrictEqual(size, expectedSizes[name]) | ||
}) | ||
it('return size of static element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const size = await driver.execute(getElementContentSize, [element]) | ||
assert.deepStrictEqual(size, {width: 294, height: 294}) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {getElementInnerOffset} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('specific element', async () => { | ||
@@ -29,3 +25,3 @@ await page.goto(url) | ||
}, element) | ||
const offset = await page.evaluate(getElementInnerOffset, {element}) | ||
const offset = await page.evaluate(getElementInnerOffset, [element]) | ||
assert.deepStrictEqual(offset, {x: 20, y: 22}) | ||
@@ -45,35 +41,37 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(function(element) { | ||
element.style.transform = 'translate(-10px, -11px)' | ||
element.scrollLeft = 10 | ||
element.scrollTop = 11 | ||
}, element) | ||
const offset = await driver.execute(getElementInnerOffset, {element}) | ||
assert.deepStrictEqual(offset, {x: 20, y: 22}) | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(function(element) { | ||
element.style.transform = 'translate(-10px, -11px)' | ||
element.scrollLeft = 10 | ||
element.scrollTop = 11 | ||
}, element) | ||
const offset = await driver.execute(getElementInnerOffset, [element]) | ||
assert.deepStrictEqual(offset, {x: 20, y: 22}) | ||
}) | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(function() { | ||
document.documentElement.style.transform = 'translate(-10px, -11px)' | ||
document.documentElement.scrollLeft = 10 | ||
document.documentElement.scrollTop = 11 | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(function() { | ||
document.documentElement.style.transform = 'translate(-10px, -11px)' | ||
document.documentElement.scrollLeft = 10 | ||
document.documentElement.scrollTop = 11 | ||
}) | ||
const offset = await driver.execute(getElementInnerOffset) | ||
assert.deepStrictEqual(offset, {x: 20, y: 22}) | ||
}) | ||
const offset = await driver.execute(getElementInnerOffset) | ||
assert.deepStrictEqual(offset, {x: 20, y: 22}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,21 +8,15 @@ const {getElementProperties} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('return element properties', async () => { | ||
await page.goto(url) | ||
const element = await page.$('#static') | ||
const {tagName} = await page.evaluate(getElementProperties, { | ||
element, | ||
properties: ['tagName'], | ||
}) | ||
const {tagName} = await page.evaluate(getElementProperties, [element, ['tagName']]) | ||
assert.deepStrictEqual(tagName, 'DIV') | ||
@@ -33,22 +26,21 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('return element properties', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const {tagName} = await driver.execute(getElementProperties, { | ||
element, | ||
properties: ['tagName'], | ||
it('return element properties', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const {tagName} = await driver.execute(getElementProperties, [element, ['tagName']]) | ||
assert.deepStrictEqual(tagName, 'DIV') | ||
}) | ||
assert.deepStrictEqual(tagName, 'DIV') | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,18 +8,15 @@ const {getElementRect} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('return static element client rect', async () => { | ||
await page.goto(url) | ||
const element = await page.$('#static') | ||
const offset = await page.evaluate(getElementRect, {element, isClient: true}) | ||
const offset = await page.evaluate(getElementRect, [element, true]) | ||
assert.deepStrictEqual(offset, {x: 303, y: 3, width: 294, height: 294}) | ||
@@ -32,3 +28,3 @@ }) | ||
const element = await page.$('#static') | ||
const offset = await page.evaluate(getElementRect, {element}) | ||
const offset = await page.evaluate(getElementRect, [element]) | ||
assert.deepStrictEqual(offset, {x: 300, y: 0, width: 300, height: 300}) | ||
@@ -38,62 +34,71 @@ }) | ||
it('return fixed element rect', async () => { | ||
await page.setViewportSize({width: 500, height: 500}) | ||
await page.goto(url) | ||
const element = await page.$('#fixed') | ||
await page.evaluate(() => scrollTo(500, 500)) | ||
const offset = await page.evaluate(getElementRect, {element}) | ||
assert.deepStrictEqual(offset, {x: 200, y: 200, width: 300, height: 300}) | ||
const offset = await page.evaluate(getElementRect, [element]) | ||
assert.deepStrictEqual(offset, {x: 500, y: 300, width: 300, height: 300}) | ||
}) | ||
it('return fixed element child rect', async () => { | ||
await page.setViewportSize({width: 500, height: 500}) | ||
await page.goto(url) | ||
const element = await page.$('#fixed-child') | ||
await page.evaluate(() => scrollTo(500, 500)) | ||
const offset = await page.evaluate(getElementRect, {element}) | ||
assert.deepStrictEqual(offset, {x: 230, y: 230, width: 240, height: 240}) | ||
const offset = await page.evaluate(getElementRect, [element]) | ||
assert.deepStrictEqual(offset, {x: 530, y: 330, width: 240, height: 240}) | ||
}) | ||
}) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
const expectedRects = { | ||
'internet explorer': { | ||
fixed: {x: 483, y: 283, width: 300, height: 300}, | ||
child: {x: 513, y: 313, width: 240, height: 240}, | ||
}, | ||
'ios safari': { | ||
fixed: {x: 75, y: 335, width: 300, height: 300}, | ||
child: {x: 105, y: 365, width: 240, height: 240}, | ||
}, | ||
} | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
describe(name, () => { | ||
let driver | ||
it('return static element client rect', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const offset = await driver.execute(getElementRect, {element, isClient: true}) | ||
assert.deepStrictEqual(offset, {x: 303, y: 3, width: 294, height: 294}) | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('return static element rect', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const offset = await driver.execute(getElementRect, {element}) | ||
assert.deepStrictEqual(offset, {x: 300, y: 0, width: 300, height: 300}) | ||
}) | ||
it('return static element client rect', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const offset = await driver.execute(getElementRect, [element, true]) | ||
assert.deepStrictEqual(offset, {x: 303, y: 3, width: 294, height: 294}) | ||
}) | ||
it('return fixed element rect', async () => { | ||
await driver.setWindowSize(500, 500) | ||
await driver.url(url) | ||
const element = await driver.$('#fixed') | ||
await driver.execute('scrollTo(500, 500)') | ||
const offset = await driver.execute(getElementRect, {element}) | ||
assert.deepStrictEqual(offset, {x: 167, y: 97, width: 300, height: 300}) | ||
}) | ||
it('return static element rect', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const offset = await driver.execute(getElementRect, [element]) | ||
assert.deepStrictEqual(offset, {x: 300, y: 0, width: 300, height: 300}) | ||
}) | ||
it('return fixed element child rect', async () => { | ||
await driver.setWindowSize(500, 500) | ||
await driver.url(url) | ||
const element = await driver.$('#fixed-child') | ||
await driver.execute('scrollTo(500, 500)') | ||
const offset = await driver.execute(getElementRect, {element}) | ||
assert.deepStrictEqual(offset, {x: 197, y: 127, width: 240, height: 240}) | ||
it('return fixed element rect', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#fixed') | ||
await driver.execute('scrollTo(500, 500)') | ||
const offset = await driver.execute(getElementRect, [element]) | ||
assert.deepStrictEqual(offset, expectedRects[name].fixed) | ||
}) | ||
it('return fixed element child rect', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#fixed-child') | ||
await driver.execute('scrollTo(500, 500)') | ||
const offset = await driver.execute(getElementRect, [element]) | ||
assert.deepStrictEqual(offset, expectedRects[name].child) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {getElementScrollOffset} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('specific element', async () => { | ||
@@ -26,3 +22,3 @@ await page.goto(url) | ||
await page.evaluate(element => element.scrollTo(10, 11), element) | ||
const offset = await page.evaluate(getElementScrollOffset, {element}) | ||
const offset = await page.evaluate(getElementScrollOffset, [element]) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
@@ -39,33 +35,35 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(function(element) { | ||
element.scrollLeft = 10 | ||
element.scrollTop = 11 | ||
}, element) | ||
const offset = await driver.execute(getElementScrollOffset, {element}) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(function(element) { | ||
element.scrollLeft = 10 | ||
element.scrollTop = 11 | ||
}, element) | ||
const offset = await driver.execute(getElementScrollOffset, [element]) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(function() { | ||
document.documentElement.scrollLeft = 10 | ||
document.documentElement.scrollTop = 11 | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(function() { | ||
document.documentElement.scrollLeft = 10 | ||
document.documentElement.scrollTop = 11 | ||
}) | ||
const offset = await driver.execute(getElementScrollOffset) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
const offset = await driver.execute(getElementScrollOffset) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {getElementStyleProperties} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('return element style properties', async () => { | ||
@@ -26,6 +22,6 @@ await page.goto(url) | ||
await page.evaluate(element => (element.style.backgroundColor = 'red'), element) | ||
const {backgroundColor} = await page.evaluate(getElementStyleProperties, { | ||
const {backgroundColor} = await page.evaluate(getElementStyleProperties, [ | ||
element, | ||
properties: ['backgroundColor'], | ||
}) | ||
['backgroundColor'], | ||
]) | ||
assert.deepStrictEqual(backgroundColor, 'red') | ||
@@ -35,25 +31,27 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('return element style properties', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
await driver.execute(function(element) { | ||
element.style.backgroundColor = 'red' | ||
}, element) | ||
const {backgroundColor} = await driver.execute(getElementStyleProperties, { | ||
element, | ||
properties: ['backgroundColor'], | ||
it('return element style properties', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
await driver.execute(function(element) { | ||
element.style.backgroundColor = 'red' | ||
}, element) | ||
const {backgroundColor} = await driver.execute(getElementStyleProperties, [ | ||
element, | ||
['backgroundColor'], | ||
]) | ||
assert.deepStrictEqual(backgroundColor, 'red') | ||
}) | ||
assert.deepStrictEqual(backgroundColor, 'red') | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {getElementTranslateOffset} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('specific element', async () => { | ||
@@ -26,3 +22,3 @@ await page.goto(url) | ||
await page.evaluate(element => (element.style.transform = 'translate(-10px, -11px)'), element) | ||
const offset = await page.evaluate(getElementTranslateOffset, {element}) | ||
const offset = await page.evaluate(getElementTranslateOffset, [element]) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
@@ -41,31 +37,33 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(function(element) { | ||
element.style.transform = 'translate(-10px, -11px)' | ||
}, element) | ||
const offset = await driver.execute(getElementTranslateOffset, {element}) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(function(element) { | ||
element.style.transform = 'translate(-10px, -11px)' | ||
}, element) | ||
const offset = await driver.execute(getElementTranslateOffset, [element]) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(function() { | ||
document.documentElement.style.transform = 'translate(-10px, -11px)' | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(function() { | ||
document.documentElement.style.transform = 'translate(-10px, -11px)' | ||
}) | ||
const offset = await driver.execute(getElementTranslateOffset) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
const offset = await driver.execute(getElementTranslateOffset) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {getElementXpath} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('return element xpath', async () => { | ||
@@ -26,3 +22,3 @@ await page.goto(url) | ||
const element = await frame.$('.b4') | ||
const xpath = await frame.evaluate(getElementXpath, {element}) | ||
const xpath = await frame.evaluate(getElementXpath, [element]) | ||
assert.deepStrictEqual(xpath, '/HTML[1]/BODY[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]') | ||
@@ -32,20 +28,22 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('return element xpath', async () => { | ||
await driver.url(url) | ||
await driver.switchToFrame(await driver.$('iframe[name="frame"]')) | ||
const element = await driver.$('.b4') | ||
const xpath = await driver.execute(getElementXpath, {element}) | ||
assert.deepStrictEqual(xpath, '/HTML[1]/BODY[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]') | ||
it('return element xpath', async () => { | ||
await driver.url(url) | ||
await driver.switchToFrame(await driver.$('iframe[name="frame"]')) | ||
const element = await driver.$('.b4') | ||
const xpath = await driver.execute(getElementXpath, [element]) | ||
assert.deepStrictEqual(xpath, '/HTML[1]/BODY[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]') | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,52 +8,41 @@ const {getViewportSize} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('return viewport size', async () => { | ||
await page.goto(url) | ||
const expectedViewportSize = {width: 500, height: 500} | ||
await page.setViewportSize(expectedViewportSize) | ||
const viewportSize = await page.evaluate(getViewportSize) | ||
assert.deepStrictEqual(viewportSize, expectedViewportSize) | ||
assert.deepStrictEqual(viewportSize, {width: 800, height: 600}) | ||
}) | ||
}) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
const expectedViewportSizes = { | ||
'internet explorer': {width: 800, height: 600}, | ||
'ios safari': {width: 375, height: 635}, | ||
} | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
describe(name, () => { | ||
let driver | ||
it('return viewport size', async () => { | ||
await driver.url(url) | ||
const expectedViewportSize = {width: 500, height: 500} | ||
await driver.setWindowSize(expectedViewportSize.width, expectedViewportSize.height) | ||
const browserWrapperSize = await driver.execute(function() { | ||
return { | ||
width: window.outerWidth - window.innerWidth, | ||
height: window.outerHeight - window.innerHeight, | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
await driver.setWindowSize( | ||
expectedViewportSize.width + browserWrapperSize.width, | ||
expectedViewportSize.height + browserWrapperSize.height, | ||
) | ||
const viewportSize = await driver.execute(getViewportSize) | ||
assert.deepStrictEqual(viewportSize, expectedViewportSize) | ||
it('return viewport size', async () => { | ||
await driver.url(url) | ||
const viewportSize = await driver.execute(getViewportSize) | ||
assert.deepStrictEqual(viewportSize, expectedViewportSizes[name]) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,18 +8,15 @@ const {isElementScrollable} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('scrollable element', async () => { | ||
await page.goto(url) | ||
const element = await page.$('#scrollable') | ||
const isScrollable = await page.evaluate(isElementScrollable, {element}) | ||
const isScrollable = await page.evaluate(isElementScrollable, [element]) | ||
assert.ok(isScrollable) | ||
@@ -32,3 +28,3 @@ }) | ||
const element = await page.$('#static') | ||
const isScrollable = await page.evaluate(isElementScrollable, {element}) | ||
const isScrollable = await page.evaluate(isElementScrollable, [element]) | ||
assert.ok(!isScrollable) | ||
@@ -38,26 +34,28 @@ }) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('scrollable element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
const isScrollable = await driver.execute(isElementScrollable, {element}) | ||
assert.ok(isScrollable) | ||
}) | ||
it('scrollable element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
const isScrollable = await driver.execute(isElementScrollable, [element]) | ||
assert.ok(isScrollable) | ||
}) | ||
it('not scrollable element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const isScrollable = await driver.execute(isElementScrollable, {element}) | ||
assert.ok(!isScrollable) | ||
it('not scrollable element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#static') | ||
const isScrollable = await driver.execute(isElementScrollable, [element]) | ||
assert.ok(!isScrollable) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,14 +8,11 @@ const {markElements} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('markElements', async () => { | ||
@@ -26,3 +22,3 @@ await page.goto(url) | ||
const ids = ['aaa', 'bbb', 'ccc'] | ||
await page.evaluate(markElements, {elements, ids}) | ||
await page.evaluate(markElements, [elements, ids]) | ||
const markedElementIds = await page.evaluate(() => | ||
@@ -40,26 +36,28 @@ [].map.call( | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('markElements', async () => { | ||
await driver.url(url) | ||
const elements = await driver.$$('#scrollable,#static,#fixed') | ||
const ids = ['aaa', 'bbb', 'ccc'] | ||
await driver.execute(markElements, {elements, ids}) | ||
const markedElementIds = await driver.execute(function() { | ||
return [].map.call( | ||
document.querySelectorAll('[data-eyes-selector="aaa"],[data-eyes-selector="bbb"],[data-eyes-selector="ccc"]'), // eslint-disable-line | ||
function(el) { return el.id }// eslint-disable-line | ||
) | ||
it('markElements', async () => { | ||
await driver.url(url) | ||
const elements = await driver.$$('#scrollable,#static,#fixed') | ||
const ids = ['aaa', 'bbb', 'ccc'] | ||
await driver.execute(markElements, [elements, ids]) | ||
const markedElementIds = await driver.execute(function() { | ||
return [].map.call( | ||
document.querySelectorAll('[data-eyes-selector="aaa"],[data-eyes-selector="bbb"],[data-eyes-selector="ccc"]'), // eslint-disable-line | ||
function(el) { return el.id }// eslint-disable-line | ||
) | ||
}) | ||
assert.deepStrictEqual(markedElementIds, ['scrollable', 'static', 'fixed']) | ||
}) | ||
assert.deepStrictEqual(markedElementIds, ['scrollable', 'static', 'fixed']) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,18 +8,15 @@ const {scrollTo} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('specific element', async () => { | ||
await page.goto(url) | ||
const element = await page.$('#scrollable') | ||
await page.evaluate(scrollTo, {element, offset: {x: 10, y: 11}}) | ||
await page.evaluate(scrollTo, [element, {x: 10, y: 11}]) | ||
const offset = await page.evaluate( | ||
@@ -35,3 +31,3 @@ element => ({x: element.scrollLeft, y: element.scrollTop}), | ||
await page.goto(url) | ||
await page.evaluate(scrollTo, {offset: {x: 10, y: 11}}) | ||
await page.evaluate(scrollTo, [undefined, {x: 10, y: 11}]) | ||
const offset = await page.evaluate(() => ({ | ||
@@ -45,34 +41,36 @@ x: document.documentElement.scrollLeft, | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(scrollTo, {element, offset: {x: 10, y: 11}}) | ||
const offset = await driver.execute(function(element) { | ||
return {x: element.scrollLeft, y: element.scrollTop} | ||
}, element) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(scrollTo, [element, {x: 10, y: 11}]) | ||
const offset = await driver.execute(function(element) { | ||
return {x: element.scrollLeft, y: element.scrollTop} | ||
}, element) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(scrollTo, {offset: {x: 10, y: 11}}) | ||
const offset = await driver.execute(function() { | ||
return { | ||
x: document.documentElement.scrollLeft, | ||
y: document.documentElement.scrollTop, | ||
} | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(scrollTo, [undefined, {x: 10, y: 11}]) | ||
const offset = await driver.execute(function() { | ||
return { | ||
x: document.documentElement.scrollLeft, | ||
y: document.documentElement.scrollTop, | ||
} | ||
}) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
assert.deepStrictEqual(offset, {x: 10, y: 11}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,21 +8,18 @@ const {setElementStyleProperties} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('set element style properties', async () => { | ||
await page.goto(url) | ||
const element = await page.$('#scrollable') | ||
const {overflow} = await page.evaluate(setElementStyleProperties, { | ||
const {overflow} = await page.evaluate(setElementStyleProperties, [ | ||
element, | ||
properties: {overflow: 'hidden'}, | ||
}) | ||
{overflow: 'hidden'}, | ||
]) | ||
assert.deepStrictEqual(overflow, '') | ||
@@ -35,26 +31,28 @@ const actualOverflow = await page.evaluate(element => element.style.overflow, element) | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('set element style properties', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
const {overflow} = await driver.execute(setElementStyleProperties, { | ||
element, | ||
properties: {overflow: 'hidden'}, | ||
it('set element style properties', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
const {overflow} = await driver.execute(setElementStyleProperties, [ | ||
element, | ||
{overflow: 'hidden'}, | ||
]) | ||
assert.deepStrictEqual(overflow, '') | ||
const actualOverflow = await driver.execute(function(element) { | ||
return element.style.overflow | ||
}, element) | ||
assert.deepStrictEqual(actualOverflow, 'hidden') | ||
}) | ||
assert.deepStrictEqual(overflow, '') | ||
const actualOverflow = await driver.execute(function(element) { | ||
return element.style.overflow | ||
}, element) | ||
assert.deepStrictEqual(actualOverflow, 'hidden') | ||
}) | ||
}) | ||
} | ||
}) |
@@ -1,2 +0,1 @@ | ||
const playwright = require('playwright') | ||
const assert = require('assert') | ||
@@ -9,18 +8,15 @@ const {translateTo} = require('../dist/index') | ||
describe('chrome', () => { | ||
let browser, page | ||
let page | ||
before(async () => { | ||
browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
page = await context.newPage() | ||
before(async function() { | ||
page = await global.getDriver('chrome') | ||
if (!page) { | ||
this.skip() | ||
} | ||
}) | ||
after(async () => { | ||
await browser.close() | ||
}) | ||
it('specific element', async () => { | ||
await page.goto(url) | ||
const element = await page.$('#scrollable') | ||
await page.evaluate(translateTo, {element, offset: {x: 10, y: 11}}) | ||
await page.evaluate(translateTo, [element, {x: 10, y: 11}]) | ||
const transforms = await page.evaluate( | ||
@@ -41,3 +37,3 @@ element => ({ | ||
await page.goto(url) | ||
await page.evaluate(translateTo, {offset: {x: 10, y: 11}}) | ||
await page.evaluate(translateTo, [undefined, {x: 10, y: 11}]) | ||
const transforms = await page.evaluate(() => ({ | ||
@@ -54,43 +50,45 @@ transform: document.documentElement.style.transform, | ||
describe('ie', () => { | ||
let driver | ||
for (const name of ['internet explorer', 'ios safari']) { | ||
describe(name, () => { | ||
let driver | ||
before(async function() { | ||
driver = global.ieDriver | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}) | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(translateTo, {element, offset: {x: 10, y: 11}}) | ||
const transforms = await driver.execute(function(element) { | ||
return { | ||
transform: element.style.transform, | ||
webkitTransform: element.style.webkitTransform, | ||
before(async function() { | ||
driver = await global.getDriver(name) | ||
if (!driver) { | ||
this.skip() | ||
} | ||
}, element) | ||
assert.deepStrictEqual(transforms, { | ||
transform: 'translate(-10px, -11px)', | ||
webkitTransform: 'translate(-10px, -11px)', | ||
}) | ||
}) | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(translateTo, {offset: {x: 10, y: 11}}) | ||
const transforms = await driver.execute(function() { | ||
return { | ||
transform: document.documentElement.style.transform, | ||
webkitTransform: document.documentElement.style.webkitTransform, | ||
} | ||
it('specific element', async () => { | ||
await driver.url(url) | ||
const element = await driver.$('#scrollable') | ||
await driver.execute(translateTo, [element, {x: 10, y: 11}]) | ||
const transforms = await driver.execute(function(element) { | ||
return { | ||
transform: element.style.transform, | ||
webkitTransform: element.style.webkitTransform, | ||
} | ||
}, element) | ||
assert.deepStrictEqual(transforms, { | ||
transform: 'translate(-10px, -11px)', | ||
webkitTransform: 'translate(-10px, -11px)', | ||
}) | ||
}) | ||
assert.deepStrictEqual(transforms, { | ||
transform: 'translate(-10px, -11px)', | ||
webkitTransform: 'translate(-10px, -11px)', | ||
it('default element', async () => { | ||
await driver.url(url) | ||
await driver.execute(translateTo, [undefined, {x: 10, y: 11}]) | ||
const transforms = await driver.execute(function() { | ||
return { | ||
transform: document.documentElement.style.transform, | ||
webkitTransform: document.documentElement.style.webkitTransform, | ||
} | ||
}) | ||
assert.deepStrictEqual(transforms, { | ||
transform: 'translate(-10px, -11px)', | ||
webkitTransform: 'translate(-10px, -11px)', | ||
}) | ||
}) | ||
}) | ||
}) | ||
} | ||
}) |
@@ -0,28 +1,69 @@ | ||
const playwright = require('playwright') | ||
const {remote} = require('webdriverio') | ||
const drivers = new Map() | ||
exports.mochaHooks = { | ||
async beforeAll() { | ||
global.ieDriver = await remote({ | ||
protocol: 'https', | ||
hostname: 'ondemand.saucelabs.com', | ||
path: '/wd/hub', | ||
port: 443, | ||
logLevel: 'silent', | ||
capabilities: { | ||
browserName: 'internet explorer', | ||
browserVersion: '11.285', | ||
platformName: 'Windows 10', | ||
'sauce:options': { | ||
name: 'Snippets tests', | ||
username: process.env.SAUCE_USERNAME, | ||
accessKey: process.env.SAUCE_ACCESS_KEY, | ||
}, | ||
}, | ||
connectionRetryCount: 0, | ||
}) | ||
global.getDriver = async function(name) { | ||
let {driver} = drivers.get(name) || {} | ||
if (!driver) { | ||
if (name === 'chrome') { | ||
const browser = await playwright.chromium.launch() | ||
const context = await browser.newContext() | ||
driver = await context.newPage() | ||
await driver.setViewportSize({width: 800, height: 600}) | ||
drivers.set('chrome', {driver, cleanup: () => browser.close()}) | ||
} else if (name === 'internet explorer') { | ||
driver = await remote({ | ||
protocol: 'https', | ||
hostname: 'ondemand.saucelabs.com', | ||
path: '/wd/hub', | ||
port: 443, | ||
logLevel: 'silent', | ||
capabilities: { | ||
browserName: 'internet explorer', | ||
browserVersion: '11.285', | ||
platformName: 'Windows 10', | ||
'sauce:options': { | ||
name: 'Snippets tests', | ||
username: process.env.SAUCE_USERNAME, | ||
accessKey: process.env.SAUCE_ACCESS_KEY, | ||
}, | ||
}, | ||
connectionRetryCount: 0, | ||
}) | ||
await driver.setWindowSize(816, 686) | ||
drivers.set('internet explorer', {driver, cleanup: () => driver.deleteSession()}) | ||
} else if (name === 'ios safari') { | ||
driver = await remote({ | ||
protocol: 'https', | ||
hostname: 'ondemand.saucelabs.com', | ||
path: '/wd/hub', | ||
port: 443, | ||
logLevel: 'silent', | ||
capabilities: { | ||
name: 'Snippets tests', | ||
browserName: 'Safari', | ||
deviceName: 'iPhone XS Simulator', | ||
deviceOrientation: 'portrait', | ||
platformVersion: '13.4', | ||
platformName: 'iOS', | ||
username: process.env.SAUCE_USERNAME, | ||
accessKey: process.env.SAUCE_ACCESS_KEY, | ||
}, | ||
connectionRetryCount: 0, | ||
}) | ||
drivers.set('ios safari', {driver, cleanup: () => driver.deleteSession()}) | ||
} | ||
} | ||
return driver | ||
} | ||
}, | ||
async afterAll() { | ||
await global.ieDriver.deleteSession() | ||
for (const {cleanup} of drivers.values()) { | ||
await cleanup() | ||
} | ||
}, | ||
} |
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
114939
13
1844
6