Skip to content

Commit

Permalink
add screenshot command to api
Browse files Browse the repository at this point in the history
  • Loading branch information
toddtarsi committed Nov 26, 2023
1 parent 81361e1 commit 0dc7e95
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/selenium-ide/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seleniumhq/selenium-ide",
"version": "4.0.0-alpha.56",
"version": "4.0.0-alpha.57",
"private": true,
"description": "Selenium IDE electron app",
"author": "Todd <[email protected]>",
Expand Down Expand Up @@ -106,7 +106,7 @@
"@seleniumhq/code-export-ruby-rspec": "^4.0.0-alpha.1",
"side-code-export": "^4.0.0-alpha.11",
"@seleniumhq/get-driver": "^4.0.0-alpha.1",
"@seleniumhq/side-api": "^4.0.0-alpha.34",
"@seleniumhq/side-api": "^4.0.0-alpha.35",
"@seleniumhq/side-model": "^4.0.0-alpha.4",
"@seleniumhq/side-runtime": "^4.0.0-alpha.31",
"dnd-core": "^16.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,10 @@ export default class DriverController extends BaseController {
}
return null
}

async takeScreenshot(): Promise<string> {
const driver = this.session.playback.playbacks?.[0]?.executor?.driver
if (driver) return await driver.takeScreenshot()
return ''
}
}
2 changes: 1 addition & 1 deletion packages/side-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@seleniumhq/side-api",
"version": "4.0.0-alpha.34",
"version": "4.0.0-alpha.35",
"private": false,
"description": "Selenium IDE API command shapes and such",
"author": "Todd Tarsi <[email protected]>",
Expand Down
4 changes: 4 additions & 0 deletions packages/side-api/src/commands/driver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ import type { Shape as ListBrowsers } from './listBrowsers'
import type { Shape as SelectBrowser } from './selectBrowser'
import type { Shape as StartProcess } from './startProcess'
import type { Shape as StopProcess } from './stopProcess'
import type { Shape as TakeScreenshot } from './takeScreenshot'

import * as download from './download'
import * as listBrowsers from './listBrowsers'
import * as selectBrowser from './selectBrowser'
import * as startProcess from './startProcess'
import * as stopProcess from './stopProcess'
import * as takeScreenshot from './takeScreenshot'

export const commands = {
download,
listBrowsers,
selectBrowser,
startProcess,
stopProcess,
takeScreenshot,
}

/**
Expand All @@ -28,4 +31,5 @@ export type Shape = {
selectBrowser: SelectBrowser
startProcess: StartProcess
stopProcess: StopProcess
takeScreenshot: TakeScreenshot
}
4 changes: 4 additions & 0 deletions packages/side-api/src/commands/driver/takeScreenshot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Return a base64 encoded screenshot of the current window.
*/
export type Shape = () => Promise<string>
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0dc7e95

Please sign in to comment.