feat(tool): add locator.selectOption() action (#25)
Implemented `locator.selectOption`
This commit is contained in:
@@ -48,6 +48,9 @@ test('test tool list', async ({ server }) => {
|
||||
expect.objectContaining({
|
||||
name: 'browser_type',
|
||||
}),
|
||||
expect.objectContaining({
|
||||
name: 'browser_select_option',
|
||||
}),
|
||||
expect.objectContaining({
|
||||
name: 'browser_press_key',
|
||||
}),
|
||||
@@ -227,3 +230,104 @@ test('test reopen browser', async ({ server }) => {
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
test.describe('test browser_select_option', () => {
|
||||
test('single option', async ({ server }) => {
|
||||
await server.send({
|
||||
jsonrpc: '2.0',
|
||||
id: 2,
|
||||
method: 'tools/call',
|
||||
params: {
|
||||
name: 'browser_navigate',
|
||||
arguments: {
|
||||
url: 'data:text/html,<html><title>Title</title><select><option value="foo">Foo</option><option value="bar">Bar</option></select></html>',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await server.send({
|
||||
jsonrpc: '2.0',
|
||||
id: 3,
|
||||
method: 'tools/call',
|
||||
params: {
|
||||
name: 'browser_select_option',
|
||||
arguments: {
|
||||
element: 'Select',
|
||||
ref: 's1e4',
|
||||
values: ['bar'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(response).toEqual(expect.objectContaining({
|
||||
id: 3,
|
||||
result: {
|
||||
content: [{
|
||||
type: 'text',
|
||||
text: `Selected option in \"Select\"
|
||||
|
||||
- Page URL: data:text/html,<html><title>Title</title><select><option value="foo">Foo</option><option value="bar">Bar</option></select></html>
|
||||
- Page Title: Title
|
||||
- Page Snapshot
|
||||
\`\`\`yaml
|
||||
- document [ref=s2e2]:
|
||||
- combobox [ref=s2e4]:
|
||||
- option \"Foo\" [ref=s2e5]
|
||||
- option \"Bar\" [selected] [ref=s2e6]
|
||||
\`\`\`
|
||||
`,
|
||||
}],
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
test('multiple option', async ({ server }) => {
|
||||
await server.send({
|
||||
jsonrpc: '2.0',
|
||||
id: 2,
|
||||
method: 'tools/call',
|
||||
params: {
|
||||
name: 'browser_navigate',
|
||||
arguments: {
|
||||
url: 'data:text/html,<html><title>Title</title><select multiple><option value="foo">Foo</option><option value="bar">Bar</option><option value="baz">Baz</option></select></html>',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = await server.send({
|
||||
jsonrpc: '2.0',
|
||||
id: 3,
|
||||
method: 'tools/call',
|
||||
params: {
|
||||
name: 'browser_select_option',
|
||||
arguments: {
|
||||
element: 'Select',
|
||||
ref: 's1e4',
|
||||
values: ['bar', 'baz'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(response).toEqual(expect.objectContaining({
|
||||
id: 3,
|
||||
result: {
|
||||
content: [{
|
||||
type: 'text',
|
||||
text: `Selected option in \"Select\"
|
||||
|
||||
- Page URL: data:text/html,<html><title>Title</title><select multiple><option value="foo">Foo</option><option value="bar">Bar</option><option value="baz">Baz</option></select></html>
|
||||
- Page Title: Title
|
||||
- Page Snapshot
|
||||
\`\`\`yaml
|
||||
- document [ref=s2e2]:
|
||||
- listbox [ref=s2e4]:
|
||||
- option \"Foo\" [ref=s2e5]
|
||||
- option \"Bar\" [selected] [ref=s2e6]
|
||||
- option \"Baz\" [selected] [ref=s2e7]
|
||||
\`\`\`
|
||||
`,
|
||||
}],
|
||||
},
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user