Skip to content

Commit 14d01a4

Browse files
committed
adding back plugin comm channel capabiltiy
1 parent 7ce32e2 commit 14d01a4

File tree

34 files changed

+208
-64
lines changed

34 files changed

+208
-64
lines changed

packages/selenium-ide/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"@seleniumhq/code-export-python-pytest": "^4.0.0-alpha.4",
112112
"@seleniumhq/code-export-ruby-rspec": "^4.0.0-alpha.3",
113113
"@seleniumhq/get-driver": "^4.0.0-alpha.3",
114-
"@seleniumhq/side-api": "^4.0.0-alpha.40",
114+
"@seleniumhq/side-api": "^4.0.0-alpha.41",
115115
"@seleniumhq/side-model": "^4.0.0-alpha.5",
116116
"@seleniumhq/side-runtime": "^4.0.0-alpha.33",
117117
"dnd-core": "^16.0.1",

packages/selenium-ide/src/browser/api/classes/EventListener.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BaseListener, VariadicArgs } from '@seleniumhq/side-api'
33

44
const baseListener = <ARGS extends VariadicArgs>(
55
path: string
6-
): BaseListener<ARGS> => {
6+
): BaseListener<ARGS> & { emitEvent: (...args: ARGS) => void } => {
77
const listeners: any[] = []
88
return {
99
addListener(listener) {
@@ -15,7 +15,11 @@ const baseListener = <ARGS extends VariadicArgs>(
1515
console.debug(path, 'dispatching event')
1616
const results = listeners.map((fn) => fn(...args))
1717
ipcRenderer.send(`${path}.response`, results)
18-
return results;
18+
return results
19+
},
20+
emitEvent(...args) {
21+
console.debug(path, 'emitting event')
22+
ipcRenderer.send(`${path}.emit`, ...args)
1923
},
2024
hasListener(listener) {
2125
return listeners.includes(listener)

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

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,23 @@ import { RecorderPreprocessor } from '@seleniumhq/side-api'
1818
import api from 'browser/api'
1919
import apiMutators from 'browser/api/mutator'
2020
import preload from 'browser/helpers/preload'
21-
import {cb as ElectronCallback} from 'browser/helpers/preload-electron'
21+
import { cb as ElectronCallback } from 'browser/helpers/preload-electron'
2222
import { webFrame } from 'electron'
2323
import Recorder from './preload/recorder'
2424

2525
const recorderProcessors: RecorderPreprocessor[] = []
2626
async function main() {
27-
const preloads = await api.plugins.getPreloads()
28-
for (const preload of preloads) {
29-
eval(preload)
30-
}
3127
window.addEventListener('DOMContentLoaded', async () => {
28+
const preloads = await api.plugins.getPreloads()
29+
for (const preload of preloads) {
30+
try {
31+
console.debug(`Loading preload: ${preload}`)
32+
eval(preload)
33+
console.debug(`Loaded preload!`)
34+
} catch (e) {
35+
console.error(`Error loading preload: ${preload}`, e)
36+
}
37+
}
3238
webFrame.executeJavaScript(`
3339
Object.defineProperty(navigator, 'webdriver', {
3440
get () {
@@ -44,17 +50,20 @@ async function main() {
4450
})
4551
}
4652

47-
preload(api, ElectronCallback, main)(
48-
{
49-
plugins: {
50-
addRecorderPreprocessor: (fn) => {
51-
recorderProcessors.push(fn)
52-
},
53-
},
54-
recorder: api.recorder,
55-
mutators: {
56-
plugins: {},
57-
recorder: apiMutators.recorder,
53+
preload(
54+
api,
55+
ElectronCallback,
56+
main
57+
)({
58+
channels: api.channels,
59+
plugins: {
60+
addRecorderPreprocessor: (fn) => {
61+
recorderProcessors.push(fn)
5862
},
5963
},
60-
)
64+
recorder: api.recorder,
65+
mutators: {
66+
plugins: {},
67+
recorder: apiMutators.recorder,
68+
},
69+
})

packages/selenium-ide/src/browser/windows/ProjectEditor/components/Drawer/EditorToolbar.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ListSubheader, { ListSubheaderProps } from '@mui/material/ListSubheader'
88
import React, { FC } from 'react'
99

1010
interface EditorToolbarProps extends ListSubheaderProps {
11+
disabled?: boolean
1112
onAdd?: () => void
1213
onEdit?: () => void
1314
onRemove?: () => void
@@ -24,6 +25,7 @@ const standardIconProps = {
2425
const EditorToolbar: FC<EditorToolbarProps> = ({
2526
children,
2627
className = 'lh-36',
28+
disabled = false,
2729
onAdd,
2830
onEdit,
2931
onRemove,
@@ -41,7 +43,12 @@ const EditorToolbar: FC<EditorToolbarProps> = ({
4143
{onAdd ? (
4244
<Box sx={{ flex: 0 }}>
4345
<Tooltip title="Add">
44-
<IconButton {...standardIconProps} color="success" onClick={onAdd}>
46+
<IconButton
47+
{...standardIconProps}
48+
color="success"
49+
disabled={disabled}
50+
onClick={onAdd}
51+
>
4552
<AddIcon />
4653
</IconButton>
4754
</Tooltip>
@@ -50,7 +57,12 @@ const EditorToolbar: FC<EditorToolbarProps> = ({
5057
{onRemove ? (
5158
<Box sx={{ flex: 0 }}>
5259
<Tooltip title="Remove">
53-
<IconButton {...standardIconProps} color="warning" onClick={onRemove}>
60+
<IconButton
61+
{...standardIconProps}
62+
color="warning"
63+
disabled={disabled}
64+
onClick={onRemove}
65+
>
5466
<RemoveIcon />
5567
</IconButton>
5668
</Tooltip>
@@ -59,7 +71,12 @@ const EditorToolbar: FC<EditorToolbarProps> = ({
5971
{onEdit ? (
6072
<Box sx={{ flex: 0 }}>
6173
<Tooltip title="Edit">
62-
<IconButton {...standardIconProps} color="info" onClick={onEdit}>
74+
<IconButton
75+
{...standardIconProps}
76+
color="info"
77+
disabled={disabled}
78+
onClick={onEdit}
79+
>
6380
<EditIcon />
6481
</IconButton>
6582
</Tooltip>
@@ -68,7 +85,12 @@ const EditorToolbar: FC<EditorToolbarProps> = ({
6885
{onView ? (
6986
<Box sx={{ flex: 0 }}>
7087
<Tooltip title="View Playback Results">
71-
<IconButton {...standardIconProps} color="info" onClick={onView}>
88+
<IconButton
89+
{...standardIconProps}
90+
color="info"
91+
disabled={disabled}
92+
onClick={onView}
93+
>
7294
<VisibilityIcon />
7395
</IconButton>
7496
</Tooltip>

packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Project/ProjectSettings.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ const ProjectSettings: FC<ProjectSettingsProps> = ({
5555
value={project.url}
5656
/>
5757
</FormControl>
58+
<FormControl>
59+
<TextField
60+
id="timeout"
61+
label="Step Timeout (MILLISECONDS)"
62+
helperText="Steps will fail if they take longer than this setting"
63+
name="timeout"
64+
type="number"
65+
inputProps={{ min:0, step: 1000 }}
66+
onChange={(e: any) => {
67+
update({
68+
delay: Math.max(parseInt(e.target.value || '0'), 0),
69+
})
70+
}}
71+
size="small"
72+
value={project.delay || 0}
73+
/>
74+
</FormControl>
5875
<FormControl>
5976
<TextField
6077
id="delay"

packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/CommandFields/CommandSelector.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const updateCommand = updateACField('command')
1414
const CommandSelector: FC<CommandSelectorProps> = ({
1515
command,
1616
commands,
17+
disabled,
1718
isDisabled,
1819
testID,
1920
}) => {
@@ -40,6 +41,7 @@ const CommandSelector: FC<CommandSelectorProps> = ({
4041
<Autocomplete
4142
id="command-selector"
4243
className="flex-1"
44+
disabled={disabled}
4345
onChange={updateCommand(testID, command.id)}
4446
getOptionLabel={(option) => option.label}
4547
options={commandOptions}
@@ -65,7 +67,10 @@ const CommandSelector: FC<CommandSelectorProps> = ({
6567
} a new window`}
6668
placement="top-end"
6769
>
68-
<IconButton onClick={() => setOpensWindow(!command.opensWindow)}>
70+
<IconButton
71+
disabled={disabled}
72+
onClick={() => setOpensWindow(!command.opensWindow)}
73+
>
6974
<OpenInNew color={command.opensWindow ? 'info' : 'inherit'} />
7075
</IconButton>
7176
</Tooltip>
@@ -75,6 +80,7 @@ const CommandSelector: FC<CommandSelectorProps> = ({
7580
placement="top-end"
7681
>
7782
<IconButton
83+
disabled={disabled}
7884
onClick={() =>
7985
setCommand(isDisabled ? command.command : `//${command.command}`)
8086
}

packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/CommandFields/LocatorField.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type PluralField = 'targets' | 'values'
1616
const CommandLocatorField: FC<CommandArgFieldProps> = ({
1717
command,
1818
commands,
19+
disabled,
1920
fieldName,
2021
testID,
2122
}) => {
@@ -44,6 +45,7 @@ const CommandLocatorField: FC<CommandArgFieldProps> = ({
4445
<FormControl className="flex flex-row">
4546
<Autocomplete
4647
className="flex-1"
48+
disabled={disabled}
4749
freeSolo
4850
inputValue={localValue || ''}
4951
componentsProps={{
@@ -81,13 +83,15 @@ const CommandLocatorField: FC<CommandArgFieldProps> = ({
8183
/>
8284
<IconButton
8385
className="ml-4"
86+
disabled={disabled}
8487
onClick={() =>
8588
window.sideAPI.recorder.requestHighlightElement(fieldName)
8689
}
8790
>
8891
<FindInPageIcon />
8992
</IconButton>
9093
<IconButton
94+
disabled={disabled}
9195
onClick={() =>
9296
window.sideAPI.recorder.requestSelectElement(true, fieldName)
9397
}

packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/CommandFields/TextField.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import Tooltip from '@mui/material/Tooltip'
99
import { LocatorFields } from '@seleniumhq/side-api'
1010

1111
const CommandTextField: FC<CommandFieldProps> = ({
12-
commands,
1312
command,
13+
commands,
14+
disabled,
1415
fieldName,
1516
note,
1617
testID,
@@ -27,6 +28,7 @@ const CommandTextField: FC<CommandFieldProps> = ({
2728
<FormControl className="flex flex-row">
2829
<TextField
2930
className="flex-1"
31+
disabled={disabled}
3032
id={`${fieldName}-${command.id}`}
3133
label={label}
3234
InputLabelProps={{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import CommandTextField from './CommandFields/TextField'
1010
export interface CommandEditorProps {
1111
command: CommandShape
1212
commands: CoreSessionData['state']['commands']
13+
disabled?: boolean
1314
selectedCommandIndexes: number[]
1415
testID: string
1516
}

packages/selenium-ide/src/browser/windows/ProjectEditor/tabs/Tests/TestCommandList.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface CommandListProps {
1212
bottomOffset: number
1313
commands: CommandShape[]
1414
commandStates: CommandsStateShape
15+
disabled?: boolean
1516
selectedCommandIndexes: number[]
1617
}
1718

@@ -22,6 +23,7 @@ const CommandList: FC<CommandListProps> = ({
2223
bottomOffset,
2324
commandStates,
2425
commands,
26+
disabled = false,
2527
selectedCommandIndexes,
2628
}) => {
2729
const [preview, reorderPreview, resetPreview] = useReorderPreview(
@@ -34,9 +36,10 @@ const CommandList: FC<CommandListProps> = ({
3436
<ReorderableList
3537
bottomOffset={bottomOffset}
3638
dense
39+
aria-disabled={disabled}
3740
subheader={
3841
<EditorToolbar
39-
sx={{ top: '48px', zIndex: 100 }}
42+
disabled={disabled}
4043
onAdd={() =>
4144
window.sideAPI.tests.addSteps(
4245
activeTest,
@@ -52,6 +55,7 @@ const CommandList: FC<CommandListProps> = ({
5255
)
5356
: undefined
5457
}
58+
sx={{ top: '48px', zIndex: 100 }}
5559
>
5660
<span className="ml-4">Commands</span>
5761
</EditorToolbar>
@@ -67,6 +71,7 @@ const CommandList: FC<CommandListProps> = ({
6771
activeTest={activeTest}
6872
command={command}
6973
commandState={commandStates[id]}
74+
disabled={disabled}
7075
key={id}
7176
index={index}
7277
reorderPreview={reorderPreview}

0 commit comments

Comments
 (0)