Responsive测试

Responsive测试 如何使用Galen进行响应式测试 使用Javascript编写测试代码 完整代码:https://github.com/aimer1124/GalenDemo 安装Galen 通过NPM安装 sudo npm install -g galenframework-cli 检查安装版本galen -v ➜ GalenDemo git:(master) ✗ galen -v Galen Framework Version: 2.3.4 JavaScript executor: Rhino 1.7 release 5 2015 01 29 第一步 创建测试文件,存放于test/step1.test.js test("First test", function () { console.log('This is first test') }); 执行测试 ➜ GalenDemo git:(master) ✗ galen test test/*.js ======================================== Test: First test ======================================== This is first test ======================================== ---------------------------------------- ======================================== Suite status: PASS Total tests: 1 Total failed tests: 0 Total failures: 0 第二步 添加多个不同的设备,用于测试兼容性 this.devices = { mobile: { deviceName: "mobile", size: "400x700" }, tablet: { deviceName: "tablet", size: "600x800" }, desktop: { deviceName: "desktop", size: "1024x768" } }; forAll(devices, function (device) { test("Home page on ${deviceName}", function (device){ var driver = createDriver("http://galenframework.com", device.size, "chrome"); console.log(device.size) }); }); 查看测试结果 ➜ GalenDemo git:(master) ✗ galen test test/*.js ======================================== Test: Home page on mobile ======================================== Starting ChromeDriver 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b) on port 10344 Only local connections are allowed. Aug 01, 2017 2:34:11 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS 400x700 ======================================== Test: Home page on tablet ======================================== Starting ChromeDriver 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b) on port 6454 Only local connections are allowed. Aug 01, 2017 2:34:17 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS 600x800 ======================================== Test: Home page on desktop ======================================== Starting ChromeDriver 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b) on port 42862 Only local connections are allowed. Aug 01, 2017 2:34:23 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS 1024x768 ======================================== ---------------------------------------- ======================================== Suite status: PASS Total tests: 3 Total failed tests: 0 Total failures: 0 第三步 引入gspec文件,来难页面布局 新增specs/home-page.gspec @objects header id header = Main section = header: height 5 to 100px 在测试脚本step3.test.js中添加Layout检查 test("Home page on ${deviceName}", function (device){ var driver = createDriver("http://samples.galenframework.com/tutorial1/tutorial1.html", device.size, "chrome"); checkLayout(driver, "GalenDemo/home-page.gspec", [device.deviceName]); }); 添加关闭浏览器 driver.close(); 添加页面pageObject 新增pageObject this.home = $page("home", { content: "div#content" }); 测试中引用pageObject var homepage = new home(driver); if (!homepage.content.exists()){ console.log("Content element don't exist") } 第四步 不同分辨率下Layout测试及生成测试报告 不同分辨率测试 重新调整设备配制信息 function Device(deviceName, size, tags) { this.deviceName = deviceName; this.size = size; this.tags = tags; } this.devices = { mobile: new Device("mobile", "450x700", ["mobile"]), tablet: new Device("tablet", "600x800", ["tablet"]), desktop: new Device("desktop", "1024x768", ["desktop"]) }; 修改layout测试中的设备辨别和测试 @on * header: height 5 to 100px @on tablet content: width 600px @on desktop content: width 1024px 生成测试报告 ➜ GalenDemo git:(master) ✗ galen test test/step3.test.js --htmlreport ./report ======================================== Test: Home page on mobile ======================================== Starting ChromeDriver 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b) on port 36316 Only local connections are allowed. Aug 03, 2017 2:56:04 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS = Main section = header: height 5 to 100px ======================================== Test: Home page on tablet ======================================== Starting ChromeDriver 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b) on port 28325 Only local connections are allowed. Aug 03, 2017 2:56:07 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS = Main section = header: height 5 to 100px content: width 600px ======================================== Test: Home page on desktop ======================================== Starting ChromeDriver 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b) on port 12177 Only local connections are allowed. Aug 03, 2017 2:56:10 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS = Main section = header: height 5 to 100px content: width 1024px ======================================== ---------------------------------------- ======================================== Suite status: PASS Total tests: 3 Total failed tests: 0 Total failures: 0 从日志中可以查看到,每次在不同设备测试时layout代码已变更 Test: Home page on desktop ======================================== Starting ChromeDriver 2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b) on port 12177 Only local connections are allowed. Aug 03, 2017 2:56:10 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS = Main section = header: height 5 to 100px content: width 1024px ======================================== 参考 http://galenframework.com/ http://galenframework.com/docs/reference-javascript-tests-guide/

