appium-safari-driver 1.1.1 → 2.2.1
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.
- package/.azure-pipelines.yml +30 -0
- package/.eslintignore +2 -0
- package/.eslintrc +3 -0
- package/.github/dependabot.yml +11 -0
- package/LICENSE +198 -10
- package/README.md +137 -13
- package/azure-templates/node_setup_steps.yml +6 -0
- package/build/index.js +35 -31
- package/build/lib/commands/find.js +16 -473
- package/build/lib/commands/index.js +14 -64
- package/build/lib/commands/record-screen.js +329 -0
- package/build/lib/desired-caps.js +48 -0
- package/build/lib/driver.js +61 -197
- package/build/lib/logger.js +12 -7
- package/build/lib/safari.js +197 -0
- package/build/lib/server.js +24 -27
- package/build/lib/utils.js +19 -273
- package/build/test/functional/desktop-driver-e2e-specs.js +56 -0
- package/build/test/functional/mobile-driver-e2e-specs.js +83 -0
- package/build/test/unit/driver-specs.js +20 -0
- package/build/test/unit/utils-specs.js +51 -0
- package/build/test/utils.js +18 -0
- package/gulpfile.js +10 -4
- package/index.js +12 -12
- package/lib/commands/find.js +10 -199
- package/lib/commands/index.js +12 -26
- package/lib/commands/record-screen.js +310 -0
- package/lib/desired-caps.js +37 -0
- package/lib/driver.js +59 -62
- package/lib/logger.js +3 -2
- package/lib/safari.js +175 -0
- package/lib/server.js +7 -7
- package/lib/utils.js +13 -131
- package/package.json +46 -31
- package/test/functional/desktop-driver-e2e-specs.js +48 -0
- package/test/functional/mobile-driver-e2e-specs.js +73 -0
- package/test/unit/driver-specs.js +9 -0
- package/test/unit/utils-specs.js +43 -0
- package/test/utils.js +5 -0
- package/.jscsrc +0 -11
- package/.jshintrc +0 -11
- package/.npmignore +0 -2
- package/.travis.yml +0 -14
- package/build/lib/commands/alert.js +0 -134
- package/build/lib/commands/context.js +0 -1133
- package/build/lib/commands/element.js +0 -452
- package/build/lib/commands/execute.js +0 -198
- package/build/lib/commands/general.js +0 -362
- package/build/lib/commands/gesture.js +0 -851
- package/build/lib/commands/logging.js +0 -96
- package/build/lib/commands/navigation.js +0 -101
- package/build/lib/commands/orientation.js +0 -74
- package/build/lib/commands/safari.js +0 -99
- package/build/lib/commands/screenshot.js +0 -169
- package/build/lib/commands/web.js +0 -1125
- package/build/test/functional/driver-e2e-specs.js +0 -229
- package/build/test/unit/webdriveragent-specs.js +0 -17
- package/lib/commands/alert.js +0 -49
- package/lib/commands/context.js +0 -446
- package/lib/commands/element.js +0 -158
- package/lib/commands/execute.js +0 -83
- package/lib/commands/general.js +0 -143
- package/lib/commands/gesture.js +0 -402
- package/lib/commands/logging.js +0 -40
- package/lib/commands/navigation.js +0 -34
- package/lib/commands/orientation.js +0 -28
- package/lib/commands/safari.js +0 -55
- package/lib/commands/screenshot.js +0 -60
- package/lib/commands/web.js +0 -446
- package/test/.jshintrc +0 -22
- package/test/functional/driver-e2e-specs.js +0 -83
- package/test/instruments-auth.sh +0 -3
- package/test/unit/webdriveragent-specs.js +0 -9
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/macos/
|
|
2
|
+
variables:
|
|
3
|
+
VM_IMAGE: macOS-10.15
|
|
4
|
+
XCODE_VERSION: 12.1
|
|
5
|
+
PLATFORM_VERSION: 14.1
|
|
6
|
+
DEVICE_NAME: iPhone 11 Pro Max
|
|
7
|
+
DEFAULT_NODE_VERSION: "12.x"
|
|
8
|
+
|
|
9
|
+
pool:
|
|
10
|
+
vmImage: "$(VM_IMAGE)"
|
|
11
|
+
|
|
12
|
+
stages:
|
|
13
|
+
- stage: Unit_Tests_And_Linters
|
|
14
|
+
jobs:
|
|
15
|
+
- job: Node_Unit_Tests
|
|
16
|
+
steps:
|
|
17
|
+
- template: azure-templates/node_setup_steps.yml
|
|
18
|
+
- script: npm install
|
|
19
|
+
- script: npm run test
|
|
20
|
+
|
|
21
|
+
- stage: Integration_Tests
|
|
22
|
+
jobs:
|
|
23
|
+
- job: Node_Integration_Tests
|
|
24
|
+
variables:
|
|
25
|
+
CI: true
|
|
26
|
+
_FORCE_LOGS: 1
|
|
27
|
+
steps:
|
|
28
|
+
- template: azure-templates/node_setup_steps.yml
|
|
29
|
+
- script: npm install
|
|
30
|
+
- script: npm run e2e-test
|
package/.eslintignore
ADDED
package/.eslintrc
ADDED
package/LICENSE
CHANGED
|
@@ -1,13 +1,201 @@
|
|
|
1
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License.
|
|
5
|
-
You may obtain a copy of the License at
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
1. Definitions.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright JS Foundation and other contributors, https://js.foundation
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,22 +1,146 @@
|
|
|
1
1
|
appium-safari-driver
|
|
2
|
-
|
|
2
|
+
====
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
This is Appium driver for automating Safari on [Mac OS X](https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari?language=objc) and iOS [since version 13](https://webkit.org/blog/9395/webdriver-is-coming-to-safari-in-ios-13/).
|
|
5
|
+
The driver only supports Safari automation using [W3C WebDriver protocol](https://www.w3.org/TR/webdriver/).
|
|
6
|
+
Under the hood this driver is a wrapper/proxy over Apple's `safaridriver` binary. Check the output of `man safaridriver` command to get more details on the supported features and possible pitfalls.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
It didn't make much sense to add the simulator start/stop functionality to this driver since it's not quite a standalone driver but more for proxying to from other running drivers.
|
|
8
|
+
## Usage
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
It is mandatory to run the `safaridriver --enable` command from the Mac OS terminal and provide your administrator password before any automated session will be executed.
|
|
11
|
+
In order to automate Safari on real devices it is also necessary to enable Remote Automation switch in `Settings → Safari → Advanced → Remote Automation` for these particular devices.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
Then you need to decide where the automated test is going to be executed. Safari driver supports the following target platforms:
|
|
14
|
+
- Mac OS (High Sierra or newer)
|
|
15
|
+
- iOS Simulator (iOS version 13 or newer)
|
|
16
|
+
- iOS Real Device (iOS version 13 or newer)
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
Safari driver allows to define multiple criterions for platform selection and also to fine-tune your automation session properties. This could be done via the following session capabilities:
|
|
17
19
|
|
|
20
|
+
Capability Name | Description
|
|
21
|
+
--- | ---
|
|
22
|
+
platformName | safaridriver binary can only create WebDriver sessions for desktop or mobile Safari and can only run on Mac OS. Value of platformName could equal to 'Mac' or 'iOS' in order to start Safari driver session for the corresponding platform. Values of platformName are compared case-insensitively.
|
|
23
|
+
automationName | Value of automationName must equal to 'Safari' in order to start Safari driver session. Values of automationName are compared case-insensitively.
|
|
24
|
+
browserName | safaridriver can only create WebDriver sessions for Safari. Any value passed to this capability will be changed to 'Safari'.
|
|
25
|
+
browserVersion | safaridriver will only create a session using hosts whose Safari version matches the value of browserVersion. Browser version numbers are prefix-matched. For example, if the value of browserVersion is '12', this will allow hosts with a Safari version of '12.0.1' or '12.1'.
|
|
26
|
+
safari:platformVersion | safaridriver will only create a session using hosts whose OS version matches the value of safari:platformVersion. OS version numbers are prefix-matched. For example, if the value of safari:platformVersion is '12', this will allow hosts with an OS version of '12.0' or '12.1' but not '10.12'.
|
|
27
|
+
safari:platformBuildVersion | safaridriver will only create a session using hosts whose OS build version matches the value of safari:platformBuildVersion. example of a macOS build version is '18E193'. On macOS, the OS build version can be determined by running the sw_vers(1) utility.
|
|
28
|
+
safari:useSimulator | If the value of safari:useSimulator is true, safaridriver will only use iOS Simulator hosts. If the value of safari:useSimulator is false, safaridriver will not use iOS Simulator hosts. NOTE: An Xcode installation is required in order to run WebDriver tests on iOS Simulator hosts.
|
|
29
|
+
safari:deviceType | If the value of safari:deviceType is 'iPhone', safaridriver will only create a session using an iPhone device or iPhone simulator. If the value of safari:deviceType is 'iPad', safaridriver will only create a session using an iPad device or iPad simulator. Values of safari:deviceType are compared case-insensitively.
|
|
30
|
+
safari:deviceName | safaridriver will only create a session using hosts whose device name matches the value of safari:deviceName. Device names are compared case-insensitively. NOTE: Device names for connected devices are shown in iTunes. If Xcode is installed, device names for connected devices are available via the output of instruments(1) and in the Devices and Simulators window (accessed in Xcode via "Window > Devices and Simulators").
|
|
31
|
+
safari:deviceUDID | safaridriver will only create a session using hosts whose device UDID matches the value of safari:deviceUDID. Device UDIDs are compared case-insensitively. NOTE: If Xcode is installed, UDIDs for connected devices are available via the output of instruments(1) and in the Devices and Simulators window (accessed in Xcode via "Window > Devices and Simulators").
|
|
32
|
+
safari:automaticInspection | This capability instructs Safari to preload the Web Inspector and JavaScript debugger in the background prior to returning a newly-created window. To pause the test's execution in JavaScript and bring up Web Inspector's Debugger tab, you can simply evaluate a debugger; statement in the test page.
|
|
33
|
+
safari:automaticProfiling | This capability instructs Safari to preload the Web Inspector and start a Timeline recording in the background prior to returning a newly-created window. To view the recording, open the Web Inspector through Safari's Develop menu.
|
|
34
|
+
webkit:WebRTC | This capability allows a test to temporarily change Safari's policies for WebRTC and Media Capture. The value of the webkit:WebRTC capability is a dictionary with the following sub-keys, all of which are optional: `DisableInsecureMediaCapture` - Normally, Safari refuses to allow media capture over insecure connections. This restriction is relaxed by default for WebDriver sessions for testing purposes (for example, a test web server not configured for HTTPS). When this capability is specified, Safari will revert to the normal behavior of preventing media capture over insecure connections. `DisableICECandidateFiltering` - To protect a user's privacy, Safari normally filters out WebRTC ICE candidates that correspond to internal network addresses when capture devices are not in use. This capability suppresses ICE candidate filtering so that both internal and external network addresses are always sent as ICE candidates.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## Example
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
# Python3 + PyTest
|
|
41
|
+
import pytest
|
|
42
|
+
import time
|
|
43
|
+
|
|
44
|
+
from appium import webdriver
|
|
45
|
+
from selenium.webdriver.common.by import By
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def generate_caps():
|
|
49
|
+
common_caps = {
|
|
50
|
+
# It does not really matter what to put there, although setting 'Safari' might cause a failure
|
|
51
|
+
# depending on the particular client library
|
|
52
|
+
'browserName': 'AppiumSafari',
|
|
53
|
+
# automationName capability presence is mandatory for this Safari Driver to be selected
|
|
54
|
+
'automationName': 'Safari',
|
|
55
|
+
}
|
|
56
|
+
real_device_caps = {
|
|
57
|
+
**common_caps,
|
|
58
|
+
'platformName': 'iOS',
|
|
59
|
+
# This capability is optional
|
|
60
|
+
'safari:deviceType': 'iPhone',
|
|
61
|
+
# Do not forget to verify that Remote Automation is enabled for this device
|
|
62
|
+
'safari:deviceUDID': '<MyDeviceUDID>',
|
|
63
|
+
'safari:useSimulator': False,
|
|
64
|
+
}
|
|
65
|
+
simulator_caps = {
|
|
66
|
+
**common_caps,
|
|
67
|
+
'platformName': 'iOS',
|
|
68
|
+
'safari:platformVersion': '14.1',
|
|
69
|
+
'safari:deviceName': 'iPad Air 2',
|
|
70
|
+
'safari:useSimulator': True,
|
|
71
|
+
}
|
|
72
|
+
desktop_browser_caps = {
|
|
73
|
+
**common_caps,
|
|
74
|
+
'platformName': 'Mac',
|
|
75
|
+
}
|
|
76
|
+
return [real_device_caps, simulator_caps, desktop_browser_caps]
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@pytest.fixture(params=generate_caps())
|
|
80
|
+
def driver(request):
|
|
81
|
+
drv = webdriver.Remote('http://localhost:4723/wd/hub', request.param)
|
|
82
|
+
yield drv
|
|
83
|
+
drv.quit()
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class TimeoutError(Exception):
|
|
87
|
+
pass
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def wait_until_truthy(func, timeout_sec=5.0, interval_sec=0.5):
|
|
91
|
+
started = time.time()
|
|
92
|
+
original_error = None
|
|
93
|
+
while time.time() - started < timeout_sec:
|
|
94
|
+
original_error = None
|
|
95
|
+
try:
|
|
96
|
+
result = func()
|
|
97
|
+
if result:
|
|
98
|
+
return result
|
|
99
|
+
except Exception as e:
|
|
100
|
+
original_error = e
|
|
101
|
+
time.sleep(interval_sec)
|
|
102
|
+
if original_error is None:
|
|
103
|
+
raise TimeoutError(f'Condition unmet after {timeout_sec}s timeout')
|
|
104
|
+
raise original_error
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_feature_status_page_search(driver):
|
|
108
|
+
driver.get('https://webkit.org/status/')
|
|
109
|
+
|
|
110
|
+
# Enter "CSS" into the search box.
|
|
111
|
+
# Ensures that at least one result appears in search
|
|
112
|
+
# !!! Remember there are no ID and NAME locators in W3C standard
|
|
113
|
+
# These two have been superseded by CSS ones
|
|
114
|
+
search_box = driver.find_element_by_css('#search')
|
|
115
|
+
search_box.send_keys('CSS')
|
|
116
|
+
value = search_box.get_attribute('value')
|
|
117
|
+
assert len(value) > 0
|
|
118
|
+
search_box.submit()
|
|
119
|
+
# Count the visible results when filters are applied
|
|
120
|
+
# so one result shows up in at most one filter
|
|
121
|
+
assert wait_until_truthy(lambda: len(driver.execute_script("return document.querySelectorAll('li.feature:not(.is-hidden)')")) > 0)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def test_feature_status_page_filters(driver):
|
|
125
|
+
driver.get('https://webkit.org/status/')
|
|
126
|
+
|
|
127
|
+
assert wait_until_truthy(lambda: len(driver.execute_script("return document.querySelectorAll('.filter-toggle')")) == 7)
|
|
128
|
+
|
|
129
|
+
# Make sure every filter is turned off.
|
|
130
|
+
for checked_filter in filter(lambda f: f.is_selected(), filters):
|
|
131
|
+
checked_filter.click()
|
|
132
|
+
|
|
133
|
+
# Make sure you can select every filter.
|
|
134
|
+
for filt in filters:
|
|
135
|
+
filt.click()
|
|
136
|
+
assert filt.is_selected()
|
|
137
|
+
filt.click()
|
|
18
138
|
```
|
|
19
|
-
gulp once # unit tests
|
|
20
|
-
_FORCE_LOGS=1 gulp e2e-test # functional tests
|
|
21
|
-
```
|
|
22
139
|
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# clone repo, then in repo dir:
|
|
144
|
+
npm install
|
|
145
|
+
gulp watch
|
|
146
|
+
```
|
package/build/index.js
CHANGED
|
@@ -1,48 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default'];
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(exports, '__esModule', {
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
6
|
value: true
|
|
11
7
|
});
|
|
8
|
+
Object.defineProperty(exports, "SafariDriver", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _driver.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "startServer", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _server.startServer;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.default = void 0;
|
|
12
21
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _yargs2 = _interopRequireDefault(_yargs);
|
|
22
|
+
require("source-map-support/register");
|
|
16
23
|
|
|
17
|
-
var
|
|
24
|
+
var _driver = _interopRequireDefault(require("./lib/driver"));
|
|
18
25
|
|
|
19
|
-
var
|
|
26
|
+
var _server = require("./lib/server");
|
|
20
27
|
|
|
21
|
-
var
|
|
28
|
+
var _asyncbox = require("asyncbox");
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
const DEFAULT_HOST = 'localhost';
|
|
31
|
+
const DEFAULT_PORT = 4797;
|
|
25
32
|
|
|
26
|
-
function main() {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
port = _yargs2['default'].argv.port || DEFAULT_PORT;
|
|
32
|
-
host = _yargs2['default'].argv.host || DEFAULT_HOST;
|
|
33
|
-
return context$1$0.abrupt('return', (0, _libServer.startServer)(port, host));
|
|
33
|
+
async function main() {
|
|
34
|
+
const getArgValue = argName => {
|
|
35
|
+
const argIndex = process.argv.indexOf(argName);
|
|
36
|
+
return argIndex > 0 ? process.argv[argIndex + 1] : null;
|
|
37
|
+
};
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}, null, this);
|
|
39
|
+
const port = parseInt(getArgValue('--port'), 10) || DEFAULT_PORT;
|
|
40
|
+
const host = getArgValue('--host') || DEFAULT_HOST;
|
|
41
|
+
return await (0, _server.startServer)(port, host);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
if (require.main === module) {
|
|
43
45
|
(0, _asyncbox.asyncify)(main);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
exports
|
|
48
|
-
|
|
48
|
+
var _default = _driver.default;
|
|
49
|
+
exports.default = _default;require('source-map-support').install();
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbIkRFRkFVTFRfSE9TVCIsIkRFRkFVTFRfUE9SVCIsIm1haW4iLCJnZXRBcmdWYWx1ZSIsImFyZ05hbWUiLCJhcmdJbmRleCIsInByb2Nlc3MiLCJhcmd2IiwiaW5kZXhPZiIsInBvcnQiLCJwYXJzZUludCIsImhvc3QiLCJyZXF1aXJ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