Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
This is an Appium driver for automating the Safari browser on macOS, iOS and iPadOS.

> [!IMPORTANT]
> Since major version *4.0.0*, this driver is only compatible with Appium 3.
> Since major version *6.0.0*, this driver is only compatible with Appium 4.


## Documentation
Expand Down
3 changes: 2 additions & 1 deletion docs/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ and prerequisites of Appium itself can be found in [the Appium documentation](ht

| Safari driver version | Supported Appium server version |
| --- | --- |
| >= 4.0.0 | Appium 3 |
| >= 6.0.0 | Appium 4 |
| 4.0.0 - 5.0.11 | Appium 3 |
| 3.0.0 - 3.5.26 | Appium 2 |

## Installation
Expand Down
6 changes: 6 additions & 0 deletions lib/commands/cookies.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import type {SafariDriver} from '../driver.js';

declare module '../driver.js' {
interface SafariDriver {
deleteCookies(...args: Parameters<typeof deleteCookies>): ReturnType<typeof deleteCookies>;
}
}

/**
* Delete all cookies visible to the current page.
*
Expand Down
6 changes: 6 additions & 0 deletions lib/commands/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import {util} from 'appium/support.js';

import type {SafariDriver} from '../driver.js';

declare module '../driver.js' {
interface SafariDriver {
findElOrEls(...args: Parameters<typeof findElOrEls>): ReturnType<typeof findElOrEls>;
}
}

/**
* Find element(s) using the specified strategy and selector.
* This is needed to make lookup by image working.
Expand Down
7 changes: 7 additions & 0 deletions lib/commands/record-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import {util, fs, net, tempDir} from 'appium/support.js';
import type {SafariDriver} from '../driver.js';
import {parseRuntimeIdentifier} from '../utils.js';

declare module '../driver.js' {
interface SafariDriver {
startRecordingScreen(...args: Parameters<typeof startRecordingScreen>): ReturnType<typeof startRecordingScreen>;
stopRecordingScreen(...args: Parameters<typeof stopRecordingScreen>): ReturnType<typeof stopRecordingScreen>;
}
}

const DEFAULT_TIME_LIMIT_MS = 60 * 10 * 1000; // 10 minutes
const DEFAULT_EXT = '.mp4';

Expand Down
30 changes: 12 additions & 18 deletions lib/driver.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import type {
RouteMatcher,
DefaultCreateSessionResult,
DriverData,
InitialOpts,
StringRecord,
ExternalDriver,
W3CDriverCaps,
} from '@appium/types';
import {BaseDriver} from 'appium/driver.js';

import * as cookieCommands from './commands/cookies.js';
import * as findCommands from './commands/find.js';
import * as recordScreenCommands from './commands/record-screen.js';
import {deleteCookies} from './commands/cookies.js';
import {findElOrEls} from './commands/find.js';
import {startRecordingScreen, stopRecordingScreen, type ScreenRecorder} from './commands/record-screen.js';
import {desiredCapConstraints, type SafariConstraints} from './desired-caps.js';
import {newMethodMap} from './method-map.js';
import {SafariDriverServer} from './safari.js';
Expand All @@ -35,14 +34,7 @@ export class SafariDriver
static newMethodMap = newMethodMap;

proxyReqRes: ((...args: any[]) => any) | null = null;
_screenRecorder: recordScreenCommands.ScreenRecorder | null = null;

deleteCookies = cookieCommands.deleteCookies;

findElOrEls = findCommands.findElOrEls;

startRecordingScreen = recordScreenCommands.startRecordingScreen;
stopRecordingScreen = recordScreenCommands.stopRecordingScreen;
_screenRecorder: ScreenRecorder | null = null;

private isProxyActive = false;
private _safari: SafariDriverServer | null = null;
Expand Down Expand Up @@ -83,12 +75,9 @@ export class SafariDriver
}

override async createSession(
w3cCaps1: W3CSafariDriverCaps,
w3cCaps2?: W3CSafariDriverCaps,
w3cCaps3?: W3CSafariDriverCaps,
driverData?: DriverData[],
w3cCapabilities: W3CSafariDriverCaps,
): Promise<DefaultCreateSessionResult<SafariConstraints>> {
const [sessionId, caps] = await super.createSession(w3cCaps1, w3cCaps2, w3cCaps3, driverData);
const [sessionId, caps] = await super.createSession(w3cCapabilities);
this._safari = new SafariDriverServer(this.log);
try {
await this.safari.start(formatCapsForServer(caps), {
Expand Down Expand Up @@ -125,4 +114,9 @@ export class SafariDriver
}
}

export default SafariDriver;
Object.assign(SafariDriver.prototype, {
deleteCookies,
findElOrEls,
startRecordingScreen,
stopRecordingScreen,
});
5 changes: 1 addition & 4 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import {SafariDriver} from './driver.js';

export default SafariDriver;
export {SafariDriver};
export {SafariDriver} from './driver.js';
4 changes: 1 addition & 3 deletions lib/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {logger} from 'appium/support.js';

const log = logger.getLogger('Safari');

export default log;
export const log = logger.getLogger('Safari');
2 changes: 0 additions & 2 deletions lib/safari.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,3 @@ export class SafariDriverServer {
}
}
}

export default SafariDriverServer;
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@
"teen_process": "^4.0.4"
},
"devDependencies": {
"@appium/docutils": "^3.0.0",
"@appium/oxc-config": "^1.1.0",
"@appium/semantic-release-config": "^1.1.0",
"@appium/tsconfig": "^1.2.0",
"@appium/types": "^1.0.0-rc.1",
"@appium/docutils": "^4.0.0-beta.5",
"@appium/oxc-config": "^2.0.0-beta.2",
"@appium/semantic-release-config": "^2.0.0-beta.1",
"@appium/tsconfig": "^2.0.0-beta.1",
"@appium/types": "^2.0.0-beta.5",
"@types/node": "^26.0.0",
"@types/portscanner": "^2.1.4",
"webdriverio": "^9.0.5"
"webdriverio": "^10.1.0"
},
"peerDependencies": {
"appium": "^3.0.0-rc.2"
"appium": "^4.0.0-beta.6"
},
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
"node": "^22.22.2 || ^24.15.0 || >=26.0.0",
"npm": ">=10"
},
"appium": {
Expand Down
Loading