简体   繁体   English

如何在CSS回归测试backstop.js中检查引导方式

[英]how to check bootstrap modal in CSS Regression Testing backstopjs

I'm trying to simulate the clicking of CSS elements on my page and automatically take screenshots of the window at each stage for testing purposes. 我正在尝试模拟页面上CSS元素的单击,并在每个阶段自动拍摄窗口的屏幕截图以进行测试。 I'm using backstopJS as the CSS testing/screenshot framework. 我正在使用backstopJS作为CSS测试/屏幕截图框架。 Everything seems to work fine for this first element. 对于第一个元素,一切似乎都工作正常。 A modal is triggered when i click on the register link in the main header menu. 当我单击主标题菜单中的注册链接时,将触发模式。 but it is not generating any reference screenshotof the modal. 但它不会生成该模式的任何参考屏幕截图。

plz help to trigger a reference screenshot of the modal in the below given script 请在以下给定脚本中帮助触发模态的参考屏幕截图

This is the script : 这是脚本:

{
  "viewports": [
    {
      "name": "desktop",
      "width": 1600,
      "height": 900
    },
    {
      "name": "phone",
      "width": 320,
      "height": 480
    },
    {
      "name": "tablet_v",
      "width": 568,
      "height": 1024
    },
    {
      "name": "tablet_h",
      "width": 1024,
      "height": 768
    }
  ],
  "grabConfigs" : [
    {
      "testName":"vawizard"
      ,"url":"http://localhost/vawizard/index.html"
      ,"hideSelectors": [

      ]

      ,"removeSelectors": [
        "header.banner--clone"
      ]
      ,"selectors":[
        "#outer_wrapper header"
        ,".banner_box"
        ,".help_desk"
        ,".big_search_box"
        ,".look_specific"
        ,".smart_tool_box"
        ,"footer"
        ,".copyright_box"
      ]
    }
  ]
}

This is the link http://wizard.hodgesdigital.com/ 这是链接http://wizard.hodgesdigital.com/

Any ideas what could be causing this behavior? 任何想法可能导致此行为?

BackstopJS is mainly focused on testing layout states at different screen sizes and doesn't support the testing of user interactions. BackstopJS主要专注于测试不同屏幕尺寸的布局状态 ,不支持测试用户交互。

In your case I can make two recommendations. 对于您的情况,我可以提出两项建议。 1) You could add a state to your URL which triggers the modal when your page is loaded OR 2) you could write a custom CasperJS script to test cases like this which require some user interaction. 1)您可以在网址中添加一个状态,以在加载页面时触发模式;或2)您可以编写自定义的CasperJS脚本来测试类似这种需要一些用户交互的情况。 More detail below... 下面有更多详细信息...

Approach 1: In the first case you could add a hash to your URL which would trigger your modal, In my experience it's common for web apps (eg Angular and Ember) to represent modal states in this way.... 方法1:在第一种情况下,您可以在网址中添加哈希值,从而触发模态。以我的经验,Web应用程序(例如Angular和Ember)以这种方式表示模态状态是很常见的...

// in your BackstopJS config
"url": "http://localhost/vawizard/index.html#openModal",


// then as part of a jQuery script
$(document).ready(function(){
  if ( /openModal/.test(location.hash) )
    {
      // Do your open modal action here
      // Then trigger BackstopJS
    }
});

Approach 2: If the above is not your style there is another good option. 方法2:如果以上不是您的风格,则还有另一个不错的选择。 As part of the BackstopJS install you also have a full version of CasperJS -- so I would recommend going to CasperJS.org to look at some basic examples and see if it makes sense to write your own scripts. 作为BackstopJS安装的一部分,您还具有完整版本的CasperJS-因此,我建议您去CasperJS.org查看一些基本示例,看看编写自己的脚本是否有意义。 It will be a little more time consuming in the short run but the project specific boilerplate you write now may be nice to have for future edge cases (for testing forms, other interactions etc.). 在短期内这将花费更多的时间,但是您现在编写的特定于项目的样板对于将来的边缘情况(用于测试表单,其他交互等)可能会很好。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM