Skip to content

Commit 20197c6

Browse files
committed
Add ability for e2e screenshots
1 parent 6131671 commit 20197c6

6 files changed

Lines changed: 375 additions & 5 deletions

File tree

packages/@react-native-windows/automation-commands/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
*/
77

88
import dumpVisualTree from './dumpVisualTree';
9+
import createScreenshot from './screenshot';
910

10-
export {dumpVisualTree};
11+
export { dumpVisualTree, createScreenshot };
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
4+
*
5+
* @format
6+
*/
7+
8+
// import { AutomationClient } from '@react-native-windows/automation-channel';
9+
10+
// declare global {
11+
// const automationClient: AutomationClient | undefined;
12+
// }
13+
14+
/**
15+
* Dump a section of the native visual tree.
16+
*/
17+
export default async function createScreenshot(
18+
opts?: {
19+
accessibilityId: string,
20+
location?: { x: number, y: number, width: number, height: number };
21+
},
22+
): Promise<void> {
23+
if (!automationClient) {
24+
throw new Error('RPC client is not enabled');
25+
}
26+
27+
const dumpResponse = await automationClient.invoke('CreateScreenshot', {
28+
...opts,
29+
});
30+
31+
if (dumpResponse.type === 'error') {
32+
throw new Error(dumpResponse.message);
33+
}
34+
}

packages/e2e-test-app-fabric/windows/RNTesterApp-Fabric.Package/Package.appxmanifest

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22

33
<Package
44
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
55
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
66
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
7-
IgnorableNamespaces="uap rescap">
7+
xmlns:uap6="http://schemas.microsoft.com/appx/manifest/uap/windows10/6"
8+
xmlns:uap11="http://schemas.microsoft.com/appx/manifest/uap/windows10/11"
9+
IgnorableNamespaces="uap rescap uap6 uap11">
810

911
<Identity
1012
Name="RNTesterApp-Fabric"
@@ -45,5 +47,6 @@
4547
<Capabilities>
4648
<Capability Name="internetClient" />
4749
<rescap:Capability Name="runFullTrust" />
50+
<uap11:Capability Name="graphicsCaptureProgrammatic"/>
4851
</Capabilities>
4952
</Package>

0 commit comments

Comments
 (0)