Skip to content

Commit

Permalink
Change env variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmay-browserstack committed Dec 16, 2024
1 parent 61b195c commit c048f3c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ENV_INFO = `${seleniumPkg.name}/${seleniumPkg.version}`;
const utils = require('@percy/sdk-utils');
const { DriverMetadata } = require('./driverMetadata');
const log = utils.logger('selenium-webdriver');
const CS_MAX_SCREENSHOT_LIMIT = 25000;

const getWidthsForMultiDOM = (userPassedWidths, eligibleWidths) => {
// Deep copy of eligible mobile widths
Expand Down Expand Up @@ -82,10 +83,10 @@ async function captureResponsiveDOM(driver, options) {
await new Promise(resolve => setTimeout(resolve, parseInt(process.env.RESPONSIVE_CAPTURE_SLEEP_TIME) * 1000));
}

if (process.env.PERCY_RESPONSIVE_CAPTURE_SCROLL_ENABLED) {
if (process.env.PERCY_ENABLE_LAZY_LOADING_SCROLL) {
let scrollSleep = 0.45;
if (process.env.PERCY_RESPONSIVE_CAPTURE_SCROLL_TIME) {
scrollSleep = parseFloat(process.env.PERCY_RESPONSIVE_CAPTURE_SCROLL_TIME);
if (process.env.PERCY_LAZY_LOAD_SCROLL_TIME) {
scrollSleep = parseFloat(process.env.PERCY_LAZY_LOAD_SCROLL_TIME);
}
await module.exports.slowScrollToBottom(driver, scrollSleep);
}
Expand Down Expand Up @@ -272,7 +273,7 @@ module.exports.slowScrollToBottom = async (driver, timeInSeconds = 0.45) => {

let page = 1;
// Break the loop if maximum scroll height 25000px is reached
while (scrollHeight > current && current < 25000) {
while (scrollHeight > current && current < CS_MAX_SCREENSHOT_LIMIT) {
current = clientHeight * page;
page += 1;
await driver.executeScript(`window.scrollTo(0, ${current})`);
Expand All @@ -284,8 +285,8 @@ module.exports.slowScrollToBottom = async (driver, timeInSeconds = 0.45) => {
// Get back to top
await driver.executeScript('window.scrollTo(0, 0)');
let sleepAfterScroll = 1;
if (process.env.PERCY_SLEEP_AFTER_SCROLL_DONE) {
sleepAfterScroll = parseFloat(process.env.PERCY_SLEEP_AFTER_SCROLL_DONE);
if (process.env.PERCY_SLEEP_AFTER_LAZY_LOAD_COMPLETE) {
sleepAfterScroll = parseFloat(process.env.PERCY_SLEEP_AFTER_LAZY_LOAD_COMPLETE);
}
await new Promise(resolve => setTimeout(resolve, sleepAfterScroll * 1000));
};

0 comments on commit c048f3c

Please sign in to comment.