简体   繁体   English

BackstopJS:无法滚动页面以使用 scrollToSelector 结束

[英]BackstopJS: Not able to scroll the page to end using scrollToSelector

I am using two files one to keep all the URLs and other variables and other to keep the scenario config我使用两个文件,一个保存所有 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
};

mainConfig.js mainConfig.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 doesn't seem to be working. scrollToSelector似乎不起作用。 Is there any other way it should declared and called.是否有任何其他方式应该声明和调用。

Your scrollToSelector need to be in the rectangular parentesis [] , like that scrollToSelector: ['.a.wp-block-button__link']您的scrollToSelector需要位于矩形括号[]中,就像scrollToSelector: ['.a.wp-block-button__link']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我无法在用于移动自动化的机器人框架上使用“向下滚动”关键字,因为该元素位于页面末尾 - I am not able down to use 'Scroll Down' keyword on robot framework for mobile automation, as the element is located at end of the page 使用vbscript自动化页面滚动 - automate page scroll using vbscript Appium无法在iOS 8.4上滚动 - Appium not able to scroll on iOS 8.4 我如何使用机器人框架滚动列表视图的末尾? - How do i need to scroll end of the listview using robot framework? Appium无法识别和滚动Android设备上的元素 - Appium not able to identify and scroll element on android device 在InDesign中控制段落在页面的开始和结束位置 - Controlling where paragraphs start and end on a page, in InDesign 如何在vbscript中滚动Internet浏览器网页而不使用sendkey - how to scroll internet browser web page without sendkeys in vbscript 尝试使用 JAVA 读取 Scroll Lock 状态 - Trying to read Scroll Lock status using JAVA 无法使用Selenium在文本框中插入文本(使用Firefox) - Not able to insert text in textbox using Selenium (using firefox) 我无法使用XPATH找到与子元素完全匹配的对象 - I am not able to find an exact match for child elements using XPATH
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM