@nodebug/selenium
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -1,1 +0,1 @@ | ||
function WebElement(e){function t(e,t){let n="";e.exact?(attributes.forEach(t=>{n+=`@${t}='${e.id}' or `}),n+=`normalize-space(.)='${e.id}' `,n+=`and not(.//*[normalize-space(.)='${e.id}'])`):(attributes.forEach(t=>{n+=`contains(@${t},'${e.id}') or `}),n+=`contains(normalize-space(.),'${e.id}') `,n+=`and not(.//*[contains(normalize-space(.),'${e.id}')])`);let a=`//*[${n}]`;return e.index&&(a=`(${a})[${e.index}]`),"write"===t?(a+="/following::*[",a+="self::input[@type='text' or @type='password'] or ",a+="self::textarea or ",a+="self::*[@contenteditable='true']",a+="]"):"check"===t?a+="/preceding-sibling::input[@type='checkbox']":"select"===t&&(a+="/following::select"),"row"===e.type&&(a=`//tbody/tr[(.${a})]`),"column"===e.type&&(a=a.replace("//*",""),a=`//tbody/tr/*[count(//thead//th${a}/preceding-sibling::th)+1]`),a}async function n(e,t,n){let a;if([void 0,null,""].includes(t))a=e.matches;else{if([void 0,null,""].includes(n))throw new ReferenceError(`Location '${t}' cannot be found as relative element is '${n}'`);switch(t){case"above":a=e.matches.filter(e=>n.rect.top>=e.rect.bottom);break;case"below":a=e.matches.filter(e=>n.rect.bottom<=e.rect.top);break;case"toLeftOf":a=e.matches.filter(e=>n.rect.left>=e.rect.right);break;case"toRightOf":a=e.matches.filter(e=>n.rect.right<=e.rect.left);break;case"within":a=e.matches.filter(e=>n.rect.left<=e.rect.left&&n.rect.right>=e.rect.right&&n.rect.top<=e.rect.top&&n.rect.bottom>=e.rect.bottom);break;default:throw new ReferenceError(`Location '${t}' is not supported`)}}return a[0]}async function a(e){return s.executeScript("return arguments[0].getBoundingClientRect();",e)}async function r(e,n){const r=t(e,n),i=await s.findElements(By.xpath(r)),c=i.map(async e=>({element:e,tagName:await e.getTagName(),rect:await a(e),frame:null,contenteditable:await e.getAttribute("contenteditable")||null})),l=await Promise.all(c);return l.filter(e=>e.rect.height>0)}async function i(e,t){const n=await r(e);let a=n;return["write","check"].includes(t)?(a=a.filter(e=>"input"===e.tagName),a.length<1&&(a=await r(e,t))):["select"].includes(t)&&(a=a.filter(e=>"select"===e.tagName),a.length<1&&(a=await r(e,t))),a.length<1&&(a=n),a}async function c(e,t){const n=e.map(async(e,n)=>{const a={...e};return["element","row","column"].includes(a.type)&&a.matches.length<1&&(a.matches=0===n?await i(a,t):await r(a)),a});return Promise.all(n)}async function l(e,t){await s.switchTo().defaultContent();let n=await c(e,t);for(let e=0;e<n.length;e++)if(["element","row","column"].includes(n[e].type)&&n[e].matches.length<1){const a=(await s.findElements(By.xpath("//iframe"))).length;for(let e=0;e<a;e++)await s.wait(until.ableToSwitchToFrame(e)),n=await c(n,t);if(n[e].matches.length<1)throw new ReferenceError(`'${n[e].id}' has no matching elements on page.`)}return n}async function o(e,t){const a=await l(e,t);let r=null;for(let e=a.length-1;e>-1;e--){const t=a[e];if(["element","row","column"].includes(t.type)&&(r=await n(t),null===r))throw new ReferenceError(`'${t.id}' has no matching elements on page.`);if("location"===t.type&&(e-=1,r=await n(a[e],t.located,r),null===r))throw new ReferenceError(`'${a[e].id}' ${t.located} '${a[e+2].id}' has no matching elements on page.`)}return r}const s=e;return{find:o}}const{By:By,until:until}=require("selenium-webdriver"),attributes=["placeholder","value","data-test-id","id","resource-id","name","aria-label","class","hint","title","tooltip","alt","src"];module.exports=WebElement; | ||
function WebElement(e){function t(e,t){let n="";e.exact?(attributes.forEach(t=>{n+=`@${t}='${e.id}' or `}),n+=`normalize-space(.)='${e.id}' `,n+=`and not(.//*[normalize-space(.)='${e.id}'])`):(attributes.forEach(t=>{n+=`contains(@${t},'${e.id}') or `}),n+=`contains(normalize-space(.),'${e.id}') `,n+=`and not(.//*[contains(normalize-space(.),'${e.id}')])`);let a=`//*[${n}]`;return e.index&&(a=`(${a})[${e.index}]`),"write"===t?(a+="/following::*[",a+="self::input[@type='text' or @type='password'] or ",a+="self::textarea or ",a+="self::*[@contenteditable='true']",a+="]"):"check"===t?a+="/preceding-sibling::input[@type='checkbox']":"select"===t&&(a+="/following::select"),a}function n(e){let t="";e.exact?(attributes.forEach(n=>{t+=`@${n}='${e.id}' or `}),t+=`normalize-space(.)='${e.id}' `):(attributes.forEach(n=>{t+=`contains(@${n},'${e.id}') or `}),t+=`contains(normalize-space(.),'${e.id}') `);let n=`//*[${t}]`;return n=`//tbody/tr[(.${n})]`,e.index&&(n=`(${n})[${e.index}]`),n}function a(e){let t="";e.exact?(attributes.forEach(n=>{t+=`@${n}='${e.id}' or `}),t+=`normalize-space(.)='${e.id}' `):(attributes.forEach(n=>{t+=`contains(@${n},'${e.id}') or `}),t+=`contains(normalize-space(.),'${e.id}') `);let n=`[${t}]`;return n=`//tbody/tr/*[count(//thead//th${n}/preceding-sibling::th)+1]`,n}function i(e,i){return"row"===e.type?n(e):"column"===e.type?a(e):t(e,i)}async function r(e,t,n){let a;if([void 0,null,""].includes(t))a=e.matches;else{if([void 0,null,""].includes(n))throw new ReferenceError(`Location '${t}' cannot be found as relative element is '${n}'`);switch(t){case"above":a=e.matches.filter(e=>n.rect.top>=e.rect.bottom);break;case"below":a=e.matches.filter(e=>n.rect.bottom<=e.rect.top);break;case"toLeftOf":a=e.matches.filter(e=>n.rect.left>=e.rect.right);break;case"toRightOf":a=e.matches.filter(e=>n.rect.right<=e.rect.left);break;case"within":a=e.matches.filter(e=>n.rect.left<=e.rect.left&&n.rect.right>=e.rect.right&&n.rect.top<=e.rect.top&&n.rect.bottom>=e.rect.bottom);break;default:throw new ReferenceError(`Location '${t}' is not supported`)}}return a[0]}async function c(e){return f.executeScript("return arguments[0].getBoundingClientRect();",e)}async function o(e,t){const n=i(e,t),a=await f.findElements(By.xpath(n)),r=a.map(async e=>{const t=await e.getAttribute("contenteditable"),n=await e.findElement(By.xpath("./..")).getAttribute("contenteditable");return{element:e,tagName:await e.getTagName(),rect:await c(e),frame:null,contenteditable:t||n||null}}),o=await Promise.all(r);return o.filter(e=>e.rect.height>0)}async function l(e,t){const n=await o(e);let a=n;return["write","check"].includes(t)?(a=a.filter(e=>"input"===e.tagName||"true"===e.contenteditable),a.length<1&&(a=await o(e,t))):["select"].includes(t)&&(a=a.filter(e=>"select"===e.tagName),a.length<1&&(a=await o(e,t))),a.length<1&&(a=n),a}async function s(e,t){const n=e.map(async(e,n)=>{const a={...e};return["element","row","column"].includes(a.type)&&a.matches.length<1&&(a.matches=0===n?await l(a,t):await o(a)),a});return Promise.all(n)}async function u(e,t){await f.switchTo().defaultContent();let n=await s(e,t);for(let e=0;e<n.length;e++)if(["element","row","column"].includes(n[e].type)&&n[e].matches.length<1){const a=(await f.findElements(By.xpath("//iframe"))).length;for(let e=0;e<a;e++)await f.wait(until.ableToSwitchToFrame(e)),n=await s(n,t);if(n[e].matches.length<1)throw new ReferenceError(`'${n[e].id}' has no matching elements on page.`)}return n}async function d(e,t){const n=await u(e,t);let a=null;for(let e=n.length-1;e>-1;e--){const t=n[e];if(["element","row","column"].includes(t.type)&&(a=await r(t),null===a))throw new ReferenceError(`'${t.id}' has no matching elements on page.`);if("location"===t.type&&(e-=1,a=await r(n[e],t.located,a),null===a))throw new ReferenceError(`'${n[e].id}' ${t.located} '${n[e+2].id}' has no matching elements on page.`)}return a}const f=e;return{find:d}}const{By:By,until:until}=require("selenium-webdriver"),attributes=["placeholder","value","data-test-id","id","resource-id","name","aria-label","class","hint","title","tooltip","alt","src"];module.exports=WebElement; |
@@ -1,1 +0,1 @@ | ||
function sleep(e){return new Promise(t=>setTimeout(t,e))}function Driver(e,t){function i(e){let t="";"click"===e.action?t="Clicking on ":"focus"===e.action?t="Focussing on ":"hover"===e.action?t="Hovering on ":"write"===e.action?t=`Writing '${e.data}' into `:"clear"===e.action?t="Clearing text in ":"overwrite"===e.action?t=`Overwriting with '${e.data}' in `:"select"===e.action?t=`Selecting '${e.data}' from dropdown `:"isVisible"===e.action?t="Checking ":"waitVisibility"===e.action?t="Waiting for ":"check"===e.action?t="Checking checkbox for ":"uncheck"===e.action?t="Unchecking checkbox for ":"screenshot"===e.action&&(t="Capturing screenshot of ");for(let e=0;e<F.length;e++){const i=F[e];["element","row","column"].includes(i.type)?(i.exact&&(t+="exact "),t+=`${i.type} '${i.id}' `,i.index&&(t+=`of index '${i.index}' `)):"location"===i.type&&(t+=`located '${i.located}' `)}return"isVisible"===e.action?t+="is visible":"waitVisibility"===e.action&&(t+="to be visible"),log.info(t),!0}async function n(){i({action:"hover"});try{const e=await R.find(F);await(await q.actions()).move({origin:e.element}).perform()}catch(e){throw log.error(`Error during hover.\nError ${e.stack}`),e}return F=[],!0}async function r(){i({action:"focus"});try{const t=await R.find(F);await e.executeScript("return arguments[0].focus();",t.element)}catch(e){throw log.error(`Error during focus.\nError ${e.stack}`),e}return F=[],!0}async function a(t){i({action:"click"});try{const i=await R.find(F);try{await(await q.actions()).move({origin:i.element}).perform()}catch(t){"MoveTargetOutOfBoundsError"===t.name&&(await e.executeScript("return arguments[0].scrollIntoView();",i.element),await(await q.actions()).move({origin:i.element}).perform())}await e.executeScript("return arguments[0].click();",i.element),void 0!==t&&await sleep(1e3*t.wait)}catch(e){throw log.error(`Error during click.\nError ${e.stack}`),e}return F=[],!0}async function o(e){i({action:"write",data:e});try{const t=await R.find(F,"write");if("input"===t.tagName)await t.element.sendKeys(e);else{const i=await t.element.getAttribute("textContent");await t.element.click();for(let e=0;e<i.length;e++)await(await q.actions()).sendKeys(Key.RIGHT).perform();await(await q.actions()).sendKeys(e).perform()}}catch(e){throw log.error(`Error while entering data.\nError ${e.stack}`),e}return F=[],!0}async function c(){i({action:"clear"});try{const e=await R.find(F,"write");if("input"===e.tagName)await e.element.clear();else{const t=await e.element.getAttribute("textContent");await e.element.click();for(let e=0;e<t.length;e++)await(await q.actions()).sendKeys(Key.RIGHT).perform();await(await q.actions()).keyDown(Key.SHIFT).perform();for(let e=0;e<t.length;e++)await(await q.actions()).sendKeys(Key.LEFT).perform();await(await q.actions()).keyUp(Key.SHIFT).perform(),await(await q.actions()).sendKeys("").perform()}}catch(e){throw log.error(`Error while clearing field.\nError ${e.stack}`),e}return F=[],!0}async function s(e){i({action:"overwrite",data:e});try{const t=await R.find(F,"write");if(["input","textarea"].includes(t.tagName))await t.element.clear(),await t.element.sendKeys(e);else{const i=await t.element.getAttribute("textContent");await t.element.click();for(let e=0;e<i.length;e++)await(await q.actions()).sendKeys(Key.RIGHT).perform();await(await q.actions()).keyDown(Key.SHIFT).perform();for(let e=0;e<i.length;e++)await(await q.actions()).sendKeys(Key.LEFT).perform();await(await q.actions()).keyUp(Key.SHIFT).perform(),await(await q.actions()).sendKeys(e).perform()}}catch(e){throw log.error(`Error while overwriting text in field.\nError ${e.stack}`),e}return F=[],!0}async function l(e){i({action:"select",data:e});try{const t=await R.find(F,"select");if("select"!==t.tagName)throw new ReferenceError("Element is not of type select");await t.element.findElement(By.xpath(`.//option[.="${e}"]`)).click()}catch(e){throw log.error(`Error while selecting value in dropdown.\nError ${e.stack}`),e}return F=[],!0}async function u(e){try{const t=await R.find(F,"check"),i=await t.element.isSelected();("check"===e&&!i||"uncheck"===e&&i)&&await t.element.click()}catch(e){throw log.error(`Error during checkbox set.\nError ${e.stack}`),e}return F=[],!0}async function w(){return i({action:"check"}),u("check")}async function f(){return i({action:"uncheck"}),u("uncheck")}function h(){return F.push({exact:!0}),this}function m(e){const t=F.pop();return JSON.stringify(t)===JSON.stringify({exact:!0})?F.push({type:"element",id:e,exact:!0,matches:[],index:!1}):(void 0!==t&&F.push(t),F.push({type:"element",id:e,exact:!1,matches:[],index:!1})),this}function p(e){if("string"!=typeof e)throw new TypeError(`Expected parameter for row is string. Received ${typeof e} instead`);const t=F.pop();return JSON.stringify(t)===JSON.stringify({exact:!0})?F.push({type:"row",id:e,exact:!0,matches:[],index:!1}):(void 0!==t&&F.push(t),F.push({type:"row",id:e,exact:!1,matches:[],index:!1})),this}function d(e){if("string"!=typeof e)throw new TypeError(`Expected parameter for column is string. Received ${typeof e} instead`);const t=F.pop();return JSON.stringify(t)===JSON.stringify({exact:!0})?F.push({type:"column",id:e,exact:!0,matches:[],index:!1}):(void 0!==t&&F.push(t),F.push({type:"column",id:e,exact:!1,matches:[],index:!1})),this}function g(){return F.push({type:"location",located:"above"}),this}function y(){return F.push({type:"location",located:"below"}),this}function k(){return F.push({type:"location",located:"near"}),this}function x(){return F.push({type:"location",located:"toLeftOf"}),this}function b(){return F.push({type:"location",located:"toRightOf"}),this}function v(){return F.push({type:"location",located:"within"}),this}function E(e){if("number"!=typeof e)throw new TypeError(`Expected parameter for atIndex is number. Received ${typeof e} instead`);const t=F.pop();return void 0!==t&&(t.index=e,F.push(t)),this}async function T(t,i){let n;const{implicit:r}=await e.manage().getTimeouts();"number"==typeof i&&await e.manage().setTimeouts({implicit:1e3*i});try{await e.wait(async function(){return n=await R.find(F),![void 0,null,""].includes(n)}())}catch(e){if("fail"===t)throw e}return await e.manage().setTimeouts({implicit:r}),F=[],![void 0,null,""].includes(n)}async function S(e){return i({action:"isVisible"}),T("nofail",e)}async function K(e){return i({action:"waitVisibility"}),T("fail",e)}async function $(t){let n=!1;if(!t){let e;try{e=await R.find(F)}catch(e){log.error(e.stack)}[void 0,null,""].includes(e)||(i({action:"screenshot"}),n=await e.element.takeScreenshot(!0))}n||(log.info("Capturing screenshot of page"),n=await e.takeScreenshot()),F=[];try{return(await imagemin.buffer(Buffer.from(n,"base64"),{plugins:[pngquant({quality:[.1,.4]})]})).toString("base64")}catch(e){return log.error(e.stack),!1}}async function O(e){const t=await $();return V.perform(e,t)}const q=new Browser(e,t),R=new WebElement(e),V=new Visual;let F=[];return{hover:n,click:a,focus:r,write:o,clear:c,overwrite:s,select:l,check:w,uncheck:f,exact:h,element:m,row:p,column:d,above:g,below:y,near:k,toLeftOf:x,toRightOf:b,within:v,atIndex:E,isVisible:S,waitForVisibility:K,screenshot:$,visual:O,newWindow:q.newWindow,close:q.close,newTab:q.newTab,closeTab:q.closeTab,switchTab:q.switchTab,title:q.title,currentURL:q.currentURL,maximize:q.maximize,minimize:q.minimize,fullscreen:q.fullscreen,setSize:q.setSize,getSize:q.getSize,goto:q.goto,refresh:q.refresh,goBack:q.goBack,goForward:q.goForward,reset:q.reset,getDriver:q.getDriver,actions:q.actions}}const{log:log}=require("@nodebug/logger"),imagemin=require("imagemin"),pngquant=require("imagemin-pngquant"),{By:By,Key:Key}=require("selenium-webdriver"),Browser=require("./app/browser.js"),WebElement=require("./app/elements.js"),Visual=require("./app/visual.js");module.exports=Driver; | ||
function sleep(e){return new Promise(t=>setTimeout(t,e))}function Driver(e,t){function i(e){let t="";"click"===e.action?t="Clicking on ":"focus"===e.action?t="Focussing on ":"hover"===e.action?t="Hovering on ":"write"===e.action?t=`Writing '${e.data}' into `:"clear"===e.action?t="Clearing text in ":"overwrite"===e.action?t=`Overwriting with '${e.data}' in `:"select"===e.action?t=`Selecting '${e.data}' from dropdown `:"isVisible"===e.action?t="Checking ":"waitVisibility"===e.action?t="Waiting for ":"check"===e.action?t="Checking checkbox for ":"uncheck"===e.action?t="Unchecking checkbox for ":"screenshot"===e.action&&(t="Capturing screenshot of ");for(let e=0;e<R.length;e++){const i=R[e];["element","row","column"].includes(i.type)?(i.exact&&(t+="exact "),t+=`${i.type} '${i.id}' `,i.index&&(t+=`of index '${i.index}' `)):"location"===i.type&&(t+=`located '${i.located}' `)}return"isVisible"===e.action?t+="is visible":"waitVisibility"===e.action&&(t+="to be visible"),log.info(t),!0}async function n(){i({action:"hover"});try{const e=await N.find(R);await(await q.actions()).move({origin:e.element}).perform()}catch(e){throw log.error(`Error during hover.\nError ${e.stack}`),e}return R=[],!0}async function r(){i({action:"focus"});try{const t=await N.find(R);await e.executeScript("return arguments[0].focus();",t.element)}catch(e){throw log.error(`Error during focus.\nError ${e.stack}`),e}return R=[],!0}async function a(t){i({action:"click"});try{const i=await N.find(R);try{await i.element.click()}catch(t){"ElementNotInteractableError"===t.name&&await e.executeScript("return arguments[0].click();",i.element)}void 0!==t&&await sleep(1e3*t.wait)}catch(e){throw log.error(`Error during click.\nError ${e.stack}`),e}return R=[],!0}async function o(e){i({action:"write",data:e});try{const t=await N.find(R,"write");if("input"===t.tagName)await t.element.sendKeys(e);else{const i=await t.element.getAttribute("textContent");await t.element.click();for(let e=0;e<i.length;e++)await(await q.actions()).sendKeys(Key.RIGHT).perform();await(await q.actions()).sendKeys(e).perform(),await sleep(2e3)}}catch(e){throw log.error(`Error while entering data.\nError ${e.stack}`),e}return R=[],!0}async function c(){i({action:"clear"});try{const e=await N.find(R,"write");if("input"===e.tagName)await e.element.clear();else{const t=await e.element.getAttribute("textContent");await e.element.click();for(let e=0;e<t.length;e++)await(await q.actions()).sendKeys(Key.RIGHT).perform();await(await q.actions()).keyDown(Key.SHIFT).perform();for(let e=0;e<t.length;e++)await(await q.actions()).sendKeys(Key.LEFT).perform();await(await q.actions()).keyUp(Key.SHIFT).sendKeys(Key.BACK_SPACE).perform(),await(await q.actions()).sendKeys(Key.BACK_SPACE).perform(),await sleep(2e3)}}catch(e){throw log.error(`Error while clearing field.\nError ${e.stack}`),e}return R=[],!0}async function s(e){i({action:"overwrite",data:e});try{const t=await N.find(R,"write");if(["input","textarea"].includes(t.tagName))await t.element.clear(),await t.element.sendKeys(e);else{const i=await t.element.getAttribute("textContent");await t.element.click();for(let e=0;e<i.length;e++)await(await q.actions()).sendKeys(Key.RIGHT).perform();await(await q.actions()).keyDown(Key.SHIFT).perform();for(let e=0;e<i.length;e++)await(await q.actions()).sendKeys(Key.LEFT).perform();await(await q.actions()).keyUp(Key.SHIFT).sendKeys(e).perform(),await sleep(2e3)}}catch(e){throw log.error(`Error while overwriting text in field.\nError ${e.stack}`),e}return R=[],!0}async function l(e){i({action:"select",data:e});try{const t=await N.find(R,"select");if("select"!==t.tagName)throw new ReferenceError("Element is not of type select");await t.element.findElement(By.xpath(`.//option[.="${e}"]`)).click()}catch(e){throw log.error(`Error while selecting value in dropdown.\nError ${e.stack}`),e}return R=[],!0}async function u(e){try{const t=await N.find(R,"check"),i=await t.element.isSelected();("check"===e&&!i||"uncheck"===e&&i)&&await t.element.click()}catch(e){throw log.error(`Error during checkbox set.\nError ${e.stack}`),e}return R=[],!0}async function w(){return i({action:"check"}),u("check")}async function f(){return i({action:"uncheck"}),u("uncheck")}function h(){return R.push({exact:!0}),this}function p(e){const t=R.pop();return JSON.stringify(t)===JSON.stringify({exact:!0})?R.push({type:"element",id:e,exact:!0,matches:[],index:!1}):(void 0!==t&&R.push(t),R.push({type:"element",id:e,exact:!1,matches:[],index:!1})),this}function m(e){if("string"!=typeof e)throw new TypeError(`Expected parameter for row is string. Received ${typeof e} instead`);const t=R.pop();return JSON.stringify(t)===JSON.stringify({exact:!0})?R.push({type:"row",id:e,exact:!0,matches:[],index:!1}):(void 0!==t&&R.push(t),R.push({type:"row",id:e,exact:!1,matches:[],index:!1})),this}function d(e){if("string"!=typeof e)throw new TypeError(`Expected parameter for column is string. Received ${typeof e} instead`);const t=R.pop();return JSON.stringify(t)===JSON.stringify({exact:!0})?R.push({type:"column",id:e,exact:!0,matches:[],index:!1}):(void 0!==t&&R.push(t),R.push({type:"column",id:e,exact:!1,matches:[],index:!1})),this}function y(){return R.push({type:"location",located:"above"}),this}function g(){return R.push({type:"location",located:"below"}),this}function k(){return R.push({type:"location",located:"near"}),this}function x(){return R.push({type:"location",located:"toLeftOf"}),this}function b(){return R.push({type:"location",located:"toRightOf"}),this}function v(){return R.push({type:"location",located:"within"}),this}function E(e){if("number"!=typeof e)throw new TypeError(`Expected parameter for atIndex is number. Received ${typeof e} instead`);const t=R.pop();return void 0!==t&&(t.index=e,R.push(t)),this}async function K(t,i){let n;const{implicit:r}=await e.manage().getTimeouts();"number"==typeof i&&await e.manage().setTimeouts({implicit:1e3*i});try{await e.wait(async function(){return n=await N.find(R),![void 0,null,""].includes(n)}())}catch(e){if("fail"===t)throw e}return await e.manage().setTimeouts({implicit:r}),R=[],![void 0,null,""].includes(n)}async function S(e){return i({action:"isVisible"}),K("nofail",e)}async function T(e){return i({action:"waitVisibility"}),K("fail",e)}async function $(t){let n=!1;if(!t){let e;try{e=await N.find(R)}catch(e){log.error(e.stack)}[void 0,null,""].includes(e)||(i({action:"screenshot"}),n=await e.element.takeScreenshot(!0))}n||(log.info("Capturing screenshot of page"),n=await e.takeScreenshot()),R=[];try{return(await imagemin.buffer(Buffer.from(n,"base64"),{plugins:[pngquant({quality:[.1,.4]})]})).toString("base64")}catch(e){return log.error(e.stack),!1}}async function C(e){const t=await $();return O.perform(e,t)}const q=new Browser(e,t),N=new WebElement(e),O=new Visual;let R=[];return{hover:n,click:a,focus:r,write:o,clear:c,overwrite:s,select:l,check:w,uncheck:f,exact:h,element:p,row:m,column:d,above:y,below:g,near:k,toLeftOf:x,toRightOf:b,within:v,atIndex:E,isVisible:S,waitForVisibility:T,screenshot:$,visual:C,newWindow:q.newWindow,close:q.close,newTab:q.newTab,closeTab:q.closeTab,switchTab:q.switchTab,title:q.title,currentURL:q.currentURL,maximize:q.maximize,minimize:q.minimize,fullscreen:q.fullscreen,setSize:q.setSize,getSize:q.getSize,goto:q.goto,refresh:q.refresh,goBack:q.goBack,goForward:q.goForward,reset:q.reset,getDriver:q.getDriver,actions:q.actions}}const{log:log}=require("@nodebug/logger"),imagemin=require("imagemin"),pngquant=require("imagemin-pngquant"),{By:By,Key:Key}=require("selenium-webdriver"),Browser=require("./app/browser.js"),WebElement=require("./app/elements.js"),Visual=require("./app/visual.js");module.exports=Driver; |
{ | ||
"name": "@nodebug/selenium", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Node Bug", |
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
79888