Skip to content

Commit 90c7baa

Browse files
committed
lots of stuff and test fixes
1 parent bb33f08 commit 90c7baa

File tree

95 files changed

+928
-830
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+928
-830
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"clean:deps": "rimraf packages/*/node_modules node_modules",
1414
"clean": "rimraf packages/*/build packages/*/dist packages/*/node_modules packages/*/tsconfig.tsbuildinfo node_modules",
1515
"clean:nuke": "git clean -fdx",
16+
"start": "cd packages/selenium-ide && npm start",
1617
"test": "jest",
1718
"test:e2e": "jest --testMatch \"**/packages/**/__tests__/**/*.e2e.js\"",
1819
"lint": "pnpm run lint:scripts",

Diff for: packages/selenium-ide/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/selenium-ide",
3-
"version": "4.0.0-alpha.47",
3+
"version": "4.0.0-alpha.48",
44
"private": true,
55
"description": "Selenium IDE electron app",
66
"author": "Todd <[email protected]>",
@@ -106,9 +106,9 @@
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.29",
109+
"@seleniumhq/side-api": "^4.0.0-alpha.30",
110110
"@seleniumhq/side-model": "^4.0.0-alpha.4",
111-
"@seleniumhq/side-runtime": "^4.0.0-alpha.27",
111+
"@seleniumhq/side-runtime": "^4.0.0-alpha.29",
112112
"dnd-core": "^16.0.1",
113113
"electron-chromedriver": "^25.3.0",
114114
"electron-log": "^4.4.8",

Diff for: packages/selenium-ide/scripts/ide-runner.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ main()
3636

