Skip to content

Update code to deal API-breaking changes in Spectron/Electron.#4

Open
jdhiser wants to merge 5 commits into
slashwhy:masterfrom
jdhiser:master
Open

Update code to deal API-breaking changes in Spectron/Electron.#4
jdhiser wants to merge 5 commits into
slashwhy:masterfrom
jdhiser:master

Conversation

@jdhiser
Copy link
Copy Markdown

@jdhiser jdhiser commented Aug 18, 2020

Older versions of Electron allowed one to IPC objects
that contained code (and other features) by silently converting
code -> undefined. Newer versions reject these IPCs. Adjusted
getMenuItem to return a generic object instead of a electron.MenuItem.

Newer versions of node/spectron also require webPreferences:true
to be set when creating an application. Updated tests to reflect
this.

Next, I added the appropriate parameters to the menuItem.click()
method (menuItem,browserwindow,event). I haven't yet figured
out how to pass a valid event, so don't trust that parameter yet,
but browserWindow is frequently needed so that an application knows
which window is being communicated with!

Lastly, I made the clickMenuItem an async function that uses
sendSync, so that tests could more easily wait until the click
was handled.

Bump version number.

Older versions of Electron allowed one to IPC objects
that contained code (and other features) by silently converting
code -> undefined.  Newer versions reject these IPCs.  Adjusted
getMenuItem to return a generic object instead of a electron.MenuItem.

Newer versions of node/spectron also require webPreferences:true
to be set when creating an application.  Updated tests to reflect
this.

Next, I added the appropriate parameters to the menuItem.click()
method (menuItem,browserwindow,event).  I haven't yet figured
out how to pass a valid event, so don't trust that parameter yet,
but browserWindow is frequently needed so that an application knows
which window is being communicated with!

Lastly, I made the clickMenuItem an async function that uses
sendSync, so that tests could more easily wait until the click
was handled.

Bump version number.
…ly. Bumped version number to re-publish working version
Old example directory required very-old versions of
elctron/spectron/webdriver.  Thus, necessitating this update.
WebdriverIO API changes required some work.
@yoresu
Copy link
Copy Markdown

yoresu commented Dec 23, 2020

hi,my electron version is 9.0.0,and my spectron version is12.0.0.I ran code menuAddon.clickMenu('XXX', 'XXXX'); It return the message TypeError: Cannot read property 'electron' of undefined
at SpectronMenuAddon.clickMenu (node_modules\spectron-menu-addon\dist\index.js:24:18)
at Context. (spec.js:65:15)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

@jdhiser
Copy link
Copy Markdown
Author

jdhiser commented Dec 23, 2020

Hey yoresu,

I think you need to match spectron/electron versions as listed here: https://github.com/electron-userland/spectron#version-map

If that doesn't @SALT-AND-PEPPER has not responded about this PR, so I've been maintaining this -v2 in jdhiser:master. If you're having problems with that version and my comment above didn't help, please open an issue on that repo.

-j

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants