-
Notifications
You must be signed in to change notification settings - Fork 228
Upgrade to support electron 4 (2) #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to support electron 4 (2) #361
Conversation
Implement workaround found https://bitbucket.org/chromiumembedded/cef/issues/2476/cef-webdriver-instructions-will-need-to
@@ -137,7 +137,7 @@ describe('application loading', function () { | |||
it('gets the render process console logs and clears them', function () { | |||
return app.client.waitUntilWindowLoaded() | |||
.getRenderProcessLogs().then(function (logs) { | |||
expect(logs.length).to.equal(3) | |||
expect(logs.length).to.equal(4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not checked, but probably an Electron warning is fired.
test/multi-window-test.js
Outdated
@@ -24,15 +24,15 @@ describe('multiple windows', function () { | |||
it('launches the application', function () { | |||
return app.client | |||
.getWindowCount().should.eventually.equal(2) | |||
.windowByIndex(1) | |||
.windowByIndex(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why the order has changed, but don't think this change breaks the idea of the test anyway 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it looks like we can't rely on the order of windowhandles
So I rewrote the test to be independent of the order of the returned windows.
Failing on Windows CI: 1) window commands
webContents.selectAll()
selects all the text on the page:
AssertionError: expected '' to include 'Hello' Have no clue so far: is Edit: was actually failing since previous bump of version: #334 |
lib/application.js
Outdated
@@ -149,6 +149,11 @@ Application.prototype.createClient = function () { | |||
args.push('spectron-env-' + name + '=' + self.env[name]) | |||
} | |||
|
|||
// Port to communicate on. Required starting with ChromeDriver v2.41. | |||
// https://bitbucket.org/chromiumembedded/cef/issues/2476/cef-webdriver-instructions-will-need-to | |||
const randomPort = Math.floor(Math.random() * (9999 - 9000) + 9000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right port to use, we should be using port 0
and reading the DevToolsActivePort
file to get the chosen port 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the link above:
It also doesn't work with CEF. The reason is that CEF's devtools implementation refuses to handle the remote-debugging-port=0 use case. See this code: https://bitbucket.org/chromiumembedded/cef/src/8e9d736cda2015b706e183bfd8f7fd63a2cd5396/libcef/browser/devtools_manager_delegate.cc#lines-75
So I considered that, in Electron (CEF right?), remote-debugging-port=0
won't work and I have not given it a try.
I can give it a try though if you think I should!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexstrat I fixed --remote-debugging-port=0
a while back in Electron -> electron/electron#17800
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes! I missed that indeed!
However, it looks like the fix is only available for electron >=5 and this PR is for electron 4, right?
Should I either:
- backport the fix in Electron 4
- keep this random port solution until Spectron 7 (Electron 5) and add a comment here about it
- try the
remote-debugging-port=0
here and see if it works (is there a reason for it to work?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started looking into electron 5 and I'm not sure we need to read DevToolsActivePort
actually. Indeed currently webdriver@4
does not use the devtools-service
(no trace in dependencies, etc..) which is the only component that'll need access to devtools.
Indded, I was able to get electron 5 running just by removing args.push('remote-debugging-port=${randomPort}')
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to keep the random port solution until Spectron 7. #364
Ready for 2nd review! 👐 |
I am using spectron@5.0.0 with electron@4.0.4. What might be broken for me? Sorry if this is not the right place to ask! |
lib/application.js
Outdated
@@ -153,6 +153,20 @@ Application.prototype.createClient = function () { | |||
args.push(arg) | |||
}) | |||
|
|||
// Since ChromeDriver v2.41, ChromeDriver with CEF will only connect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Electron doesn't use CEF :) Do you mean this is broken here in a similar way it's broken in CEF?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, it was not accurate, but yes, I guess it's similar behavior.
Looks like
is still failing 🤔 |
@codebytere yes, indeed, but it was failing since electron 3 #334 see 25d492d's Appeyor build. I've done some research about it but I could not find a clue and I can hardly test in Windows. If you think it's necessary for merging this PR, I can have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can investigate the windows spec failure in a follow-up
If ok, I think we can merge (i can't) and release? |
This was originally employed to work around Spectron choosing a random port colliding with our back end. Spectron's choosing a random port was in turn used as an Electron workaround. The workarounds haven't been needed since Electron 5. We moved past Electron 4 at #381 . This effectively reverts #319 Other refs: electron-userland/spectron#361 electron-userland/spectron#364
This was originally employed to work around Spectron choosing a random port colliding with our back end. Spectron's choosing a random port was in turn used as an Electron workaround. The workarounds haven't been needed since Electron 5. We moved past Electron 4 at #381 . This effectively reverts #319 Other refs: electron-userland/spectron#361 electron-userland/spectron#364
This was originally employed to work around Spectron choosing a random port colliding with our back end. Spectron's choosing a random port was in turn used as an Electron workaround. The workarounds haven't been needed since Electron 5. We moved past Electron 4 at #381 . This effectively reverts #319 Other refs: electron-userland/spectron#361 electron-userland/spectron#364
Finish #354 by implementing the workaround of #346 (comment)