自动化测试工具癖赏味不足

Layout测试

2016-11-28  本文已影响322人  Yuan_Jie

Web页面Layout测试,一直是测试人员比较头疼的事情。原因有

如何使用高效的方式来测试Web Layout是否能正常,下面来看下Galen是如何帮助我们的

Galen的特点

@objects
    comments            #comments
    article-content     div.article

= Main section =
    @on mobile, tablet
        comments:
            width 300px
            inside screen 10 to 30px top right
            near article-content > 10px right

    @on desktop
        comments:
            width ~ 100% of screen/width
            below article-content > 20px

使用

安装

sudo npm install -g galenframework-cli
➜  Downloads galen -v
Galen Framework
Version: 2.3.2
JavaScript executor: Rhino 1.7 release 5 2015 01 29

第一个测试项目

@objects
    header              id      header

= Main section =
    header:
        height 100px
galen check home-page.gspec
     --url http://samples.galenframework.com/tutorial1/tutorial1.html
     --size 640x480  
     --htmlreport .
➜  galenDemo galen check home-page.gspec --url http://samples.galenframework.com/tutorial1/tutorial1.html --size 640x480 --htmlreport .
========================================
Test: home-page.gspec
========================================
Starting ChromeDriver 2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1) on port 7505
Only local connections are allowed.
Nov 28, 2016 3:15:04 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Nov 28, 2016 3:15:05 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
check  home-page.gspec --url http://samples.galenframework.com/tutorial1/tutorial1.html --size 640x480 --htmlreport . -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/galenframework-cli/node_modules/chromedriver/lib/chromedriver/chromedriver
= Main section =
    header:
        height 100px


========================================
----------------------------------------
========================================
Suite status: PASS
Total tests: 1
Total failed tests: 0
Total failures: 0
测试报告

至此,使用Galen进行单个页面布局的测试就已经结束了。下面再进行一次测试修改元素高度

@objects
    header        id    header
= Main section =
    header:
        height 40px

- 再次执行测试,查看测试结果

➜  galenDemo galen check home-page.gspec --url http://samples.galenframework.com/tutorial1/tutorial1.html --size 640x480 --htmlreport .
========================================
Test: home-page.gspec
========================================
Starting ChromeDriver 2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1) on port 9809
Only local connections are allowed.
Nov 28, 2016 3:24:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Nov 28, 2016 3:24:12 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
check  home-page.gspec --url http://samples.galenframework.com/tutorial1/tutorial1.html --size 640x480 --htmlreport . -Dwebdriver.chrome.driver=/usr/local/lib/node_modules/galenframework-cli/node_modules/chromedriver/lib/chromedriver/chromedriver
= Main section =
    header:
->      height 40px
->      :   "header" height is 100px instead of 40px


========================================
----------------------------------------
========================================
Failed tests:
    home-page.gspec

Suite status: FAIL
Total tests: 1
Total failed tests: 1
Total failures: 1
There were failures in galen tests

到目前为止,我们可以发现,使用Galen进行页面布局测试会很方便和快速,且错误信息显示足够详细

总结

参考

上一篇 下一篇

猜你喜欢

热点阅读