Skip to content

Commit eebfd0a

Browse files
committed
fixing recording
1 parent 5069c85 commit eebfd0a

File tree

9 files changed

+38
-24
lines changed

9 files changed

+38
-24
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.41",
3+
"version": "4.0.0-alpha.42",
44
"private": true,
55
"description": "Selenium IDE electron app",
66
"author": "Todd <[email protected]>",
@@ -107,7 +107,7 @@
107107
"@seleniumhq/code-export-ruby-rspec": "^4.0.0-alpha.1",
108108
"side-code-export": "^4.0.0-alpha.10",
109109
"@seleniumhq/get-driver": "^4.0.0-alpha.1",
110-
"@seleniumhq/side-api": "^4.0.0-alpha.24",
110+
"@seleniumhq/side-api": "^4.0.0-alpha.25",
111111
"@seleniumhq/side-model": "^4.0.0-alpha.4",
112112
"@seleniumhq/side-runtime": "^4.0.0-alpha.25",
113113
"dnd-core": "16.0.1",

packages/selenium-ide/src/browser/windows/PlaybackWindow/preload.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ import api from 'browser/api'
1818
import apiMutators from 'browser/api/mutator'
1919
import { contextBridge, ipcRenderer, webFrame } from 'electron'
2020
import { identity } from 'lodash/fp'
21-
import path from 'path'
2221
import Recorder from './preload/recorder'
2322

24-
const pluginFromPath = (pluginPath: string) => {
25-
const actualPluginPath = __non_webpack_require__.resolve(pluginPath)
26-
const preloadPath = path.join(actualPluginPath, '..', 'preload', 'index.js')
23+
const pluginFromPath = ([pluginPath, preloadPath]: [string, string]) => {
2724
try {
2825
const pluginPreload = __non_webpack_require__(preloadPath)
2926
const pluginHandler =
@@ -43,7 +40,6 @@ const pluginFromPath = (pluginPath: string) => {
4340
* Expose it in the main context
4441
*/
4542
window.addEventListener('DOMContentLoaded', async () => {
46-
contextBridge.exposeInMainWorld('sideAPI', true)
4743
webFrame.executeJavaScript(`
4844
Object.defineProperty(navigator, 'webdriver', {
4945
get () {
@@ -57,7 +53,11 @@ window.addEventListener('DOMContentLoaded', async () => {
5753
mutators: { recorder: apiMutators.recorder },
5854
}
5955
const pluginPaths = await api.plugins.list()
60-
const plugins = pluginPaths.map(pluginFromPath).filter(identity)
56+
const preloadPaths = await api.plugins.listPreloadPaths()
57+
const richPlugins: [string, string][] = pluginPaths.map((p, i) => [p, preloadPaths[i]])
58+
const plugins = richPlugins.map(pluginFromPath).filter(identity)
59+
60+
contextBridge.exposeInMainWorld('sideAPI', window.sideAPI)
6161
setTimeout(async () => {
6262
console.debug('Initializing the recorder')
6363
new Recorder(window, plugins)

packages/selenium-ide/src/main/api/classes/Handler.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ const Handler =
6464
apiDebugLog('Received API Request', path, args)
6565
const result = await doAPI(...(args as Parameters<HANDLER>))
6666
apiDebugLog('Resolved API Request', path, result)
67-
event.senderFrame.send(`${path}.complete`, result)
67+
if (event.senderFrame) {
68+
event.senderFrame.send(`${path}.complete`, result)
69+
}
6870
})
6971
return doAPI
7072
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { correctPluginPaths, loadPlugins, PluginShape } from '@seleniumhq/side-r
22
import { ipcMain } from 'electron'
33
import storage from 'main/store'
44
import BaseController from '../Base'
5+
import path from 'path'
56

67
export type PluginMessageHandler = (
78
event: Electron.IpcMainEvent,
@@ -21,6 +22,15 @@ export default class PluginsController extends BaseController {
2122
.concat(correctPluginPaths(projectPath, activeProject.plugins))
2223
}
2324

25+
async listPreloadPaths() {
26+
const list = await this.list();
27+
return list.map((pluginPath) => {
28+
const actualPluginPath = __non_webpack_require__.resolve(pluginPath)
29+
const preloadPath = path.join(actualPluginPath, '..', 'preload', 'index.js')
30+
return preloadPath
31+
})
32+
}
33+
2434
async onProjectLoaded() {
2535
const pluginPaths = await this.list()
2636
const plugins = await loadPlugins(

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ const getFrameTraversalCommands = (
4646
const getLastActiveWindowHandleId = (session: CoreSessionData): string => {
4747
const activeTest = getActiveTest(session)
4848
const activeIndex = getActiveCommandIndex(session)
49-
49+
console.log(activeTest, activeIndex)
5050
const commands = activeTest.commands
5151
for (let i = activeIndex; i >= 0; i--) {
5252
let item = commands[i]
53-
5453
if (item.command == 'selectWindow') {
5554
let target = item.target as string
5655
return target.substring('handle=${'.length, target.length - 1)

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

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import type { Shape as List } from './list'
2+
import type { Shape as ListPreloadPaths } from './listPreloadPaths'
23
import type { Shape as ProjectCreate } from './projectCreate'
34
import type { Shape as ProjectDelete } from './projectDelete'
45
import type { Shape as ProjectEdit } from './projectEdit'
56

67
import * as list from './list'
8+
import * as listPreloadPaths from './listPreloadPaths'
79
import * as projectCreate from './projectCreate'
810
import * as projectDelete from './projectDelete'
911
import * as projectEdit from './projectEdit'
1012

1113
export const commands = {
1214
list,
15+
listPreloadPaths,
1316
projectCreate,
1417
projectDelete,
1518
projectEdit,
@@ -19,6 +22,7 @@ export const commands = {
1922
*/
2023
export type Shape = {
2124
list: List
25+
listPreloadPaths: ListPreloadPaths
2226
projectCreate: ProjectCreate
2327
projectDelete: ProjectDelete
2428
projectEdit: ProjectEdit
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Get a list of active plugin preload paths
3+
*/
4+
export type Shape = () => Promise<string[]>

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)