通过selenium进行浏览器性能测试
我们使用“grandor”测试内部AngularJS应用程序。
除了功能测试之外,我们还可以在
deparator perf
是什么
基于nodejsbrowser perf
图书馆。“因为是表演
功能“.
使用“detactor perf”,我们可以测量和断言不同的性能
进行浏览器操作时的特征,针对
示例:
browser.get('http://www.angularjs.org');
perf.start(); // Start measuring the metrics
element(by.model('todoText')).sendKeys('write a protractor test');
element(by.css('[value="add"]')).click();
perf.stop(); // Stop measuring the metrics
if (perf.isEnabled) { // Is perf measuring enabled ?
// Check for perf regressions, just like you check for functional regressions
expect(perf.getStats('meanFrameTime')).toBeLessThan(60);
};
现在,对于另一个内部应用程序,我们有一组基于硒的测试
用Python编写。
是否可以使用selenium python检查性能回归,或者
我应该用“量角器”重写测试来编写浏览器吗
性能测试?
-
有可能更接近[什么是浏览器性能]
正在做](https://github.com/axemclion/browser-perf/wiki/Architecture)通过
收集[chrome性能
日志](https://sites.google.com/a/chrome.org/chromedriver/logging/performance-
日志)并进行分析。
为了[获得性能
日志](https://stackoverflow.com/questions/27644615/get-chrome-performance-
以及跟踪日志),通过调整loggingPrefs打开“performance”日志`
所需能力:from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities caps = DesiredCapabilities.CHROME caps['loggingPrefs'] = {'performance': 'ALL'} driver = webdriver.Chrome(desired_capabilities=caps) driver.get('https://stackoverflow.com') logs = [json.loads(log['message'])['message'] for log in driver.get_log('performance')] with open('devtools.json', 'wb') as f: json.dump(logs, f) driver.close()
At this point,
devtools.json
file would contain a bunch of trace records:[ { "params": { "timestamp": 1419571233.19293, "frameId": "16639.1", "requestId": "16639.1", "loaderId": "16639.2", "type": "Document", "response": { "mimeType": "text/plain", "status": 200, "fromServiceWorker": false, "encodedDataLength": -1, "headers": { "Access-Control-Allow-Origin": "*", "Content-Type": "text/plain;charset=US-ASCII" }, "url": "data:,", "statusText": "OK", "connectionId": 0, "connectionReused": false, "fromDiskCache": false } }, "method": "Network.responseReceived" }, { "params": { "timestamp": 1419571233.19294, "encodedDataLength": 0, "requestId": "16639.1" }, "method": "Network.loadingFinished" }, .. ]
现在,问题是,怎么处理它。
一个最初被建议的选项[在Google测试自动化期间]
[会议](https://www.youtube.com/watch?v=0(kAPWSZNY4)提交日志
到网页测试.org. 有一个例子
java可用此处,但是,在
现在,我还没有用Python实现它。
理论上,UI报表由网页测试.org看起来像这样:
它们还提供JSON/XML和其他格式的度量
进一步分析。
这真的很了不起,多亏了维韦克·辛格的直截了当的评论。
browser perf还使用日志记录功能来提取跟踪日志,
并对数据进行分析。