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

Commit

Permalink
Merge 673e09f into b4e1af2
Browse files Browse the repository at this point in the history
  • Loading branch information
wswebcreation committed Jun 30, 2019
2 parents b4e1af2 + 673e09f commit 4ed10a1
Show file tree
Hide file tree
Showing 6 changed files with 1,577 additions and 2,340 deletions.
6 changes: 3 additions & 3 deletions lib/commands/saveFullPageScreen.ts
Expand Up @@ -28,9 +28,9 @@ export default async function saveFullPageScreen(
const disableCSSAnimation: boolean = 'disableCSSAnimation' in saveFullPageOptions.method
? saveFullPageOptions.method.disableCSSAnimation
: saveFullPageOptions.wic.disableCSSAnimation;
// default this one to false, this will be handled in
// taking the screenshots
const hideScrollBars: boolean = false;
const hideScrollBars: boolean = 'hideScrollBars' in saveFullPageOptions.method
? saveFullPageOptions.method.hideScrollBars
: saveFullPageOptions.wic.hideScrollBars;
const fullPageScrollTimeout: number = 'fullPageScrollTimeout' in saveFullPageOptions.method
? saveFullPageOptions.method.fullPageScrollTimeout
: saveFullPageOptions.wic.fullPageScrollTimeout;
Expand Down
42 changes: 21 additions & 21 deletions lib/methods/__snapshots__/screenshots.spec.ts.snap

Large diffs are not rendered by default.

92 changes: 41 additions & 51 deletions lib/methods/screenshots.spec.ts
Expand Up @@ -36,7 +36,11 @@ describe('screenshots', () => {
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({});

expect(await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options)).toMatchSnapshot();
// Replace the screenshot with a `mocked-screenshot-string`;
const result = await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
result.data.forEach(dataObject => dataObject.screenshot = 'mocked-screenshot-string');

expect(result).toMatchSnapshot();
});

it('should get hide elements for the Android nativeWebScreenshot fullpage screenshot', async () => {
Expand Down Expand Up @@ -78,7 +82,11 @@ describe('screenshots', () => {
// getFullPageScreenshotsDataNativeMobile: For await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
.mockResolvedValueOnce({});

expect(await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options)).toMatchSnapshot();
// Replace the screenshot with a `mocked-screenshot-string`;
const result = await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
result.data.forEach(dataObject => dataObject.screenshot = 'mocked-screenshot-string');

expect(result).toMatchSnapshot();
});

it('should get the Android ChromeDriver fullpage screenshot data', async () => {
Expand Down Expand Up @@ -114,8 +122,11 @@ describe('screenshots', () => {
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({});

// await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
expect(await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options)).toMatchSnapshot();
// Replace the screenshot with a `mocked-screenshot-string`;
const result = await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
result.data.forEach(dataObject => dataObject.screenshot = 'mocked-screenshot-string');

expect(result).toMatchSnapshot();
});

it('should hide elements for the Android ChromeDriver fullpage screenshot', async () => {
Expand Down Expand Up @@ -155,8 +166,11 @@ describe('screenshots', () => {
// getFullPageScreenshotsDataNativeMobile: For await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
.mockResolvedValueOnce({});

// await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
expect(await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options)).toMatchSnapshot();
// Replace the screenshot with a `mocked-screenshot-string`;
const result = await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
result.data.forEach(dataObject => dataObject.screenshot = 'mocked-screenshot-string');

expect(result).toMatchSnapshot();
});

it('should get the iOS fullpage screenshot data', async () => {
Expand Down Expand Up @@ -193,7 +207,11 @@ describe('screenshots', () => {
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({});

expect(await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options)).toMatchSnapshot();
// Replace the screenshot with a `mocked-screenshot-string`;
const result = await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
result.data.forEach(dataObject => dataObject.screenshot = 'mocked-screenshot-string');

expect(result).toMatchSnapshot();
});

it('should hide elements for the iOS fullpage screenshot', async () => {
Expand Down Expand Up @@ -234,7 +252,11 @@ describe('screenshots', () => {
// getFullPageScreenshotsDataNativeMobile: For await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
.mockResolvedValueOnce({});

expect(await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options)).toMatchSnapshot();
// Replace the screenshot with a `mocked-screenshot-string`;
const result = await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
result.data.forEach(dataObject => dataObject.screenshot = 'mocked-screenshot-string');

expect(result).toMatchSnapshot();
});

it('should get the desktop browser fullpage screenshot data', async () => {
Expand All @@ -253,51 +275,35 @@ describe('screenshots', () => {
const MOCKED_EXECUTOR = jest.fn()
// THIS NEEDS TO BE FIXED IN THE FUTURE
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// RUN 2
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// RUN 3
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// RUN 4
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// RUN 5
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({});
.mockResolvedValueOnce(3200);

// Replace the screenshot with a `mocked-screenshot-string`;
const result = await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
result.data.forEach(dataObject => dataObject.screenshot = 'mocked-screenshot-string');

expect(await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options)).toMatchSnapshot();
expect(result).toMatchSnapshot();
});

it('should hide elements for the desktop browser fullpage screenshot', async () => {
Expand All @@ -316,55 +322,39 @@ describe('screenshots', () => {
const MOCKED_EXECUTOR = jest.fn()
// THIS NEEDS TO BE FIXED IN THE FUTURE
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// RUN 2
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// RUN 3
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// RUN 4
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// RUN 5
// getFullPageScreenshotsDataNativeMobile: For await executor(scrollToPosition, scrollY)
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, true);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(getDocumentScrollHeight)
.mockResolvedValueOnce(3200)
// getFullPageScreenshotsDataNativeMobile: For await executor(hideScrollBars, false);
.mockResolvedValueOnce({})
// getFullPageScreenshotsDataNativeMobile: For await executor(hideRemoveElements, {hide: hideAfterFirstScroll, remove: []}, false);
.mockResolvedValueOnce({});

expect(await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options)).toMatchSnapshot();
// Replace the screenshot with a `mocked-screenshot-string`;
const result = await getBase64FullPageScreenshotsData(MOCKED_TAKESCREENSHOT, MOCKED_EXECUTOR, options);
result.data.forEach(dataObject => dataObject.screenshot = 'mocked-screenshot-string');

expect(result).toMatchSnapshot();
});
});
});
6 changes: 0 additions & 6 deletions lib/methods/screenshots.ts
Expand Up @@ -265,9 +265,6 @@ export async function getFullPageScreenshotsDataDesktop(
const scrollY = innerHeight * i;
await executor(scrollToPosition, scrollY);

// Hide scrollbars before taking a screenshot, we don't want them, on the screenshot
await executor(hideScrollBars, true);

// Simply wait the amount of time specified for lazy-loading
await waitFor(fullPageScrollTimeout);

Expand Down Expand Up @@ -307,9 +304,6 @@ export async function getFullPageScreenshotsDataDesktop(
}, devicePixelRatio),
screenshot,
});

// Show scrollbars again
await executor(hideScrollBars, false);
}

// Put back the hidden elements to visible
Expand Down

0 comments on commit 4ed10a1

Please sign in to comment.