【问题标题】:BackstopJS: Not able to scroll the page to end using scrollToSelectorBackstopJS:无法使用 scrollToSelector 滚动页面以结束
【发布时间】:2021-04-19 12:16:27
【问题描述】:

我正在使用两个文件,一个用于保存所有 URL 和其他变量,另一个用于保存场景配置

const projectId = "test"; // 

let baseUrl = "someurl"; // 
let scrollToSelector = "";
let removeSelector = "";

// Replace the values of the below array with the relative URLs of your website. E.g., "/about", "/contact", "/pricing", etc.
// Use just "/" to test the homepage of your website.
// Add as many relative URLs as you need.
const relativeUrls =[
  "/about",
  "/documentation",
  "/case-studies/",
  "/solutions/",
  "/blog/"
];

relativeUrls.map(relativeUrl => {
  if (relativeUrl === "/about") {
    scrollToSelector = "a.wp-block-button__link";
  removeSelector = ".is-style-image-banner"
   console.log(scrollToSelector);
  }
});


// Leave the below array as is if you want to test your website using the viewports listed below.
// The suported viewports are: phone (320px X 480px), tablet (1024px X 768px), and desktop (1280px X 1024px).
// No other viewports are supported.
// You can remove the viewports that you don't need, but at least one of them is required.
const viewports = [
  "phone",
  "tablet",
  "desktop",
];

module.exports = {
  baseUrl,
  projectId,
  relativeUrls,
  viewports,
  scrollToSelector,
  removeSelector
};

ma​​inConfig.js

const THREE_SECONDS_IN_MS = 3000;
const scenarios = [];
const viewports = [];

basicConfig.relativeUrls.map(relativeUrl => {
  scenarios.push({
    label: relativeUrl,
    url: `${basicConfig.baseUrl}${relativeUrl}`,
    delay: THREE_SECONDS_IN_MS,
    requireSameDimensions: false,
    scrollToSelector: basicConfig.scrollToSelector,
    removeSelectors: [basicConfig.removeSelector]
    // onReadyScript:  "onReadyScript.js",
    // readyEvent: "page_loaded"
  });
});

basicConfig.viewports.map(viewport => {
  if (viewport === "phone") {
    pushViewport(viewport, 320, 480);
  }
  if (viewport === "tablet") {
    pushViewport(viewport, 1024, 768);
  }
  if (viewport === "desktop") {
    pushViewport(viewport, 1280, 1024);
  }
});

function pushViewport(viewport, width, height) {
  viewports.push({
    name: viewport,
    width,
    height,
  });
}

module.exports = {
  id: basicConfig.projectId,
  viewports,
  scenarios,
  paths: {
    bitmaps_reference: "test/backstop_data/bitmaps_reference",
    bitmaps_test: "test/backstop_data/bitmaps_test",
    html_report: "test/backstop_data/html_report"
  },
  report: ["CI"],
  engine: "puppeteer",
  engineOptions: {
    args: ["--no-sandbox"]
  },
  asyncCaptureLimit: 5,
  asyncCompareLimit: 50,
};

scrollToSelector 似乎不起作用。有没有其他方式应该声明和调用它。

【问题讨论】:

    标签: automation ui-automation backstop.js


    【解决方案1】:

    你的scrollToSelector需要在矩形括号[]中,就像scrollToSelector: ['.a.wp-block-button__link']一样

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-25
      • 1970-01-01
      • 1970-01-01
      • 2020-02-05
      • 2020-09-12
      • 1970-01-01
      • 2017-09-03
      • 1970-01-01
      相关资源
      最近更新 更多