Repository navigation
feat: add currentDisplayId setting for screenshots #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mykola-mokhnach
merged 5 commits into
appium:master
from
jsteinberg7:codex/multi-display-screenshots-actions
Sep 29, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ce34bf2
feat: add currentDisplayId setting for screenshots
jsteinberg7 d8cf1b8
chore: remove boolean check from currentDisplayId validation
jsteinberg7 4f152bc
fix: validate display settings and report available ids
jsteinberg7 e1b1bda
test: fix available-display assertion syntax
jsteinberg7 5729caa
Merge branch 'master' into codex/multi-display-screenshots-actions
KazuCocoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import assert from 'node:assert/strict'; | ||
|
|
||
| /** Exercise the currentDisplayId setting against a live WDA session. */ | ||
| export async function assertCurrentDisplayIdSetting(baseUrl: string, sessionId: string): Promise<void> { | ||
| const screensResponse = await fetch(`${baseUrl}/wda/screens`); | ||
| assert.equal(screensResponse.status, 200); | ||
| const {value: screens} = (await screensResponse.json()) as { | ||
| value: {displayId: number; isMain: boolean}[]; | ||
| }; | ||
| const main = screens.find((screen) => screen.isMain); | ||
| assert.ok(main, 'expected a main display'); | ||
| const sessionUrl = `${baseUrl}/session/${sessionId}`; | ||
| const setDisplay = async (value: unknown) => | ||
| await fetch(`${sessionUrl}/appium/settings`, { | ||
| method: 'POST', | ||
| headers: {'Content-Type': 'application/json'}, | ||
| body: JSON.stringify({settings: {currentDisplayId: value}}), | ||
| }); | ||
| const getDisplay = async () => { | ||
| const response = await fetch(`${sessionUrl}/appium/settings`); | ||
| assert.equal(response.status, 200); | ||
| return ((await response.json()) as {value: {currentDisplayId: number}}).value.currentDisplayId; | ||
| }; | ||
| const assertScreenshot = async () => { | ||
| const response = await fetch(`${sessionUrl}/screenshot`); | ||
| assert.equal(response.status, 200); | ||
| const {value} = (await response.json()) as {value: string}; | ||
| assert.ok(Buffer.from(value, 'base64').length > 0, 'expected screenshot data'); | ||
| }; | ||
|
|
||
| assert.equal(await getDisplay(), main.displayId); | ||
| assert.equal((await setDisplay(main.displayId)).status, 200); | ||
| assert.equal(await getDisplay(), main.displayId); | ||
| await assertScreenshot(); | ||
|
|
||
| const unknownId = Math.max(...screens.map((screen) => screen.displayId)) + 1; | ||
| for (const value of [true, false, unknownId, 1.5, '1']) { | ||
| const response = await setDisplay(value); | ||
| assert.equal(response.status, 400, `expected invalid argument for ${JSON.stringify(value)}`); | ||
| const {value: body} = (await response.json()) as {value: {error: string}}; | ||
| assert.equal(body.error, 'invalid argument'); | ||
| assert.equal(await getDisplay(), main.displayId, 'invalid input must not change the display'); | ||
| } | ||
| assert.equal(await getDisplay(), main.displayId); | ||
|
|
||
| assert.equal((await setDisplay(null)).status, 200); | ||
| assert.equal(await getDisplay(), main.displayId); | ||
| await assertScreenshot(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON booleans deserialize as NSNumber, so true and false pass this check as 1 and 0. If that display exists, the request changes the selected display instead of returning invalid argument. Restore the boolean guard removed in the latest commit and retain boolean rejection tests.