August 3, 2017 · 2 min · Yuanjie

什么是Locust

原文地址:http://docs.locust.io/en/latest/what-is-locust.html# 什么是Locust Locust是一个容易使用、分布式的压力测试工具。它是用于网站压力测试(或其它系统)并找出多少用户一个系统可以承载。 在测试过程中,策略就是一个Locust的蠕虫将会攻击你的网站。每一个locust的行为(或你使用的测试用户)是你自己定义的,并且蠕虫进程从一个网页视图中被实时监测。这样会帮助你来实现测试,在真实用户使用前定义系统的瓶颈。 Locust是完全基于事件的,因此可以在单台机器中支持数以千计的用户在线。和其它基于事件的程序相比较,它是不需要使用回调的。相反,它通过gevent使用轻量级的进程。每一个locust测试你的网站时,实际上是真实的在内部运行它自己的进程(或greenlet,准确的说)。这样就允许你不使用复杂的回调方法,而是使用Python编写复杂的场景。 ...

June 8, 2017 · 3 min · Yuanjie

分布式测试

分布式运行Locust 一旦单台机器不够模拟足够多的用户时,Locust支持运行在多台机器中进行压力测试。 为了实现这个,你应该在master模式中使用--master标记来启用一个Locust实例。这个实例将会运行你启动测试的Locust交互网站并查看实时统计数据。master节点的机器自身不会模拟任何用户。相反,你必须使用--slave标记启动一台到多台Locustslave机器节点,与标记--master-host一起使用(指出master机器的IP/hostname)。 常用的做法是在一台独立的机器中运行master,在slave机器中每个处理器内核运行一个slave实例。 ** !Note ** ** master和每一台slave机器,在运行分布式测试时都必须要有locust的测试文件。** ...

June 3, 2017 · 2 min · Yuanjie

编写一个Locust文件

Locust文件就是一般的Python文件。唯一的需求就是它至少需要一个继承于Locust的类. Locust类 Locust类代表一个用户(如果愿意,也可以是一个准备出动的蝗虫)。Locust会为每一个模拟用户生成一个locust类实例。同时会有一些locust类属性被定义。 task_set属性 task_set属性是指向一个定义用户行为的TaskSet类,下面会有详细的介绍。 min_wait和max_wait属性 除了task_set属性,另外一个经常被使用的就是min_wait和max_wait属性。是用于各自以毫秒为单位的最小值和最大值,一个模拟用户将会在每个任务执行时的等待执行的时间间隔。min_wait和max_wait默认设置为1000,如果不声明的话,Locust会默认在每个任务间等待1秒。 参考下面的代码,每个用户将会在每个任务间等待5至15秒: from locust import Locust, TaskSet, task_set class MyTaskSet(TaskSet): @task def my_task(self): print "executing my_task" class MyLocust(Locust): task_set = MyTaskSet min_wait = 5000 max_wait = 15000 min_wait和max_wait属性可以用于重写TaskSet类。 ...

June 2, 2017 · 9 min · Yuanjie

Locust快速入门

