delta-qa-vision 0.0.1.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +202 -0
- data/NOTICE +4 -0
- data/README.md +259 -0
- data/lib/delta_qa/vision/delta-qa-capture.js +78 -0
- data/lib/delta_qa/vision/errors.rb +111 -0
- data/lib/delta_qa/vision/ferrum.rb +217 -0
- data/lib/delta_qa/vision/frameworks.rb +57 -0
- data/lib/delta_qa/vision/gate.rb +140 -0
- data/lib/delta_qa/vision/playwright.rb +166 -0
- data/lib/delta_qa/vision/relay.rb +668 -0
- data/lib/delta_qa/vision/resize_wait.rb +34 -0
- data/lib/delta_qa/vision/selenium.rb +237 -0
- data/lib/delta_qa/vision.rb +109 -0
- metadata +59 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 93a997f56fe0c741e7bcaeef952bbf7061dba45f0753a854aad3f10ce43f625e
|
|
4
|
+
data.tar.gz: d4c2cd45f0fc378ba55525baceb2f964b7c5d77342eefa2a4a3012c5ae8e0fa4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: dac089b2f5a57086570cfe57ddcb1773f331528152e5c0c8c8dc36645894e5080ae073a84355133ab7805d2b4397f7fd4c929df544201607f67582c36130c299
|
|
7
|
+
data.tar.gz: a73a849b333d8178cb5e635bba728c375e4778f0ba1dbb7c86cf6dcb38dfdef224ed46eea26bffb627af86fb6f753a4aa73ebd26a9c2f65faa792a45a84cd42c
|
data/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/NOTICE
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Delta-QA Vision for Ruby
|
|
2
|
+
|
|
3
|
+
Delta-QA's visual regression SDK for Ruby tests on Selenium, Playwright, Ferrum, Capybara and Watir. A test sends its pages to Delta-QA, which compares each of them with the reference of the test in the same environment. Delta-QA is artificial sight: it compares the way a human eye would. A pixel-by-pixel comparison flags differences no one can see — false positives — and misses changes a person notices — false negatives. Delta-QA reports only the differences a person can see, and decides the result.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Ruby 3.3 or later
|
|
8
|
+
- One of the frameworks below, the one your test already uses: the SDK brings none, and uses the version of your test. Minitest and RSpec both run it.
|
|
9
|
+
|
|
10
|
+
| Framework | Gem |
|
|
11
|
+
|---|---|
|
|
12
|
+
| Selenium | `selenium-webdriver` 4 |
|
|
13
|
+
| Playwright | `playwright-ruby-client` |
|
|
14
|
+
| Ferrum | `ferrum` |
|
|
15
|
+
| Capybara | `capybara` 3, with its Selenium driver or `cuprite` |
|
|
16
|
+
| Watir | `watir` 7 |
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
# Gemfile
|
|
22
|
+
gem "delta-qa-vision", group: :test
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Environment variables
|
|
26
|
+
|
|
27
|
+
| Variable | Purpose |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `DELTAQA_API_KEY` | An API key of your workspace (`dqa_…`) whose role can edit, to send pages. An administrator creates it in *Settings → Workspace → API keys*; it is shown once. The workspace is the key's: there is no workspace setting |
|
|
30
|
+
| `DELTAQA_SERVER_URL` | The root of your Delta-QA server, e.g. `http://localhost:9327`; the SaaS, `https://api.delta-qa.com`, when not set |
|
|
31
|
+
|
|
32
|
+
Without a key, opening a test fails and names the variable to set. The key is sent in the `Authorization` header only: it never appears in an error message, a log or a link of the SDK.
|
|
33
|
+
|
|
34
|
+
## The Vision API
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
require "delta_qa/vision"
|
|
38
|
+
|
|
39
|
+
DeltaQa::Vision.open(driver, id: "checkout", name: "Checkout",
|
|
40
|
+
commit: ENV.fetch("GITHUB_SHA"),
|
|
41
|
+
branch: ENV["GITHUB_HEAD_REF"].to_s.empty? ? nil : ENV["GITHUB_HEAD_REF"],
|
|
42
|
+
base_branch: ENV["GITHUB_BASE_REF"].to_s.empty? ? nil : ENV["GITHUB_BASE_REF"]) do |vision|
|
|
43
|
+
driver.navigate.to("https://shop.example/cart")
|
|
44
|
+
vision.check("Cart")
|
|
45
|
+
driver.find_element(id: "pay").click
|
|
46
|
+
vision.check("Payment", ignore: ["#now", { id: "advert" }])
|
|
47
|
+
end
|
|
48
|
+
# closed: raises DeltaQa::Vision::TestFailedError when Delta-QA decides UNRESOLVED, REJECTED or FAILED
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
With a block, the test is closed when the block returns, and `open` returns its results. A block that raised keeps its own error, and its launches are closed by Delta-QA after a delay. Without a block, `open` returns the test: call `close`, which returns the results (each launch, its result, the link of its comparison and of the commit).
|
|
52
|
+
|
|
53
|
+
`open` takes these keywords; `sizes:` is a list of `DeltaQa::Vision::Size.new(width, height)`:
|
|
54
|
+
|
|
55
|
+
| Setting | Meaning |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `id:` | What recognises the test, with `app:`: keep it when the name changes; a new id is a new test |
|
|
58
|
+
| `name:` | The name Delta-QA shows the test under |
|
|
59
|
+
| `commit:` | **Required**: the git commit tested, its hash as the CI gives it |
|
|
60
|
+
| `tag:` | The git tag of the commit, shown beside it; `nil` when the commit has none — the common case |
|
|
61
|
+
| `branch:` | The branch of the launch; `nil` when the run is on no branch (the build of a tag, a detached commit) |
|
|
62
|
+
| `base_branch:` | The branch whose reference is used while the branch has none — the target of a pull or merge request; `nil` without one. Equal to the branch, it is not sent |
|
|
63
|
+
| `app:` | The application of the test, a label; optional |
|
|
64
|
+
| `sizes:` | The sizes the page is taken at: one launch per size, the page resized in the test's browser at each check and given back its size, its resources sent once; without it, the page's own size |
|
|
65
|
+
| `save_new_tests:` | Whether the pages of a new test become its reference (result `NEW`); true when absent, false to judge them first (`UNRESOLVED`) |
|
|
66
|
+
|
|
67
|
+
A setting given as an empty text is refused when the test opens, and nothing is sent.
|
|
68
|
+
|
|
69
|
+
## Demo
|
|
70
|
+
|
|
71
|
+
The [GoodDeal practice tests](https://github.com/delta-qa-com/gooddeal-practice-tests/tree/main) hold ready-to-run tests against [GoodDeal](https://delta-qa.com/playground/), a free demo store: four journeys (an order, a declined card, the contact form, the sign-in), each with a Vision check at every step. The Vision tests run when `DELTAQA_API_KEY` is set.
|
|
72
|
+
|
|
73
|
+
| Framework | Demo |
|
|
74
|
+
|---|---|
|
|
75
|
+
| Selenium | [`ruby/selenium`](https://github.com/delta-qa-com/gooddeal-practice-tests/tree/main/ruby/selenium) |
|
|
76
|
+
| Capybara | [`ruby/capybara`](https://github.com/delta-qa-com/gooddeal-practice-tests/tree/main/ruby/capybara) |
|
|
77
|
+
| Playwright | [`ruby/playwright`](https://github.com/delta-qa-com/gooddeal-practice-tests/tree/main/ruby/playwright) |
|
|
78
|
+
| Watir | [`ruby/watir`](https://github.com/delta-qa-com/gooddeal-practice-tests/tree/main/ruby/watir) |
|
|
79
|
+
| Ferrum | [`ruby/ferrum`](https://github.com/delta-qa-com/gooddeal-practice-tests/tree/main/ruby/ferrum) |
|
|
80
|
+
|
|
81
|
+
## The commit, the tag and the branches
|
|
82
|
+
|
|
83
|
+
The SDK reads neither git nor your CI: give it the values of the run, read in the variables of your CI. `commit` is required; the others are absent (``nil``) when they do not exist.
|
|
84
|
+
|
|
85
|
+
| CI | commit | tag | branch | base branch |
|
|
86
|
+
|---|---|---|---|---|
|
|
87
|
+
| GitHub Actions | `GITHUB_SHA` | `GITHUB_REF_NAME` when `GITHUB_REF_TYPE` is `tag` | `GITHUB_HEAD_REF`, else `GITHUB_REF_NAME` when `GITHUB_REF_TYPE` is `branch` | `GITHUB_BASE_REF` |
|
|
88
|
+
| GitLab CI | `CI_COMMIT_SHA` | `CI_COMMIT_TAG` | `CI_MERGE_REQUEST_SOURCE_BRANCH_NAME`, else `CI_COMMIT_BRANCH` | `CI_MERGE_REQUEST_TARGET_BRANCH_NAME` |
|
|
89
|
+
| Bitbucket Pipelines | `BITBUCKET_COMMIT` | `BITBUCKET_TAG` | `BITBUCKET_BRANCH` | `BITBUCKET_PR_DESTINATION_BRANCH` |
|
|
90
|
+
| Azure Pipelines | `BUILD_SOURCEVERSION` | `BUILD_SOURCEBRANCH` of the form `refs/tags/…` | `SYSTEM_PULLREQUEST_SOURCEBRANCH`, without its `refs/heads/`, else `BUILD_SOURCEBRANCH` of the form `refs/heads/…` | `SYSTEM_PULLREQUEST_TARGETBRANCH`, without its `refs/heads/` |
|
|
91
|
+
|
|
92
|
+
Machines that run the same suite in parallel share one commit by giving the same text.
|
|
93
|
+
|
|
94
|
+
## Browsers
|
|
95
|
+
|
|
96
|
+
The page is taken in **Chrome, Chromium or Edge**, through the browser's DevTools protocol, at a device pixel ratio of 1. Under another browser (Firefox, Safari), opening a test fails with an unsupported-browser error, and nothing is sent.
|
|
97
|
+
|
|
98
|
+
A check is taken from the top document of the page: under Selenium, Capybara with Selenium and Watir, switch back out of any frame (`switch_to.default_content`, the end of a `within_frame` block) before checking.
|
|
99
|
+
|
|
100
|
+
## Checks and zones
|
|
101
|
+
|
|
102
|
+
`check(name)` sends the page as the test sees it now — the live DOM, the state of its fields, its web components and its frames, and the files it uses. Every check of a test has its own name: a name already taken is refused, and nothing is sent.
|
|
103
|
+
|
|
104
|
+
A check can leave **zones** out of the comparison (`ignore:`: a clock, an advert) or compare **one zone alone** (`region:`). A zone is a CSS selector (a `String`), or a locator or an element of your framework — each framework below says which. Every element a zone designates is one zone; a zone that designates none fails the check, and nothing is sent. A zone is an element of the page itself: an element inside a frame is refused.
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
vision.check("Cart", ignore: ["#now"], region: "main")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Frameworks
|
|
111
|
+
|
|
112
|
+
`DeltaQa::Vision.open` takes the object your test holds, and recognises its framework by it. Anything else is refused with a `TypeError`.
|
|
113
|
+
|
|
114
|
+
### Selenium
|
|
115
|
+
|
|
116
|
+
Pass the `Selenium::WebDriver::Driver` (`Selenium::WebDriver.for(:chrome)`, `(:edge)`).
|
|
117
|
+
|
|
118
|
+
```ruby
|
|
119
|
+
driver = Selenium::WebDriver.for(:chrome, options: Selenium::WebDriver::Chrome::Options.new(args: ["--headless=new"]))
|
|
120
|
+
DeltaQa::Vision.open(driver, id: "cart", name: "Cart", commit: ENV.fetch("GITHUB_SHA")) do |vision|
|
|
121
|
+
driver.navigate.to("https://shop.example/cart")
|
|
122
|
+
vision.check("Cart", ignore: ["#now", { id: "advert" }, driver.find_element(css: "aside")])
|
|
123
|
+
end
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
A zone is a CSS selector, a locator as `find_elements` takes it (`{ css: "#cart" }`, `{ id: "advert" }`, `{ xpath: "//aside" }`), or a `Selenium::WebDriver::Element`. A frame still receiving its document is waited for within the page load timeout of the driver (`driver.manage.timeouts.page_load`).
|
|
127
|
+
|
|
128
|
+
### Playwright
|
|
129
|
+
|
|
130
|
+
Pass the `Playwright::Page` of `playwright-ruby-client`, in a Chromium browser (`playwright.chromium`, `channel: "chrome"` or `"msedge"` included).
|
|
131
|
+
|
|
132
|
+
```ruby
|
|
133
|
+
# spec/cart_spec.rb (RSpec)
|
|
134
|
+
RSpec.describe "Cart" do
|
|
135
|
+
it "looks as it did" do
|
|
136
|
+
Playwright.create(playwright_cli_executable_path: "npx playwright") do |playwright|
|
|
137
|
+
playwright.chromium.launch(channel: "chrome") do |browser|
|
|
138
|
+
page = browser.new_page(viewport: { width: 1280, height: 720 })
|
|
139
|
+
DeltaQa::Vision.open(page, id: "cart", name: "Cart", commit: ENV.fetch("GITHUB_SHA")) do |vision|
|
|
140
|
+
page.goto("https://shop.example/cart")
|
|
141
|
+
vision.check("Cart", ignore: [page.locator("#now")])
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
A zone is a selector (`page.locator` takes it), a `Playwright::Locator` or a `Playwright::ElementHandle`, of the page given to `open`. A frame still receiving its document is waited for within the navigation timeout of the page (`page.set_default_navigation_timeout`).
|
|
150
|
+
|
|
151
|
+
### Ferrum
|
|
152
|
+
|
|
153
|
+
Pass the `Ferrum::Browser` — the SDK follows the page it shows — or one `Ferrum::Page`.
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
# test/cart_test.rb (minitest)
|
|
157
|
+
class CartTest < Minitest::Test
|
|
158
|
+
def test_the_cart_looks_as_it_did
|
|
159
|
+
browser = Ferrum::Browser.new(window_size: [1280, 720], timeout: 30)
|
|
160
|
+
DeltaQa::Vision.open(browser, id: "cart", name: "Cart", commit: ENV.fetch("GITHUB_SHA")) do |vision|
|
|
161
|
+
browser.go_to("https://shop.example/cart")
|
|
162
|
+
vision.check("Cart", ignore: [browser.at_css("#now"), { xpath: "//aside" }])
|
|
163
|
+
end
|
|
164
|
+
ensure
|
|
165
|
+
browser&.quit
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
A zone is a CSS selector, a locator `{ css: "#cart" }` or `{ xpath: "//aside" }`, or a `Ferrum::Node`. The `timeout:` of the browser bounds each reading of the SDK in the page and the wait for a frame still receiving its document: a page whose files are slow to read needs it longer than Ferrum's 5 seconds.
|
|
171
|
+
|
|
172
|
+
### Capybara
|
|
173
|
+
|
|
174
|
+
Pass the `Capybara::Session` — `page` in a feature or system spec — driven by the Selenium driver (`:selenium_chrome_headless`, Chrome or Edge) or by Cuprite (`:cuprite`). A session without a browser, such as `rack_test`, is refused with a `TypeError`.
|
|
175
|
+
|
|
176
|
+
```ruby
|
|
177
|
+
# spec/features/cart_spec.rb (RSpec, Cuprite)
|
|
178
|
+
require "capybara/cuprite"
|
|
179
|
+
Capybara.javascript_driver = :cuprite
|
|
180
|
+
|
|
181
|
+
RSpec.describe "Cart", type: :feature, js: true do
|
|
182
|
+
it "looks as it did" do
|
|
183
|
+
DeltaQa::Vision.open(page, id: "cart", name: "Cart", commit: ENV.fetch("GITHUB_SHA")) do |vision|
|
|
184
|
+
visit "/cart"
|
|
185
|
+
vision.check("Cart", ignore: [find("#now")], region: "main")
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
A zone is a CSS selector, a `Capybara::Node::Element` (`find("#now")`), or a zone of the driver under the session (Selenium's or Ferrum's, above).
|
|
192
|
+
|
|
193
|
+
### Watir
|
|
194
|
+
|
|
195
|
+
Pass the `Watir::Browser`, under Chrome or Edge.
|
|
196
|
+
|
|
197
|
+
```ruby
|
|
198
|
+
# test/cart_test.rb (minitest)
|
|
199
|
+
class CartTest < Minitest::Test
|
|
200
|
+
def test_the_cart_looks_as_it_did
|
|
201
|
+
browser = Watir::Browser.new(:chrome, options: { args: ["--headless=new"] })
|
|
202
|
+
DeltaQa::Vision.open(browser, id: "cart", name: "Cart", commit: ENV.fetch("GITHUB_SHA")) do |vision|
|
|
203
|
+
browser.goto("https://shop.example/cart")
|
|
204
|
+
vision.check("Cart", ignore: [browser.element(id: "now")])
|
|
205
|
+
end
|
|
206
|
+
ensure
|
|
207
|
+
browser&.close
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
A zone is a CSS selector, a Watir element (`browser.element(id: "now")`, `browser.div(class: "advert")`) — one that does not exist designates nothing —, or a zone of Selenium (above).
|
|
213
|
+
|
|
214
|
+
## The verdict
|
|
215
|
+
|
|
216
|
+
`close` closes every launch of the test and waits for Delta-QA's result (at most 15 minutes):
|
|
217
|
+
|
|
218
|
+
| Result | The test |
|
|
219
|
+
|---|---|
|
|
220
|
+
| `NEW` | Passes: the pages became the reference of a new test |
|
|
221
|
+
| `PASSED` | Passes: the same pages as the reference |
|
|
222
|
+
| `UNRESOLVED` | Fails: a difference waits for a person's judgment — the message gives the link of the commit in Delta-QA |
|
|
223
|
+
| `REJECTED` | Fails: a difference was judged a bug |
|
|
224
|
+
| `FAILED` | Fails: Delta-QA could not compare the pages |
|
|
225
|
+
|
|
226
|
+
A second call to `close` gives the same results, or the same failure, without asking Delta-QA again.
|
|
227
|
+
|
|
228
|
+
## Errors
|
|
229
|
+
|
|
230
|
+
| Error | When |
|
|
231
|
+
|---|---|
|
|
232
|
+
| `DeltaQa::Vision::ConfigurationError` | A variable is missing or wrong; the error names it |
|
|
233
|
+
| `DeltaQa::Vision::ApiError` | Delta-QA refused a request: its code names the cause (e.g. `API_KEY_INVALID`, `INSUFFICIENT_ROLE`, `LAUNCH_CLOSED`), its ticket names the occurrence — quote it to the support |
|
|
234
|
+
| `DeltaQa::Vision::UnreachableError` | No answer came from the server; the cause says what the network said |
|
|
235
|
+
| `DeltaQa::Vision::UnsupportedBrowserError` | The browser is not Chrome, Chromium or Edge; nothing is opened |
|
|
236
|
+
| `DeltaQa::Vision::UnsupportedDensityError` | The page is shown at a device pixel ratio other than 1 |
|
|
237
|
+
| `DeltaQa::Vision::DuplicateCheckNameError` | `check` was given a name already taken in the test; nothing is sent |
|
|
238
|
+
| `DeltaQa::Vision::ZoneNotFoundError` | A zone of `check` matches no element of the page; the error names it, and nothing is sent |
|
|
239
|
+
| `DeltaQa::Vision::ResourceUnreadableError` | A file the page cites could not be read, or did not come whole within 30 seconds; the error names its address |
|
|
240
|
+
| `DeltaQa::Vision::ResourceTooLargeError` | A file the page cites is larger than Delta-QA admits; the check is not sent |
|
|
241
|
+
| `DeltaQa::Vision::LaunchResultTimeoutError` | The wait for a result ran out; the launch keeps running on Delta-QA, and the message gives the address of its comparison |
|
|
242
|
+
| `DeltaQa::Vision::TestFailedError` | Delta-QA decided a launch `UNRESOLVED`, `REJECTED` or `FAILED`: the results give each launch, its comparison, and the link of the commit |
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
## Your data
|
|
246
|
+
|
|
247
|
+
What the SDK sends — the pages your tests check and the files they use — serves only to compare them. Testing on production personal data is your responsibility: run your suites on test data.
|
|
248
|
+
|
|
249
|
+
To read a file the page cites and the browser cannot hand over, the SDK asks for it itself, as the browser would: with the browser's cookies for that address, its user agent and its `Referer`. Only `http` and `https` addresses are read.
|
|
250
|
+
|
|
251
|
+
## Versions
|
|
252
|
+
|
|
253
|
+
The SDK is released with Delta-QA: its version is the Delta-QA release that published it. Its compatibility is carried by the API it calls — the Vision API **v1**, `/api/vision/v1`, a frozen contract that only grows. A breaking change of the API is a v2, deployed beside v1, and v1 keeps answering until its announced end.
|
|
254
|
+
|
|
255
|
+
## Licence
|
|
256
|
+
|
|
257
|
+
Apache License 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE). Calling Delta-QA requires a Delta-QA API key.
|
|
258
|
+
|
|
259
|
+
Support: support@delta-qa.com · <https://delta-qa.com>
|