Skip to content
This repository has been archived by the owner on Dec 24, 2023. It is now read-only.

Fix/fix multiple issues #63

Merged
merged 3 commits into from
Apr 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dist: trusty
language: node_js

node_js:
- "8"
- "10"
- "12"

Expand Down
2 changes: 1 addition & 1 deletion lib/clientSideScripts/drawTabbableOnCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default function drawTabbableOnCanvas(drawOptions: TabbableOptions) {
*/
function isNodeMatchingSelectorFocusable(node: HTMLElement): boolean {
return !(
(node.hasAttribute('disabled') && node.getAttribute('disabled'))
(node.hasAttribute('disabled') || node.getAttribute('disabled'))
|| isHiddenInput(node)
|| isHidden(node)
);
Expand Down
15 changes: 14 additions & 1 deletion lib/helpers/afterScreenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {join} from 'path';
import {Executor} from '../methods/methods.interface';
import {AfterScreenshotOptions, ScreenshotOutput} from './afterScreenshot.interfaces';
import hideRemoveElements from '../clientSideScripts/hideRemoveElements';
import {yellow} from "chalk";

/**
* Methods that need to be executed after a screenshot has been taken
Expand Down Expand Up @@ -43,7 +44,19 @@ export default async function afterScreenshot(executor: Executor, options: After
// Show elements again
/* istanbul ignore else */
if (hideElements.length > 0 || removeElements.length > 0) {
await executor(hideRemoveElements, {hide: hideElements, remove: removeElements}, false);
try {
await executor(hideRemoveElements, {hide: hideElements, remove: removeElements}, false);
} catch (e) {
console.log(yellow(`
#####################################################################################
WARNING:
(One of) the elements that needed to be hidden or removed could not be found on the
page and caused this error
Error: ${e}
We made sure the test didn't break.
#####################################################################################
`));
}
}

// Remove the custom set css
Expand Down
15 changes: 14 additions & 1 deletion lib/helpers/beforeScreenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import getEnrichedInstanceData from '../methods/instanceData';
import {BeforeScreenshotOptions, BeforeScreenshotResult} from './beforeScreenshot.interface';
import {Executor} from '../methods/methods.interface';
import hideRemoveElements from '../clientSideScripts/hideRemoveElements';
import {yellow} from "chalk";

/**
* Methods that need to be executed before a screenshot will be taken
Expand Down Expand Up @@ -41,7 +42,19 @@ export default async function beforeScreenshot(

// Hide and or Remove elements
if (hideElements.length > 0 || removeElements.length > 0) {
await executor(hideRemoveElements, {hide: hideElements, remove: removeElements}, true);
try {
await executor(hideRemoveElements, {hide: hideElements, remove: removeElements}, true);
} catch (e) {
console.log(yellow(`
#####################################################################################
WARNING:
(One of) the elements that needed to be hidden or removed could not be found on the
page and caused this error
Error: ${e}
We made sure the test didn't break.
#####################################################################################
`));
}
}

// Set some custom css
Expand Down
86 changes: 80 additions & 6 deletions lib/methods/screenshots.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @ts-ignore
import {yellow} from 'chalk';
import scrollToPosition from '../clientSideScripts/scrollToPosition';
import getDocumentScrollHeight from '../clientSideScripts/getDocumentScrollHeight';
import getAndroidStatusAddressToolBarHeight from '../clientSideScripts/getAndroidStatusAddressToolBarHeight';
Expand Down Expand Up @@ -116,7 +118,19 @@ export async function getFullPageScreenshotsDataNativeMobile(

// Elements that need to be hidden after the first scroll for a fullpage scroll
if (i === 1 && hideAfterFirstScroll.length > 0) {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, true);
try {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, true);
} catch (e) {
console.log(yellow(`
#####################################################################################
WARNING:
(One of) the elements that needed to be hidden or removed could not be found on the
page and caused this error
Error: ${e}
We made sure the test didn't break.
#####################################################################################
`));
}
}

// Take the screenshot and get the width
Expand Down Expand Up @@ -155,7 +169,19 @@ export async function getFullPageScreenshotsDataNativeMobile(

// Put back the hidden elements to visible
if (hideAfterFirstScroll.length > 0) {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
try {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
} catch (e) {
console.log(yellow(`
#####################################################################################
WARNING:
(One of) the elements that needed to be hidden or removed could not be found on the
page and caused this error
Error: ${e}
We made sure the test didn't break.
#####################################################################################
`));
}
}

return {
Expand Down Expand Up @@ -196,7 +222,19 @@ export async function getFullPageScreenshotsDataAndroidChromeDriver(

// Elements that need to be hidden after the first scroll for a fullpage scroll
if (i === 1 && hideAfterFirstScroll.length > 0) {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, true);
try {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, true);
} catch (e) {
console.log(yellow(`
#####################################################################################
WARNING:
(One of) the elements that needed to be hidden or removed could not be found on the
page and caused this error
Error: ${e}
We made sure the test didn't break.
#####################################################################################
`));
}
}

// Take the screenshot
Expand Down Expand Up @@ -233,7 +271,19 @@ export async function getFullPageScreenshotsDataAndroidChromeDriver(

// Put back the hidden elements to visible
if (hideAfterFirstScroll.length > 0) {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
try {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
} catch (e) {
console.log(yellow(`
#####################################################################################
WARNING:
(One of) the elements that needed to be hidden or removed could not be found on the
page and caused this error
Error: ${e}
We made sure the test didn't break.
#####################################################################################
`));
}
}

return {
Expand Down Expand Up @@ -272,7 +322,19 @@ export async function getFullPageScreenshotsDataDesktop(

// Elements that need to be hidden after the first scroll for a fullpage scroll
if (i === 1 && hideAfterFirstScroll.length > 0) {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, true);
try {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, true);
} catch (e) {
console.log(yellow(`
#####################################################################################
WARNING:
(One of) the elements that needed to be hidden or removed could not be found on the
page and caused this error
Error: ${e}
We made sure the test didn't break.
#####################################################################################
`));
}
}

// Take the screenshot
Expand Down Expand Up @@ -320,7 +382,19 @@ export async function getFullPageScreenshotsDataDesktop(

// Put back the hidden elements to visible
if (hideAfterFirstScroll.length > 0) {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
try {
await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
} catch (e) {
console.log(yellow(`
#####################################################################################
WARNING:
(One of) the elements that needed to be hidden or removed could not be found on the
page and caused this error
Error: ${e}
We made sure the test didn't break.
#####################################################################################
`));
}
}

return {
Expand Down