Skip to content

Commit 0dc7e95

Browse files
committed
add screenshot command to api
1 parent 81361e1 commit 0dc7e95

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
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.56",
3+
"version": "4.0.0-alpha.57",
44
"private": true,
55
"description": "Selenium IDE electron app",
66
"author": "Todd <[email protected]>",
@@ -106,7 +106,7 @@
106106
"@seleniumhq/code-export-ruby-rspec": "^4.0.0-alpha.1",
107107
"side-code-export": "^4.0.0-alpha.11",
108108
"@seleniumhq/get-driver": "^4.0.0-alpha.1",
109-
"@seleniumhq/side-api": "^4.0.0-alpha.34",
109+
"@seleniumhq/side-api": "^4.0.0-alpha.35",
110110
"@seleniumhq/side-model": "^4.0.0-alpha.4",
111111
"@seleniumhq/side-runtime": "^4.0.0-alpha.31",
112112
"dnd-core": "^16.0.1",

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,10 @@ export default class DriverController extends BaseController {
151151
}
152152
return null
153153
}
154+
155+
async takeScreenshot(): Promise<string> {
156+
const driver = this.session.playback.playbacks?.[0]?.executor?.driver
157+
if (driver) return await driver.takeScreenshot()
158+
return ''
159+
}
154160
}

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.34",
3+
"version": "4.0.0-alpha.35",
44
"private": false,
55
"description": "Selenium IDE API command shapes and such",
66
"author": "Todd Tarsi <[email protected]>",

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ import type { Shape as ListBrowsers } from './listBrowsers'
33
import type { Shape as SelectBrowser } from './selectBrowser'
44
import type { Shape as StartProcess } from './startProcess'
55
import type { Shape as StopProcess } from './stopProcess'
6+
import type { Shape as TakeScreenshot } from './takeScreenshot'
67

78
import * as download from './download'
89
import * as listBrowsers from './listBrowsers'
910
import * as selectBrowser from './selectBrowser'
1011
import * as startProcess from './startProcess'
1112
import * as stopProcess from './stopProcess'
13+
import * as takeScreenshot from './takeScreenshot'
1214

1315
export const commands = {
1416
download,
1517
listBrowsers,
1618
selectBrowser,
1719
startProcess,
1820
stopProcess,
21+
takeScreenshot,
1922
}
2023

2124
/**
@@ -28,4 +31,5 @@ export type Shape = {
2831
selectBrowser: SelectBrowser
2932
startProcess: StartProcess
3033
stopProcess: StopProcess
34+
takeScreenshot: TakeScreenshot
3135
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Return a base64 encoded screenshot of the current window.
3+
*/
4+
export type Shape = () => Promise<string>

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)