Skip to content

Commit

Permalink
feat: add acceptInsecureCerts as safaridriver 15.4+ have it (#63)
Browse files Browse the repository at this point in the history
* feat: add acceptInsecureCerts as safaridriver 15.4+ have it

* Update README.md

* fix: allow to pass standard caps, update readme

* fix typo
  • Loading branch information
KazuCocoa authored Jul 14, 2023
1 parent 0755249 commit 0bf746a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Under the hood this driver is a wrapper/proxy over Apple's `safaridriver` binary

> **Note**
>
> Since version 3.0.0 Safari driver has dropped the support of Appium 1, and is only compatible to Appium 2. Use the `appium driver install safari`
> Since version 3.0.0 Safari driver has dropped the support of Appium 1, and is only compatible to Appium 2. Use the `appium driver install safari`
> command to add it to your Appium 2 dist.

Expand All @@ -34,6 +34,7 @@ platformName | safaridriver binary can only create WebDriver sessions for deskto
automationName | Value of automationName must equal to 'Safari' in order to start Safari driver session. Values of automationName are compared case-insensitively.
browserName | safaridriver can only create WebDriver sessions for Safari. Any value passed to this capability will be changed to 'Safari'.
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'.
acceptInsecureCerts | Makes the browser to ignore the appropriate security warning and thus allows navigation to web sites having invalid or expired TLS certificates. The capability is supported since safaridriver v15.4.
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'.
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.
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.
Expand Down Expand Up @@ -153,4 +154,3 @@ npm install
npm run lint
npm run test
```

3 changes: 3 additions & 0 deletions lib/desired-caps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const desiredCapConstraints = {
browserVersion: {
isString: true
},
acceptInsecureCerts: {
isBoolean: true
},
'safari:platformVersion': {
isString: true
},
Expand Down
3 changes: 3 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { STANDARD_CAPS } from 'appium/driver';
import _ from 'lodash';

const SAFARI_CAP_PREFIXES = ['safari:', 'webkit:'];
Expand All @@ -11,6 +12,8 @@ function formatCapsForServer (caps) {
for (const [name, value] of _.toPairs(caps)) {
if (SAFARI_CAP_PREFIXES.some((prefix) => name.startsWith(prefix))) {
result[name] = value;
} else if (!_.has(result, name) && STANDARD_CAPS.has(name)) {
result[name] = value;
}
}
return result;
Expand Down
4 changes: 3 additions & 1 deletion test/unit/utils-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ describe('formatCapsForServer', function () {
});
});

it('should only pass caps with supported prefixes', function () {
it('should only pass caps with supported prefixes and standard caps', function () {
const result = formatCapsForServer({
'safari:deviceUDID': '1234',
'webkit:yolo': '567',
'appium:bar': '789',
'acceptInsecureCerts': true
});
result.should.eql({
browserName: 'Safari',
browserVersion: undefined,
platformName: 'iOS',
'safari:deviceUDID': '1234',
'webkit:yolo': '567',
'acceptInsecureCerts': true
});
});
});

0 comments on commit 0bf746a

Please sign in to comment.