# deep-diff [![Build Status](https://travis-ci.org/flitbit/diff.png?branch=master)](https://travis-ci.org/flitbit/diff)
[![NPM](https://nodei.co/npm/deep-diff.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/deep-diff/)
**deep-diff** is a javascript/node.js module providing utility functions for determining the structural differences between objects and includes some utilities for applying differences across objects.
## Features
* Get the structural differences between two objects.
* Observe the structural differences between two objects.
* When structural differences represent change, apply change from one object to another.
* When structural differences represent change, selectively apply change from one object to another.
## ChangeLog
`0.3.8` - 2017-05-03
* reconciled recently introduced difference between `index.es.js` and `index.js`
* improved npm commands for more reliable contributions
* added a few notes to README regarding contributing.
`0.3.7` - 2017-05-01
* fixed issue #98 by merging @sberan's pull request #99 — better handling of property with `undefined` value existing on either operand. Unit tests supplied.
`0.3.6` - 2017-04-25 — Fixed, closed lingering issues:
* fixed #74 — comparing objects with longer cycles
* fixed #70 — was not properly detecting a deletion when a property on the operand (lhs) had a value of `undefined` and was _undefined_ on the comparand (rhs). :o).
* WARNING! [Still broken when importing in Typescript](https://github.com/flitbit/diff/issues/97).
`0.3.5` - 2017-04-23 — Rolled up recent fixes; patches:
* @stevemao — #79, #80: now testing latest version of node4
* @mortonfox — #85: referencing mocha's new home
* @tdebarochez — #90: fixed error when .toString not a function
* @thiamsantos — #92, #93: changed module system for improved es2015 modules. WARNING! [This PR broke importing `deep-diff` in Typescript as reported by @kgentes in #97](https://github.com/flitbit/diff/issues/97)
`0.3.4` - Typescript users, reference this version until #97 is fixed!
`0.3.3` - Thanks @SimenB: enabled npm script for release (alternate to the Makefile). Also linting as part of `npm test`. Thanks @joeldenning: Fixed issue #35; diffs of top level arrays now working.
`0.3.3` - Thanks @SimenB: enabled npm script for release (alternate to the Makefile). Also linting as part of `npm test`. Thanks @joeldenning: Fixed issue #35; diffs of top level arrays now working.
`0.3.2` - Resolves #46; support more robust filters by including `lhs` and `rhs` in the filter callback. By @Orlando80
`0.3.1` - Better type checking by @Drinks, UMD wrapper by @SimenB. Now certifies against nodejs 12 and iojs (Thanks @SimenB).
`0.2.0` - [Fixes Bug #17](https://github.com/flitbit/diff/issues/17), [Fixes Bug #19](https://github.com/flitbit/diff/issues/19), [Enhancement #21](https://github.com/flitbit/diff/issues/21) Applying changes that are properly structured can now be applied as a change (no longer requires typeof Diff) - supports differences being applied after round-trip serialization to JSON format. Prefilter now reports the path of all changes - it was not showing a path for arrays and anything in the structure below (reported by @ravishvt).
*Breaking Change* – The structure of change records for differences below an array element has changed. Array indexes are now reported as numeric elements in the `path` if the changes is merely edited (an `E` kind). Changes of kind `A` (array) are only reported for changes in the terminal array itself and will have a nested `N` (new) item or a nested `D` (deleted) item.
`0.1.7` - [Enhancement #11](https://github.com/flitbit/diff/issues/11) Added the ability to filter properties that should not be analyzed while calculating differences. Makes `deep-diff` more usable with frameworks that attach housekeeping properties to existing objects. AngularJS does this, and the new filter ability should ease working with it.
`0.1.6` - Changed objects within nested arrays can now be applied. They were previously recording the changes appropriately but `applyDiff` would error. Comparison of `NaN` works more sanely - comparison to number shows difference, comparison to another `Nan` does not.
## Installation
```
npm install deep-diff
```
For the browser, you can install with [bower](http://bower.io/):
```
bower install deep-diff
```
## Tests
Tests use [mocha](http://mochajs.org/) and [expect.js](https://github.com/LearnBoost/expect.js/), so if you clone the [github repository](https://github.com/flitbit/json-ptr) you'll need to run:
```bash
npm install
```
... followed by ...
```bash
npm test
```
... or ...
```bash
mocha -R spec
```
### Importing
**nodejs**
```javascript
var deep = require('deep-diff')
```
**browser**
```html
<script src="deep-diff-0.3.1.min.js"></script>
```
> Minified, browser release of the current version of the module is under the `releases` folder.
> In a browser, `deep-diff` defines a global variable `DeepDiff`. If there is a conflict in the global namespace you can restore the conflicting definition and assign `deep-diff` to another variable like this: `var deep = DeepDiff.noConflict();`.
## Simple Examples
In order to describe differences, change revolves around an `origin` object. For consistency, the `origin` object is always the operand on the `left-hand-side` of operations. The `comparand`, which may contain changes, is always on the `right-hand-side` of operations.
``` javascript
var diff = require('deep-diff').diff;
var lhs = {
name: 'my object',
description: 'it\'s an object!',
details: {
it: 'has',
an: 'array',
with: ['a', 'few', 'elements']
}
};
var rhs = {
name: 'updated object',
description: 'it\'s an object!',
details: {
it: 'has',
an: 'array',
with: ['a', 'few', 'more', 'elements', { than: 'before' }]
}
};
var differences = diff(lhs, rhs);
```
*up to v 0.1.7* The code snippet above would result in the following structure describing the differences:
``` javascript
// Versions < 0.2.0
[ { kind: 'E',
path: [ 'name' ],
lhs: 'my object',
rhs: 'updated object' },
{ kind: 'A',
path: [ 'details', 'with' ],
index: 2,
item: { kind: 'E', path: [], lhs: 'elements', rhs: 'more' } },
{ kind: 'A',
path: [ 'details', 'with' ],
index: 3,
item: { kind: 'N', rhs: 'elements' } },
{ kind: 'A',
path: [ 'details', 'with' ],
index: 4,
item: { kind: 'N', rhs: { than: 'before' } } } ]
```
*v 0.2.0 and above* The code snippet above would result in the following structure describing the differences:
``` javascript
[ { kind: 'E',
path: [ 'name' ],
lhs: 'my object',
rhs: 'updated object' },
{ kind: 'E',
path: [ 'details', 'with', 2 ],
lhs: 'elements',
rhs: 'more' },
{ kind: 'A',
path: [ 'details', 'with' ],
index: 3,
item: { kind: 'N', rhs: 'elements' } },
{ kind: 'A',
path: [ 'details', 'with' ],
index: 4,
item: { kind: 'N', rhs: { than: 'before' } } } ]
```
### Differences
Differences are reported as one or more change records. Change records have the following structure:
* `kind` - indicates the kind of change; will be one of the following:
* `N` - indicates a newly added property/element
* `D` - indicates a property/element was deleted
* `E` - indicates a property/element was edited
* `A` - indicates a change occurred within an array
* `path` - the property path (from the left-hand-side root)
* `lhs` - the value on the left-hand-side of the comparison (undefined if kind === 'N')
* `rhs` - the value on the right-hand-side of the comparison (undefined if kind === 'D')
* `index` - when kind === 'A', indicates the array index where the change occurred
* `item` - when kind === 'A', contains a nested change record indicating the change that occurred at the array index
Change records are generated for all structural differences between `origin` and `comparand`. The
appium工具 Appium Inspector使用
需积分: 0 39 浏览量
更新于2023-12-04
收藏 150.66MB ZIP 举报
Appium是一款强大的自动化测试工具,尤其在移动应用测试领域中占据重要地位。它支持iOS、Android以及Windows平台,使得开发者和测试工程师能够跨平台进行应用的功能性测试。Appium Inspector是Appium的一部分,是一个可视化工具,它允许用户通过图形界面来检查和交互应用的用户界面元素,这对于编写自动化测试脚本非常有帮助。
**Appium的核心概念:**
1. **WebDriver协议**:Appium基于WebDriver协议,这是一种用于自动化浏览器和移动应用的开放标准。它使得各种编程语言如Java、Python、Ruby等都可以用来编写测试脚本。
2. **模拟器/真机**:Appium支持在真实设备或模拟器上运行测试,这提供了灵活的测试环境选择。
3. **原生API访问**:Appium可以直接与应用的原生API交互,无论是Android的UIAutomator2还是iOS的XCUITest框架,都能被Appium很好地支持。
**Appium Inspector的功能:**
1. **元素检测**:Appium Inspector可以显示应用中的所有可交互元素,包括它们的属性(如ID、类名、文本等),这对于定位UI元素编写测试脚本至关重要。
2. **实时查看**:在运行应用的同时,Inspector会实时更新元素树,方便观察用户操作对UI结构的影响。
3. **元素交互**:你可以直接通过Inspector触发元素的操作,比如点击、滑动、输入文本,这有助于验证元素的行为是否符合预期。
4. **记录会话**:Inspector可以记录你在应用中的交互,生成相应的WebDriver命令,这些命令可以用于构建测试脚本。
5. **截图功能**:在测试过程中,Inspector提供截图功能,方便记录和分析问题。
**使用Appium Inspector的步骤:**
1. **安装配置**:首先需要安装Appium Desktop,其中包含了Appium Server和Inspector。确保正确配置了设备连接和驱动版本。
2. **启动Server**:运行Appium Server,设置必要的配置参数,如平台类型、设备标识、应用路径等。
3. **启动Inspector**:在Appium Desktop中打开Inspector,连接到已启动的Server。
4. **选择设备**:在Inspector中选择要测试的设备或模拟器。
5. **录制测试**:开始应用并使用Inspector检查和交互UI,记录会话以生成测试脚本。
6. **调试和优化**:根据Inspector提供的信息调试脚本,优化元素定位和动作执行。
**Appium Inspector的优势:**
1. **跨平台兼容**:无论是在iOS还是Android平台上,Inspector都能提供一致的用户体验。
2. **直观易用**:它的可视化界面使得即使是初学者也能快速上手。
3. **强大的调试能力**:通过Inspector,开发者可以深入理解应用的UI结构,从而更好地调试自动化测试脚本。
4. **提高效率**:减少了手动测试的工作量,提高了测试覆盖率和测试质量。
Appium Inspector是Appium自动化测试不可或缺的一部分,它为开发者和测试人员提供了一个强大而直观的工具,以提升移动应用的测试效率和质量。通过熟练掌握其使用,可以有效地减少错误,确保产品的稳定性。
-行业小白
- 粉丝: 118
- 资源: 8
最新资源
- sbmy.7z代码压缩包
- 基于一阶RC电池模型的锂离子电池SOE精确估计:融合FFRLS参数辨识与EKF联合估计法的实践验证,基于一阶RC电池模型的锂离子电池SOE估计 使用遗忘因子最小二乘法 FFRLS 对电池模型进行在线参
- 一个简单的聊天机器人网页应用程序,使用 DeepSeek 的 API 来响应文本输入 通过 Gradio 库启动,允许用户通过友好的界面提交文本,并接收聊天机器人的响应 (python源码)
- 基于BP神经网络优化的永磁同步电机控制算法与模型对比研究,基于BP神经网络PI的永磁同步电机控制【提供参考资料】【有模型对比】 一、算法简介 利用BP神经网络对永磁同步电机的速度环PI进行调整,增强控
- 高级语言程序设计大作业基于C++ Qt实现的视频播放器源代码+实验报告
- 《超表面资料大放送:贝塞尔光束全流程教程,附赠代码与案例》,上新超表面资料,贝塞尔光束教程 利用超表面产生任意阶数贝塞尔光束 全流程视频,附赠代码,案例 贝塞尔光束相位计算,Cst联合建模,光场强度分
- 大数据存储实验1111111111
- OneJS v1.5.9
- "基于扩展卡尔曼滤波算法与PI调节器的永磁同步电机无传感器控制Simulink仿真模型研究",永磁同步电机系列 KEF扩展卡尔曼滤波无传感器控制Matlab仿真 Simulink三相永磁同步电机E
- "精解PreScan仿真平台下的Simulink应用:LKA(车道保持辅助)PID控制、AEB(自动紧急制动)与FCW(前方碰撞预警)的分层状态机逻辑控制,涵盖CPNA行人横穿场景中的发动机逆模型技术
- "一种实用且高效的交互式多模型跟踪算法IMM的MATLAB源代码实现,经过测试真实好用,代码注释详尽,完美运行体验",一种实用的交互式多模型跟踪算法IMM,真实好用,测试过一种实用的交互式多模型跟踪算
- MATLAB实现容积卡尔曼滤波算法及其仿真算例:代码详解与完美运行,用matlab实现了容积卡尔曼滤波算法,并给出了仿真算例 matlab源代码 代码有详细注释,完美运行 ,核心关键词:matlab
- 基于Simulink模型与模糊逻辑的整车质量估计算法研究与应用,整车质量估计算法,采用simulink模型搭建,基于模糊逻辑思想,通过设计合理的模糊控制规则确定质量估计的置信度,当置信度高于某一水平时
- "基于Yolo V3-Tiny网络的FPGA图像视频人脸检测工程:Xilinx Zynq Ultrascale+平台上的并行计算加速实现",使用yolo v3-tiny 网络 fpga图像视频人脸检测
- 机械臂仿真技术研究:RRT避障算法与六自由度机械臂避障算法的实践,机械臂仿真,RRT避障算法,六自由度机械臂算法 机械臂matlab仿真,RRT避障算法,六自由度机械臂避障算法,RRT避障算法,避障仿
- 【创新发文无忧】白鹭群算法ESOA-DELM故障诊断【含Matlab源码 6852期】.zip