3737
async function main() {
3838
console.log('Starting webdriver backend')
39-
const {proc, success} = await startWebdriverBackend({ driver: 'chrome' })
39+
const { proc, success } = await startWebdriverBackend({ driver: 'chrome' })
4040
if (!success) {
4141
console.error('Failed to start webdriver backend')
4242
console.error(proc.error)
@@ -51,10 +51,7 @@ async function main() {
5151
'goog:chromeOptions': {
5252
// Here is the path to your Electron binary.
5353
binary: electronBinaryPath,
54-
args: [
55-
'app=' + pathToSeleniumIDE,
56-
`side-file=${sideFile}`,
57-
],
54+
args: ['app=' + pathToSeleniumIDE, `side-file=${sideFile}`],
5855
excludeSwitches: ['enable-logging'],
5956
},
6057
})
@@ -77,11 +74,6 @@ function startWebdriverBackend() {
7774
env: {},
7875
shell: false,
7976
})
80-
process.on('exit', () => {
81-
if (!proc.killed) {
82-
proc.kill()
83-
}
84-
})
8577
proc.stdout.on('data', (out) => {
8678
const outStr = `${out}`
8779
WebdriverDebugLog(outStr)

Diff for: packages/selenium-ide/src/browser/windows/PlaybackWindow/preload/recorder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
ExpandedMutationObserver,
2525
} from 'browser/types'
2626
import initFindSelect from './find-select'
27-
import { PluginPreloadOutputShape } from '@seleniumhq/side-api'
27+
import { PluginPreloadOutputShape, RecordNewCommandInput } from '@seleniumhq/side-api'
2828

2929
export interface RecordingState {
3030
typeTarget: HTMLElement | null
@@ -110,7 +110,7 @@ export default class Recorder {
110110
insertBeforeLastCommand: boolean = false,
111111
actualFrameLocation?: string
112112
) {
113-
let newCommand = {
113+
let newCommand: RecordNewCommandInput = {
114114
command,
115115
target,
116116
value,

Diff for: packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/TestCommandEditor.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ const CommandEditor: FC<CommandEditorProps> = ({
3737
selectedCommandIndexes.length !== 1 ||
3838
!commands[correctedCommand.command]
3939
) {
40-
console.log(selectedCommandIndexes)
4140
return (
4241
<Stack className="p-4" spacing={1}>
4342
<Typography className="centered py-4" variant="body2">

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export default class DriverController extends BaseController {
142142

143143
async stopProcess(): Promise<null | string> {
144144
if (this.driverProcess) {
145-
const procKilled = this.driverProcess.kill(9)
145+
const procKilled = await this.driverProcess.kill(9)
146146
WebdriverDebugLog('Killed driver?', procKilled)
147147
}
148148
return null

Diff for: packages/selenium-ide/src/main/session/controllers/Driver/start.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ const getDriver = ({ browser, version }: BrowserInfo) =>
5959
export type StartDriver = (
6060
session: Session
6161
) => (info: BrowserInfo) => Promise<DriverStartSuccess | DriverStartFailure>
62+
6263
const startDriver: StartDriver = () => (info) =>
6364
new Promise((resolve) => {
6465
let initialized = false
6566
const args = ['--verbose', `--port=${port}`]
6667
const driverPath = getDriver(info)
6768
if (fs.existsSync(driverPath)) {
68-
const driver = spawn(driverPath.replace(/\s/g, '\ '), args, {
69+
const driver = spawn(driverPath.replace(/\s/g, ' '), args, {
6970
env: {},
7071
shell: false,
7172
})
@@ -77,6 +78,16 @@ const startDriver: StartDriver = () => (info) =>
7778
initialized = true
7879
WebdriverDebugLog('Driver has initialized!')
7980
resolve({ success: true, driver: driver })
81+
process.on('beforeExit', async () => {
82+
console.log('Exiting?');
83+
try {
84+
if (!driver.killed) {
85+
await driver.kill(9)
86+
}
87+
} catch (e) {
88+
console.warn('Failed ot kill driver', e)
89+
}
90+
})
8091
}
8192
})
8293
driver.stderr.on('data', (err: string) => {

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

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export default class PluginsController extends BaseController {
6060
ipcMain.on(key, handler)
6161
this.pluginHooks[index][key] = handler
6262
})
63+
if (plugin.hooks?.onLoad) {
64+
await plugin.hooks.onLoad(this.session.api)
65+
}
6366
}
6467

6568
async unload(plugin: PluginShape) {
@@ -69,6 +72,9 @@ export default class PluginsController extends BaseController {
6972
Object.entries(hooks).forEach(([key, handler]) => {
7073
ipcMain.off(key, handler)
7174
})
75+
if (plugin.hooks?.onUnload) {
76+
await plugin.hooks.onUnload(this.session.api)
77+
}
7278
}
7379
// This needs to build before commands
7480
priority = 3

Diff for: packages/selenium-ide/src/main/session/controllers/Projects/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ export default class ProjectsController {
174174
let project: ProjectShape
175175
try {
176176
project = JSON.parse(fileContents)
177-
project.plugins = project.plugins.filter(
177+
project.plugins = project?.plugins?.filter(
178178
(plugin) => typeof plugin === 'string'
179-
)
179+
) ?? []
180180
return project
181181
} catch (e) {
182182
console.log((e as Error).message)

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CommandShape } from '@seleniumhq/side-model'
22
import { getActiveCommand, getActiveTest, getActiveCommandIndex } from '@seleniumhq/side-api/dist/helpers/getActiveData'
3-
import { LocatorFields, CoreSessionData } from '@seleniumhq/side-api'
3+
import { LocatorFields, CoreSessionData, RecordNewCommandInput } from '@seleniumhq/side-api'
44
import { randomInt, randomUUID } from 'crypto'
55
import { relative } from 'path'
66
import BaseController from '../Base'
@@ -61,15 +61,6 @@ const getLastActiveWindowHandleId = (session: CoreSessionData): string => {
6161

6262
return 'root'
6363
}
64-
export interface RecordNewCommandInput {
65-
command: string
66-
target: string | [string, string][]
67-
value: string | [string, string][]
68-
insertBeforeLastCommand?: boolean
69-
frameLocation?: string
70-
winHandleId?: string
71-
}
72-
7364
export default class RecorderController extends BaseController {
7465
windowIDs: number[] = []
7566

Diff for: packages/selenium-ide/src/main/session/controllers/System/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ export default class SystemController extends BaseController {
4747
message: error,
4848
type: 'error',
4949
})
50-
await this.shutdown()
5150
await this.quit()
51+
throw new Error(error)
5252
}
5353

5454
async quit() {
5555
await this.shutdown()
56+
await this.session.windows.closeAll()
5657
if (this.isDown) {
5758
this.session.app.quit()
5859
}

Diff for: packages/side-api/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@seleniumhq/side-api",
3-
"version": "4.0.0-alpha.29",
3+
"version": "4.0.0-alpha.30",
44
"private": false,
55
"description": "Selenium IDE API command shapes and such",
66
"author": "Todd Tarsi <[email protected]>",
@@ -20,7 +20,7 @@
2020
"@seleniumhq/browser-info": "^4.0.0-alpha.1",
2121
"@seleniumhq/get-driver": "^4.0.0-alpha.2",
2222
"@seleniumhq/side-model": "^4.0.0-alpha.4",
23-
"@seleniumhq/side-runtime": "^4.0.0-alpha.28",
23+
"@seleniumhq/side-runtime": "^4.0.0-alpha.29",
2424
"lodash": "^4.17.21"
2525
},
2626
"devDependencies": {

Diff for: packages/side-api/src/classes/ProxyTrap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import set from 'lodash/fp/set'
2-
import { ApiHandler } from '../types'
2+
import { ApiHandler } from '../types/base'
33

44
type NotVagueShape = null | boolean | string | number
55
type MaybeVagueShape = VagueShape | NotVagueShape

Diff for: packages/side-api/src/commands/driver/download.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrowserInfo } from '../../types'
1+
import { BrowserInfo } from '../../types/base'
22

33
/**
44
* Download a driver needed to instrument an available browser.

Diff for: packages/side-api/src/commands/driver/listBrowsers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrowsersInfo } from '../../types'
1+
import { BrowsersInfo } from '../../types/base'
22

33
/**
44
* List available browsers to be driven.

Diff for: packages/side-api/src/commands/driver/selectBrowser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrowserInfo } from '../../types'
1+
import { BrowserInfo } from '../../types/base'
22

33
/**
44
* Select a browser to run. Currently only Electron is allowed.

Diff for: packages/side-api/src/commands/driver/startProcess.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrowserInfo } from '../../types'
1+
import { BrowserInfo } from '../../types/base'
22

33
/**
44
* Start the driver process for the browser, eg Chromedriver etc..

Diff for: packages/side-api/src/commands/playback/onAfter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseListener } from '../../types'
1+
import { BaseListener } from '../../types/base'
22

33
/**
44
* Runs after a test completes

Diff for: packages/side-api/src/commands/playback/onAfterAll.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseListener } from '../../types'
1+
import { BaseListener } from '../../types/base'
22

33
/**
44
* Runs after a suite completes

Diff for: packages/side-api/src/commands/playback/onBefore.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseListener } from '../../types'
1+
import { BaseListener } from '../../types/base'
22

33
/**
44
* Runs before a test begins

Diff for: packages/side-api/src/commands/playback/onPlayUpdate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
CoreSessionData,
55
EventMutator,
66
StateShape,
7-
} from '../../types'
7+
} from '../../types/base'
88
import { badIndex } from '../../constants/badIndex'
99

1010
/**

Diff for: packages/side-api/src/commands/playback/onStepUpdate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { TestShape } from '@seleniumhq/side-model'
22
import { PlaybackEventShapes } from '@seleniumhq/side-runtime'
33
import merge from 'lodash/fp/merge'
44
import { getActiveTest, getCommandIndex } from '../../helpers/getActiveData'
5-
import { BaseListener, EventMutator, StateShape } from '../../types'
5+
import { BaseListener, EventMutator, StateShape } from '../../types/base'
66
import { EditorStateShape, PlaybackStateShape } from '../../models/state'
77

88
/**

Diff for: packages/side-api/src/commands/playback/pause.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import set from 'lodash/fp/set'
2-
import { Mutator } from '../../types'
2+
import { Mutator } from '../../types/base'
33

44
/**
55
* Pause a running test. Can be resumed.

Diff for: packages/side-api/src/commands/playback/play.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defaultPlaybackState } from '../../models'
2-
import { Mutator } from '../../types'
2+
import { Mutator } from '../../types/base'
33

44
/**
55
* Start a running test, using a range to optionally control start

Diff for: packages/side-api/src/commands/playback/playSuite.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import set from 'lodash/fp/set'
22
import { defaultPlaybackState } from '../../models'
3-
import { Mutator } from '../../types'
3+
import { Mutator } from '../../types/base'
44

55
/**
66
* Start running a test suite. Results should be processed using

Diff for: packages/side-api/src/commands/playback/resume.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import set from 'lodash/fp/set'
2-
import { Mutator } from '../../types'
2+
import { Mutator } from '../../types/base'
33

44
/**
55
* Resume running a paused test

Diff for: packages/side-api/src/commands/playback/stop.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import set from 'lodash/fp/set'
2-
import { Mutator } from '../../types'
2+
import { Mutator } from '../../types/base'
33

44
/**
55
* Abort a test. Can not be resumed

Diff for: packages/side-api/src/commands/plugins/projectCreate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import update from 'lodash/fp/update'
2-
import { Mutator } from '../../types'
2+
import { Mutator } from '../../types/base'
33

44
/**
55
* Add a plugin to the current project

Diff for: packages/side-api/src/commands/plugins/projectDelete.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import update from 'lodash/fp/update'
2-
import { Mutator } from '../../types'
2+
import { Mutator } from '../../types/base'
33

44
/**
55
* Remove a plugin from the current project

Diff for: packages/side-api/src/commands/plugins/projectEdit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import update from 'lodash/fp/update'
2-
import { Mutator } from '../../types'
2+
import { Mutator } from '../../types/base'
33

44
/**
55
* Update the path to a plugin on the current project

Diff for: packages/side-api/src/commands/projects/load.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { loadingID } from '../../constants/loadingID'
2-
import { CoreSessionData, Mutator } from '../../types'
2+
import { CoreSessionData, Mutator } from '../../types/base'
33

44
/**
55
* Loads the project editor for a path

Diff for: packages/side-api/src/commands/projects/new.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ProjectShape } from '@seleniumhq/side-model'
2-
import { Mutator } from '../../types'
2+
import { Mutator } from '../../types/base'
33

44
/**
55
* Creates a new project

Diff for: packages/side-api/src/commands/projects/update.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ProjectShape } from '@seleniumhq/side-model'
22
import merge from 'lodash/fp/merge'
33
import update from 'lodash/fp/update'
4-
import { CoreSessionData, Mutator } from '../../types'
4+
import { CoreSessionData, Mutator } from '../../types/base'
55

66
/**
77
* Edits project level config flags, like name or url.

Diff for: packages/side-api/src/commands/recorder/onFrameDeleted.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseListener } from '../../types'
1+
import { BaseListener } from '../../types/base'
22

33
export type OnFrameDeletedRecorder = []
44

Diff for: packages/side-api/src/commands/recorder/onFrameRecalculate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseListener } from '../../types'
1+
import { BaseListener } from '../../types/base'
22

33
export type OnFrameRecalculateRecorder = []
44

Diff for: packages/side-api/src/commands/recorder/onHighlightElement.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseListener } from '../../types'
1+
import { BaseListener } from '../../types/base'
22

33
/**
44
* Called when the project editor asks the recorder to highlight an element

Diff for: packages/side-api/src/commands/recorder/onNewWindow.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { CommandShape } from '@seleniumhq/side-model'
2-
import { BaseListener, EventMutator, RecordNewCommandInput } from '../../types'
2+
import {
3+
BaseListener,
4+
EventMutator,
5+
RecordNewCommandInput,
6+
} from '../../types/base'
37
import { mutator as recordNewCommandMutator } from './recordNewCommand'
48
import { mutator as updateStepTestsMutator } from '../tests/updateStep'
59
import { getActiveCommand } from '../../helpers/getActiveData'

Diff for: packages/side-api/src/commands/recorder/onRequestSelectElement.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BaseListener, LocatorFields } from '../../types'
1+
import { BaseListener, LocatorFields } from '../../types/base'
22

33
/**
44
* Called when the project editor asks the recorder to select an element.

0 commit comments

Comments
 (0)