Skip to content

Commit b3239f4

Browse files
Samiya CaurDevtools-frontend LUCI CQ
Samiya Caur
authored and
Devtools-frontend LUCI CQ
committed
Add new test target for multimodal support for Elements entrypoint
Bug: 407692633 Change-Id: I573bcb707485eb46c6eb30906910e397ebc3665e Fixed: 407692633 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6438591 Auto-Submit: Samiya Caur <samiyac@chromium.org> Reviewed-by: Ergün Erdoğmuş <ergunsh@chromium.org> Commit-Queue: Ergün Erdoğmuş <ergunsh@chromium.org>
1 parent 29ec4fd commit b3239f4

File tree

3 files changed

+35
-28
lines changed

3 files changed

+35
-28
lines changed

scripts/ai_assistance/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ node scripts/ai_assistance/auto-run.js --label title-change --example-urls <exam
3737
## `--test-target` values
3838

3939
* `elements`: tests the entrypoint via right clicking on an element in the Elements panel.
40+
* `elements-multimodal`: tests the multimodal support for Elements entrypoint by providing screenshot input with the prompt.
4041
* `performance-main-thread`: tests the entrypoint via right clicking on an event in the Performance panel main thread.
4142
* `performance-insights`: tests the entrypoint via the "Ask AI" button shown on an individual Insight in the Performance panel sidebar.
4243

scripts/ai_assistance/auto-run.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,33 @@ function formatElapsedTime() {
2121
return `${numberFormatter.format((performance.now() - startTime) / 1000)}s`;
2222
}
2323

24-
const yargsInput = yargs(hideBin(process.argv))
25-
.option('example-urls', {
26-
string: true,
27-
type: 'array',
28-
demandOption: true,
29-
})
30-
.option('parallel', {
31-
boolean: true,
32-
default: true,
33-
})
34-
.option('times', {
35-
describe: 'How many times do you want to run an example?',
36-
number: true,
37-
default: 1,
38-
})
39-
.option('label', {string: true, default: 'run'})
40-
.option('include-follow-up', {
41-
boolean: true,
42-
default: false,
43-
})
44-
.option('test-target', {
45-
describe: 'Which panel do you want to run the examples against?',
46-
choices: ['elements', 'performance-main-thread', 'performance-insights'],
47-
demandOption: true,
48-
})
49-
.parseSync();
24+
const yargsInput =
25+
yargs(hideBin(process.argv))
26+
.option('example-urls', {
27+
string: true,
28+
type: 'array',
29+
demandOption: true,
30+
})
31+
.option('parallel', {
32+
boolean: true,
33+
default: true,
34+
})
35+
.option('times', {
36+
describe: 'How many times do you want to run an example?',
37+
number: true,
38+
default: 1,
39+
})
40+
.option('label', {string: true, default: 'run'})
41+
.option('include-follow-up', {
42+
boolean: true,
43+
default: false,
44+
})
45+
.option('test-target', {
46+
describe: 'Which panel do you want to run the examples against?',
47+
choices: ['elements', 'performance-main-thread', 'performance-insights', 'elements-multimodal'],
48+
demandOption: true,
49+
})
50+
.parseSync();
5051

5152
// Map the args to a more accurate interface for better type safety.
5253
const userArgs = /** @type {import('./types.d.ts').YargsInput} **/ (yargsInput);
@@ -409,7 +410,7 @@ class Example {
409410
await devtoolsPage.keyboard.press('Escape');
410411
await devtoolsPage.keyboard.press('Escape');
411412

412-
if (userArgs.testTarget === 'elements') {
413+
if (userArgs.testTarget === 'elements' || userArgs.testTarget === 'elements-multimodal') {
413414
await devtoolsPage.locator(':scope >>> #tab-elements').setTimeout(5000).click();
414415
this.log('[Info]: Opened Elements panel');
415416

@@ -513,6 +514,7 @@ class Example {
513514
#getLocator() {
514515
switch (userArgs.testTarget) {
515516
case 'elements':
517+
case 'elements-multimodal':
516518
return 'aria/Ask a question about the selected element';
517519
case 'performance-main-thread':
518520
return 'aria/Ask a question about the selected item and its call tree';
@@ -551,6 +553,10 @@ class Example {
551553
}
552554
const devtoolsPage = this.#devtoolsPage;
553555

556+
if (userArgs.testTarget === 'elements-multimodal') {
557+
await devtoolsPage.locator('aria/Take screenshot').click();
558+
}
559+
554560
const inputSelector = this.#getLocator();
555561
await devtoolsPage.locator(inputSelector).click();
556562
await devtoolsPage.locator(inputSelector).fill(query);

scripts/ai_assistance/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface YargsInput {
5050
times: number;
5151
testTarget: TestTarget;
5252
}
53-
export type TestTarget = 'elements'|'performance-main-thread'|'performance-insights';
53+
export type TestTarget = 'elements'|'performance-main-thread'|'performance-insights'|'elements-multimodal';
5454

5555
// Clang cannot handle the Record<> syntax over multiple lines, it seems.
5656
/* clang-format off */

0 commit comments

Comments
 (0)