网站layout的automation
来源:互联网 发布:数据新闻传播方向 编辑:程序博客网 时间:2024/04/29 05:34
研究这个问题的原因,是因为在我们site上,有很多的google ads,对于每个ads的显示位置有严格的requirement。为此,我也吃了几个priority比较高的ticket。
GALEN(http://galenframework.com/)就是这样一个framework,不得不说还是很好用的,也很方便。
首先在pom文件中加入galen dependency
<dependency> <groupId>net.mindengine</groupId> <artifactId>galen</artifactId> <version>1.4.9</version> </dependency>
然后定义element的位置: SRP.spec
@@ import Header.spec============================================================================================srp-skyscraper-banner xpath //iframe[@id='google_ads_iframe_/7917/srp_0']srp-bottom-banner1 xpath //iframe[@id='google_ads_iframe_/7917/srp_2']# srp-bottom-banner2 xpath //iframe[@id='google_ads_iframe_/7917/srp_3']srp-featured-ads xpath //h3[contains(text(), 'Featured Ads')]srp-refine-search xpath //div[@id='refine-search']//div[@class='module-content']srp-paging-bar xpath //div[@class='rs-paginator c-margin-vertical1']srp-user-activity xpath //div[@id='user-activity']============================================================================================== @ desktop, tablet-lsrp-skyscraper-banner width: 160 px height: 600 px below: srp-featured-ads 20 to 130 px inside: srp-refine-search 20 to 30 px right@ desktop, tablet-l, tablet-psrp-bottom-banner1 width: 728 px height: 90 px below: srp-paging-bar 10 to 20 px above: srp-user-activity 20 to 30 px# @ ^# srp-bottom-banner2# width: 728 px# height: 90 px# below: srp-user-activity 20 to 30 px @ mobilesrp-bottom-banner1 width: 320 px height: 50 px below: srp-paging-bar 10 to 20 px above: srp-user-activity 20 to 30 px#@ ^#srp-bottom-banner2# width: 320 px# height: 50 px# below: srp-user-activity 20 to 30 px
最后code:
@Then("I should see the banners on '$page' rendered on '$device' '$orientation' orientation")public void checkBannersOnHpOnTabletOrMobile(@Named("$page") String page, @Named("$device") String device,@Named("$orientation") String orientation) throws Exception{Dimension dimension = DeviceSizes.getDeviceDimension(device, orientation);WebDriver driver = getWebDriver(page, dimension);String tag = DeviceSizes.getTag(device, orientation);LayoutReport layoutReport = Galen.checkLayout(driver, "src/main/resources/spec/" + page + ".spec", Arrays.asList(tag), null, null, null);// Creating a list of tests List<GalenTestInfo> tests = new LinkedList<GalenTestInfo>(); // Creating an object that will contain the information about the test GalenTestInfo test = GalenTestInfo.fromString(device + "_" + orientation); // Adding layout report to the test report test.getReport().layout(layoutReport, "check layout on " + device + " " + orientation +" orientation"); tests.add(test); // Exporting all test reports to html new HtmlReportBuilder().build(tests, "target/galen-html-reports"); if (layoutReport.errors() > 0) { StringBuffer sb = new StringBuffer(); List<ValidationError> errorList = layoutReport.getValidationErrors(); Iterator<ValidationError> errorListIt = errorList.iterator(); while(errorListIt.hasNext()){ ValidationError error = errorListIt.next(); sb.append(error.toString()); } Assertion.assertTrue(false, sb.toString()); }}
这个framework还有很多其他的强大之处,有兴趣的同学可以自己去研究研究。
0 0
- 网站layout的automation
- automation
- automation
- automation
- 一种基于浏览器内核修改的复杂网站layout/渲染bug的HTTP重放调试系统
- "Automation 服务器不能创建对象" 的解决方法
- "Automation 服务器不能创建对象" 的解决方案
- "Automation 服务器不能创建对象" 的解决方案
- Automation 服务器不能创建对象" 的解决方案
- "Automation 服务器不能创建对象"的解决方法
- automation服务器不能创建对象的问题
- automation服务器不能创建对象的问题
- automation 服务器不能创建对象的解决方法
- "Automation 服务器不能创建对象" 的解决方案
- Outlook的Automation对象编程方法
- automation服务器不能创建对象的问题
- 一个基于MFC的自动化(Automation)实例
- NI Measurement & Automation的小BUG
- [LeetCode] Remove Duplicates from Sorted List II
- 数据结构之栈和队列---栈的基本操作
- 1048:The Hardest Problem Ever
- 关于setTimeout延迟时间为0
- 【网络流】 HDOJ 3879 Base Station
- 网站layout的automation
- android中import出错,且该包切实存在的时候
- 多光谱光子型山火智能预警监测系统宣传资料
- UVA10976-Fractions Again?!
- hdu1312 red and black 【递归】
- Ubuntu 12.04右键在当前位置打开终端
- C++与类型转换相关的4个关键字
- hdu1312 Red and Black(入门dfs)
- CSS3动画实现loading加载图标