Locust,基于Python的性能测试工具。 什么是Locust 本文Locust版本0.7.5 原文地址:http://docs.locust.io/en/latest/quickstart.html# 示例locustfile.py 下面是一个简单的locustfile.py小示例: from locust import HttpLocust, TaskSet def login(l): l.client.post("/login", {"username":"ellen_key", "password":"education"}) def index(l): l.client.get("/") def profile(l): l.client.get("/profile") class UserBehavior(TaskSet): tasks = {index: 2, profile: 1} def on_start(self): login(self) class WebsiteUser(HttpLocust): task_set = UserBehavior min_wait = 5000 max_wait = 9000 ...

May 24, 2017 · 3 min · Yuanjie

JMeter3.2更新内容

2017.4.14,JMeter3.2版本发布。 原文地址:Apache JMeter 3.2 Release Notes , 下载地址: Download Apache JMeter 3.2 重要变更 JMeter现在需要Java8。确保你使用的最新版本的Java。 JMeter日志已经被迁移至SLF4J和Log4j 2。这个影响配制和第三方插件,查看下面的『日志变更』. 在使用JMeter的3.2版本时,在结果树中的结果数里从默认修改为500.如果你想查看更多,必须修改属性view.results.tree.max_results为一个更高的数值或者你不想限制数量可改为0。你可以在bin/user.properties中设置。更多的信息可查看这里 主要提升 JMeter现在提供一个新的BackendListener与InfluxDB交互 这个功能使用异步的HTTP请求发送数据至InfluxDB通过HTTP API并提供下面的图形展示结果 ...

May 13, 2017 · 3 min · Yuanjie

JMeter3.1更新内容

2016.11.20,JMeter官网已经正式发布了3.1的版本,今天尝试翻译下更新内容,内容中肯定还有很多不足,希望大家多多谅解。 原文地址:Apache JMeter 3.1 Release Notes , 下载地址: Download Apache JMeter 提升报告和仪表盘 仪表盘新增三个图表和一个概要表格 连接时间 成功百分比响应时间 响应时间分布 执行样例中的错误Top5 ...

March 9, 2017 · 2 min · Yuanjie

性能测试-JMeter入门手册

Github地址(源文件及脚本) 本文目的 面向新手,学习后可以使用JMeter独立完成项目的性能测试 快速分析并使用JMeter定位出项目性能测试结果 产出有价值的性能测试报告 目录 简介 认识JMeter 了解并启动JMeter 认识JMeter 第一个测试 提高JMeter 线程高并发 逻辑控件器 断言测试 结果分析 完善JMeter HTTP信息头管理 数据获取 实战性能测试 分析测试 断言结果详细分析 结果详细分析 服务器分析 扩展插件 进阶使用 命令行执行JMeter 性能测试常用专业述语 JMeter最佳实践 性能测试最佳实践 测试报告 结束语 说明 基础环境信息: OS:macOS Mojave 10.14.2 JDK:11.0.1 JMeter:5.2.1 QQ交流群:478527666 文中关于JMeter的功能,不会很详尽,够用足以 源GitBook地址:https://aimer1124.gitbooks.io/jmeter-tutorial/content/,停止更新

February 28, 2017 · 1 min · Yuanjie

JMeter与Docker

JMeter_docker Use JMeter with Docker Replace Demo.jmx Change the following about Demo.jmx file COPY Demo.jmx /opt/jmeter build Docker file in root folder docker build -t performanceDocker . run docker with performance testing ...

January 25, 2017 · 1 min · Yuanjie

Layout测试

Web页面Layout测试,一直是测试人员比较头疼的事情。原因有 当前市面中设备的分辨率千差万别 浏览器版本众多,工作量很大 如何使用高效的方式来测试Web Layout是否能正常,下面来看下Galen是如何帮助我们的 Galen的特点 开源项目,License基于Apache License, Version 2.0 可测试页面布局、响应式设计,支持功能测试 基于Selenium,对Selenium Grid支持很好,可直接在Sauce Labs和 BrowserStack 支持并行测试,减少测试时间 语法简洁 ...

November 28, 2016 · 3 min · Yuanjie