Skip to content

Commit f09c103

Browse files
committed
adding api endpoint for performing command
1 parent 810ff2b commit f09c103

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

packages/selenium-ide/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/selenium-ide",
3-
"version": "4.0.0-alpha.58",
3+
"version": "4.0.0-alpha.59",
44
"private": true,
55
"description": "Selenium IDE electron app",
66
"author": "Todd <[email protected]>",
@@ -105,7 +105,7 @@
105105
"@seleniumhq/code-export-python-pytest": "^4.0.0-alpha.2",
106106
"@seleniumhq/code-export-ruby-rspec": "^4.0.0-alpha.1",
107107
"@seleniumhq/get-driver": "^4.0.0-alpha.1",
108-
"@seleniumhq/side-api": "^4.0.0-alpha.36",
108+
"@seleniumhq/side-api": "^4.0.0-alpha.37",
109109
"@seleniumhq/side-model": "^4.0.0-alpha.4",
110110
"@seleniumhq/side-runtime": "^4.0.0-alpha.31",
111111
"dnd-core": "^16.0.1",

packages/selenium-ide/src/main/session/controllers/Playback/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { CommandShape, hasID } from '@seleniumhq/side-api'
12
import {
23
Playback,
34
PlaybackEvents,
45
PlaybackEventShapes,
56
Variables,
67
} from '@seleniumhq/side-runtime'
78
import { WebDriverExecutorHooks } from '@seleniumhq/side-runtime/src/webdriver'
8-
import { hasID } from '@seleniumhq/side-api/dist/helpers/hasID'
99
import { randomUUID } from 'crypto'
1010
import { session } from 'electron'
1111
import { Session } from 'main/types'
@@ -95,6 +95,23 @@ export default class PlaybackController extends BaseController {
9595
this.playbacks.forEach((playback) => playback.pause())
9696
}
9797

98+
async performCommand(
99+
command: Omit<CommandShape, 'id'>
100+
) {
101+
const playback = new Playback({
102+
baseUrl: this.session.projects.project.url,
103+
executor: await this.session.driver.build({}),
104+
getTestByName: (name: string) => this.session.tests.getByName(name),
105+
logger: console,
106+
variables: new Variables(),
107+
options: {
108+
delay: this.session.projects.project.delay || 0,
109+
},
110+
})
111+
await playback.playSingleCommand({ ...command, id: '-1' })
112+
await playback.cleanup()
113+
}
114+
98115
async stop() {
99116
if (this.isPlaying) {
100117
await this.pause()

packages/side-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/side-api",
3-
"version": "4.0.0-alpha.36",
3+
"version": "4.0.0-alpha.37",
44
"private": false,
55
"description": "Selenium IDE API command shapes and such",
66
"author": "Todd Tarsi <[email protected]>",

packages/side-api/src/commands/playback/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Shape as OnBeforeAll } from './onBeforeAll'
55
import type { Shape as OnPlayUpdate } from './onPlayUpdate'
66
import type { Shape as OnStepUpdate } from './onStepUpdate'
77
import type { Shape as Pause } from './pause'
8+
import type { Shape as PerformCommand } from './performCommand'
89
import type { Shape as Play } from './play'
910
import type { Shape as PlaySuite } from './playSuite'
1011
import type { Shape as Resume } from './resume'
@@ -17,6 +18,7 @@ import * as onBeforeAll from './onBeforeAll'
1718
import * as onPlayUpdate from './onPlayUpdate'
1819
import * as onStepUpdate from './onStepUpdate'
1920
import * as pause from './pause'
21+
import * as performCommand from './performCommand'
2022
import * as play from './play'
2123
import * as playSuite from './playSuite'
2224
import * as resume from './resume'
@@ -30,6 +32,7 @@ export const commands = {
3032
onPlayUpdate,
3133
onStepUpdate,
3234
pause,
35+
performCommand,
3336
play,
3437
playSuite,
3538
resume,
@@ -47,6 +50,7 @@ export type Shape = {
4750
onPlayUpdate: OnPlayUpdate
4851
onStepUpdate: OnStepUpdate
4952
pause: Pause
53+
performCommand: PerformCommand
5054
play: Play
5155
playSuite: PlaySuite
5256
resume: Resume
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { CommandShape } from '@seleniumhq/side-model'
2+
3+
/**
4+
* Attempts to execute a command supplied via API directly
5+
*/
6+
export type Shape = (cmd: Omit<CommandShape, 'id'>) => Promise<boolean>

packages/side-example-suite/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/side-example-suite",
3-
"version": "4.0.0-alpha.4",
3+
"version": "4.0.0-alpha.5",
44
"private": true,
55
"description": "Selenium IDE example suite, with tests, plugin, and export format",
66
"author": "Todd <[email protected]>",
@@ -21,7 +21,7 @@
2121
"@seleniumhq/code-export-python-pytest": "4.0.0-alpha.2"
2222
},
2323
"devDependencies": {
24-
"@seleniumhq/side-api": "^4.0.0-alpha.33"
24+
"@seleniumhq/side-api": "^4.0.0-alpha.37"
2525
},
2626
"repository": {
2727
"type": "git",

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)