diff --git a/packages/selenium-ide/package.json b/packages/selenium-ide/package.json index 23b559e4d..f4c591cfb 100644 --- a/packages/selenium-ide/package.json +++ b/packages/selenium-ide/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/selenium-ide", - "version": "4.0.0-alpha.58", + "version": "4.0.0-alpha.59", "private": true, "description": "Selenium IDE electron app", "author": "Todd ", @@ -105,7 +105,7 @@ "@seleniumhq/code-export-python-pytest": "^4.0.0-alpha.2", "@seleniumhq/code-export-ruby-rspec": "^4.0.0-alpha.1", "@seleniumhq/get-driver": "^4.0.0-alpha.1", - "@seleniumhq/side-api": "^4.0.0-alpha.36", + "@seleniumhq/side-api": "^4.0.0-alpha.37", "@seleniumhq/side-model": "^4.0.0-alpha.4", "@seleniumhq/side-runtime": "^4.0.0-alpha.31", "dnd-core": "^16.0.1", diff --git a/packages/selenium-ide/src/main/session/controllers/Playback/index.ts b/packages/selenium-ide/src/main/session/controllers/Playback/index.ts index 7c768795a..74866899f 100644 --- a/packages/selenium-ide/src/main/session/controllers/Playback/index.ts +++ b/packages/selenium-ide/src/main/session/controllers/Playback/index.ts @@ -1,3 +1,4 @@ +import { CommandShape, hasID } from '@seleniumhq/side-api' import { Playback, PlaybackEvents, @@ -5,7 +6,6 @@ import { Variables, } from '@seleniumhq/side-runtime' import { WebDriverExecutorHooks } from '@seleniumhq/side-runtime/src/webdriver' -import { hasID } from '@seleniumhq/side-api/dist/helpers/hasID' import { randomUUID } from 'crypto' import { session } from 'electron' import { Session } from 'main/types' @@ -95,6 +95,23 @@ export default class PlaybackController extends BaseController { this.playbacks.forEach((playback) => playback.pause()) } + async performCommand( + command: Omit + ) { + const playback = new Playback({ + baseUrl: this.session.projects.project.url, + executor: await this.session.driver.build({}), + getTestByName: (name: string) => this.session.tests.getByName(name), + logger: console, + variables: new Variables(), + options: { + delay: this.session.projects.project.delay || 0, + }, + }) + await playback.playSingleCommand({ ...command, id: '-1' }) + await playback.cleanup() + } + async stop() { if (this.isPlaying) { await this.pause() diff --git a/packages/side-api/package.json b/packages/side-api/package.json index e0c32ce76..437d68d9e 100644 --- a/packages/side-api/package.json +++ b/packages/side-api/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-api", - "version": "4.0.0-alpha.36", + "version": "4.0.0-alpha.37", "private": false, "description": "Selenium IDE API command shapes and such", "author": "Todd Tarsi ", diff --git a/packages/side-api/src/commands/playback/index.ts b/packages/side-api/src/commands/playback/index.ts index c99a07560..ff1ce2a6f 100644 --- a/packages/side-api/src/commands/playback/index.ts +++ b/packages/side-api/src/commands/playback/index.ts @@ -5,6 +5,7 @@ import type { Shape as OnBeforeAll } from './onBeforeAll' import type { Shape as OnPlayUpdate } from './onPlayUpdate' import type { Shape as OnStepUpdate } from './onStepUpdate' import type { Shape as Pause } from './pause' +import type { Shape as PerformCommand } from './performCommand' import type { Shape as Play } from './play' import type { Shape as PlaySuite } from './playSuite' import type { Shape as Resume } from './resume' @@ -17,6 +18,7 @@ import * as onBeforeAll from './onBeforeAll' import * as onPlayUpdate from './onPlayUpdate' import * as onStepUpdate from './onStepUpdate' import * as pause from './pause' +import * as performCommand from './performCommand' import * as play from './play' import * as playSuite from './playSuite' import * as resume from './resume' @@ -30,6 +32,7 @@ export const commands = { onPlayUpdate, onStepUpdate, pause, + performCommand, play, playSuite, resume, @@ -47,6 +50,7 @@ export type Shape = { onPlayUpdate: OnPlayUpdate onStepUpdate: OnStepUpdate pause: Pause + performCommand: PerformCommand play: Play playSuite: PlaySuite resume: Resume diff --git a/packages/side-api/src/commands/playback/performCommand.ts b/packages/side-api/src/commands/playback/performCommand.ts new file mode 100644 index 000000000..ca965a7dc --- /dev/null +++ b/packages/side-api/src/commands/playback/performCommand.ts @@ -0,0 +1,6 @@ +import { CommandShape } from '@seleniumhq/side-model' + +/** + * Attempts to execute a command supplied via API directly + */ +export type Shape = (cmd: Omit) => Promise diff --git a/packages/side-example-suite/package.json b/packages/side-example-suite/package.json index ba1e6d6ff..d90c82e92 100644 --- a/packages/side-example-suite/package.json +++ b/packages/side-example-suite/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-example-suite", - "version": "4.0.0-alpha.4", + "version": "4.0.0-alpha.5", "private": true, "description": "Selenium IDE example suite, with tests, plugin, and export format", "author": "Todd ", @@ -21,7 +21,7 @@ "@seleniumhq/code-export-python-pytest": "4.0.0-alpha.2" }, "devDependencies": { - "@seleniumhq/side-api": "^4.0.0-alpha.33" + "@seleniumhq/side-api": "^4.0.0-alpha.37" }, "repository": { "type": "git", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a3e392e0..16ae36db3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -270,7 +270,7 @@ importers: specifier: ^4.0.0-alpha.1 version: link:../get-driver '@seleniumhq/side-api': - specifier: ^4.0.0-alpha.36 + specifier: ^4.0.0-alpha.37 version: link:../side-api '@seleniumhq/side-model': specifier: ^4.0.0-alpha.4 @@ -480,7 +480,7 @@ importers: version: link:../side-code-export devDependencies: '@seleniumhq/side-api': - specifier: ^4.0.0-alpha.33 + specifier: ^4.0.0-alpha.37 version: link:../side-api packages/side-migrate: