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
3 changes: 3 additions & 0 deletions lib/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ export class XCUITestDriver
): Promise<DefaultCreateSessionResult<XCUITestDriverConstraints>> {
try {
const [sessionId, initialCaps] = await super.createSession(w3cCapabilities);
// BaseDriver assigns initial timeout capabilities directly, bypassing our setters.
// Sync the value used by the remote debugger before starting the backend.
this.setPageLoadTimeout(this.pageLoadTimeoutMs);
let caps = initialCaps;

// merge cli args to opts, and if we did merge any, revalidate opts to ensure the final set
Expand Down
33 changes: 33 additions & 0 deletions test/unit/commands/timeouts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,37 @@ describe('timeouts commands', function () {
assert.strictEqual(timeouts.implicit, driver.implicitWaitMs);
});
});

describe('initial page-load timeout capability', function () {
for (const [pageLoad, effectiveTimeout] of [
[45000, 45000],
[0, 0],
[null, 3600000],
[Number.MAX_SAFE_INTEGER, 3600000],
[undefined, 6000],
] as const) {
it(`applies ${String(pageLoad)} before backend startup`, async function (t) {
// Keep the real BaseDriver capability handling, replacing only device/session setup.
t.mock.method(driver as any, 'start', async () => {
assert.strictEqual(driver.pageLoadMs, effectiveTimeout);
});
t.mock.method(driver as any, 'setupSessionSettings', async () => {});
t.mock.method(driver.deviceConnectionsFactory, 'requestConnection', async () => {});
(driver as any)._device = {getWebInspectorSocket: async () => undefined};

await driver.createSession({
alwaysMatch: {
platformName: 'iOS',
'appium:automationName': 'XCUITest',
'appium:platformVersion': '18.0',
...(pageLoad === undefined ? {} : {timeouts: {pageLoad}}),
},
firstMatch: [{}],
});

assert.strictEqual((await driver.getTimeouts()).pageLoad, pageLoad === undefined ? 6000 : pageLoad);
assert.strictEqual((await driver.getNewRemoteDebugger()).pageLoadMs, effectiveTimeout);
});
}
});
});
Loading