Skip to content

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

Merged

Conversation

alexstrat
Copy link
Contributor

Finish #354 by implementing the workaround of #346 (comment)

@@ -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)
Copy link
Contributor Author

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.

@@ -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)
Copy link
Contributor Author

@alexstrat alexstrat May 17, 2019

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 🤷‍♂️

Copy link
Contributor Author

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

https://github.com/webdriverio/webdriverio/blob/567f8778bc8a66a2a68ad9e12da2c81e86fabe47/packages/webdriver/protocol/webdriver.json#L192

So I rewrote the test to be independent of the order of the returned windows.

@alexstrat
Copy link
Contributor Author

alexstrat commented May 17, 2019

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 getSelectedText or selectAll not working?

Edit: was actually failing since previous bump of version: #334

@@ -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)
Copy link
Member

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 🤔

Copy link
Contributor Author

@alexstrat alexstrat May 22, 2019

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!

Copy link
Member

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

Copy link
Contributor Author

@alexstrat alexstrat May 22, 2019

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?)

Copy link
Contributor Author

@alexstrat alexstrat May 22, 2019

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}').

Copy link
Contributor Author

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

@alexstrat alexstrat mentioned this pull request May 24, 2019
4 tasks
@alexstrat
Copy link
Contributor Author

Ready for 2nd review! 👐

@jonbeller
Copy link

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!

alexstrat added a commit to alexstrat/spectron that referenced this pull request Jun 1, 2019
@@ -153,6 +153,20 @@ Application.prototype.createClient = function () {
args.push(arg)
})

// Since ChromeDriver v2.41, ChromeDriver with CEF will only connect
Copy link
Member

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?

Copy link
Contributor Author

@alexstrat alexstrat Jun 2, 2019

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.

@codebytere
Copy link
Member

Looks like

    webContents.selectAll()
      1) selects all the text on the page

is still failing 🤔

@alexstrat
Copy link
Contributor Author

alexstrat commented Jun 2, 2019

@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.

Copy link
Member

@codebytere codebytere left a 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

@alexstrat
Copy link
Contributor Author

If ok, I think we can merge (i can't) and release?

@codebytere codebytere merged commit a64c809 into electron-userland:master Jun 20, 2019
alexstrat added a commit to alexstrat/spectron that referenced this pull request Jun 24, 2019
mikesbrown added a commit to brimdata/zui that referenced this pull request Apr 16, 2020
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
mikesbrown added a commit to brimdata/zui that referenced this pull request Apr 16, 2020
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
alfred-landrum pushed a commit to brimdata/zui that referenced this pull request Apr 17, 2020
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
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.

5 participants