Skip to content
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

Connect to Chrome Remote Interface when launching Chrome and record video #4628

Merged
merged 108 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
1b28a34
try connecting to chrome remote interface
bahmutov Jul 1, 2019
8b74d1e
linting
bahmutov Jul 1, 2019
ea24c39
print CRI targets for better debugging
bahmutov Jul 1, 2019
3e78b8f
linting
bahmutov Jul 1, 2019
fb8c0ff
load empty tab first when connecting to CRI
bahmutov Jul 1, 2019
7ba253f
first load blank page, then navigate
bahmutov Jul 1, 2019
ec06d65
Page.navigate is working
bahmutov Jul 3, 2019
3c76042
Merge branch 'develop' into add-cri-4608
bahmutov Jul 16, 2019
ff02745
linting
bahmutov Jul 16, 2019
ab11757
remove title
bahmutov Jul 16, 2019
3f7df04
add mocha banner
bahmutov Jul 16, 2019
b8fc8cf
more banners
bahmutov Jul 16, 2019
9bc5333
update some server unit tests
bahmutov Jul 16, 2019
b999dfc
update integration test
bahmutov Jul 16, 2019
054f589
document how to run single driver spec file
bahmutov Jul 17, 2019
1cab130
set the focus back on the page before navigating from blank chrome tab
bahmutov Jul 17, 2019
b842f23
update server unit test
bahmutov Jul 17, 2019
05bb2c4
Merge branch 'develop' into add-cri-4608
bahmutov Jul 18, 2019
6d20ab5
do not store Chrome remote interface reference for now
bahmutov Jul 18, 2019
4aaeb5f
record video of the Chrome tab using screencast API
bahmutov Jul 18, 2019
a7ec58c
use dynamic port to connect to Chrome remote interface
bahmutov Jul 23, 2019
4899902
update unit tests
bahmutov Jul 23, 2019
a09be50
merged latest add-cri-4608
bahmutov Jul 23, 2019
901272e
refactoring
bahmutov Jul 24, 2019
97e0f0d
wrap chrome remote interface in our interface, limit access to send
bahmutov Jul 24, 2019
f6250c5
Merge branch 'develop' into add-cri-4608
bahmutov Jul 30, 2019
0e1ff8b
resolved merge
bahmutov Jul 30, 2019
34dc56c
fix reference
bahmutov Jul 30, 2019
78e42e2
passing run unit spec
bahmutov Jul 30, 2019
bb51a0d
stub canary search for CI to pass
bahmutov Jul 30, 2019
59fb1b4
add build step to packages/server
bahmutov Jul 30, 2019
ed46cf6
update chrome spec
bahmutov Jul 30, 2019
eaf0aa3
do not build js on install for server
bahmutov Jul 30, 2019
8a2e24e
updated spec snapshots
bahmutov Jul 30, 2019
11805c9
update 6_visit_spec snapshot
bahmutov Jul 30, 2019
6cf87c1
update snapshot for 6_web_security_spec
bahmutov Jul 30, 2019
4594fba
update snapshot for 3_plugins_spec
bahmutov Jul 30, 2019
35aeb61
update snapshot for 3_user_agent_spec
bahmutov Jul 30, 2019
bbf6d4f
update snapshot for 5_stdout_spec
bahmutov Jul 30, 2019
77144e0
update snapshot for 2_browser_path_spec
bahmutov Jul 30, 2019
14676c4
Merge branch 'develop' into add-cri-4608
brian-mann Aug 1, 2019
b00f753
do not git ignore js files, add note why
bahmutov Aug 2, 2019
519fef3
Merge branch 'develop' into add-cri-4608
bahmutov Aug 12, 2019
d39f113
merged latest develop code into this branch
bahmutov Sep 10, 2019
5f5d4b0
update several snapshots with video on Chrome
bahmutov Sep 10, 2019
36a69a3
Merge branch 'develop' into add-cri-4608
bahmutov Sep 10, 2019
787c236
update visit performance snapshot
bahmutov Sep 10, 2019
53ac190
add chrome-remote-interface dependency
bahmutov Sep 11, 2019
6a7ec4f
Merge branch 'develop' into add-cri-4608
bahmutov Sep 26, 2019
c2a5839
Merge branch 'develop' into add-cri-4608
brian-mann Sep 29, 2019
7a56d43
cleanup coffeescript conversion to JS, fix some type errors, make par…
brian-mann Sep 29, 2019
96b56d6
fix failing tests
brian-mann Sep 29, 2019
0a258c0
Merge branch 'develop' into add-cri-4608
jennifer-shehane Oct 1, 2019
5f6b9a7
Fix snapshot - now we do record in Chrome, so warning message is no l…
jennifer-shehane Oct 1, 2019
506589b
remove chrome warnings about not recording from snapshot
jennifer-shehane Oct 1, 2019
e3a93c7
Remove performance tests from 6_visit_spec snapshot
flotwig Oct 2, 2019
629da2e
Remove error from snapshot
flotwig Oct 2, 2019
12195bc
Add newline back to cy_visit_performance_spec snapshot
flotwig Oct 2, 2019
9f2760e
Merge branch 'develop' into add-cri-4608
flotwig Oct 4, 2019
66d28ae
Navigate to about:blank
flotwig Oct 7, 2019
7216585
Merge branch 'develop' into add-cri-4608
bahmutov Oct 7, 2019
1100b5a
look for blank page url
bahmutov Oct 7, 2019
9755bc6
add note about avoiding Prettier
bahmutov Oct 7, 2019
cbe32b8
disable prettier a little more
bahmutov Oct 7, 2019
06d3f81
call chrome remote interface close after each spec
bahmutov Oct 7, 2019
15ecc5c
return promise when starting screencast
bahmutov Oct 7, 2019
af4b072
update failing unit tests, add cri client close test
bahmutov Oct 8, 2019
1c35680
update integration test
bahmutov Oct 8, 2019
17e0421
Add verbose debug statements to cri-client
flotwig Oct 8, 2019
2285b95
Merge branch 'add-cri-4608' of github.com:cypress-io/cypress into add…
flotwig Oct 8, 2019
5f56b63
Use connect.createRetryingSocket for CDP connection
flotwig Oct 8, 2019
fef98de
record video from chrome browsers
bahmutov Oct 8, 2019
d0794c1
add method for validating browser family
bahmutov Oct 8, 2019
22b2d62
update e2e spec snapshot
bahmutov Oct 8, 2019
87716ff
update 4_request_spec snapshot
bahmutov Oct 8, 2019
896eb6a
update snapshot for spec 1_commands_outside_of_test_spec
bahmutov Oct 8, 2019
edb1e7d
update snapshot for 3_plugins_spec
bahmutov Oct 8, 2019
0530c8e
update snapshot for spec 3_user_agent_spec
bahmutov Oct 8, 2019
70bdc7d
try: Always log video capturing errors
flotwig Oct 8, 2019
0ef525b
update snapshot for 2_browser_path_spec
bahmutov Oct 8, 2019
07024b9
update snapshot for 2_cookies_spec
bahmutov Oct 8, 2019
cdacbd0
better browser family test
bahmutov Oct 8, 2019
c1b00e9
update snapshot for 5_stdout_spec
bahmutov Oct 8, 2019
7a66da4
update snapshot for 5_subdomain_spec
bahmutov Oct 8, 2019
ddb168d
Add protocol_spec tests
flotwig Oct 8, 2019
dd0b727
do not capture video during performance test
bahmutov Oct 8, 2019
9c64847
Add test for VIDEO_POST_PROCESSING_FAILED warning
flotwig Oct 8, 2019
80d70c6
Merge branch 'develop' into add-cri-4608
bahmutov Oct 9, 2019
9eb37c1
use client.on to register screencast callback
bahmutov Oct 9, 2019
a8e6266
cleanup prettier, extract some functions, switch to browser.family
brian-mann Oct 10, 2019
92c50d8
moar cleanup and fixes
brian-mann Oct 10, 2019
0632635
add logging to the cri-client so we can see every message sent + rece…
brian-mann Oct 10, 2019
0e0013b
bump bluebird to 3.7.0 for .tapCatch addition
brian-mann Oct 10, 2019
e741d1d
Fix unit tests
flotwig Oct 10, 2019
0bdf678
WIP: update e2e test to ensure that duration of the video matches wha…
brian-mann Oct 10, 2019
ed25ffa
Test duration of recorded video
flotwig Oct 10, 2019
6fa7492
Run 6_video_compression in chrome + electron
flotwig Oct 10, 2019
324e7eb
Cleanup
flotwig Oct 10, 2019
3783a49
finish ffmpeg duration verification
brian-mann Oct 10, 2019
c8c3891
Merge branch 'develop' into add-cri-4608
flotwig Oct 11, 2019
5df252d
Update 8_reporters_spec snapshot
flotwig Oct 11, 2019
dcb2a48
Update CRI close logic to monkey-patch browser.kill
flotwig Oct 11, 2019
4d04eb8
add isBrowserFamily back
flotwig Oct 11, 2019
1003598
Merge branch 'develop' into add-cri-4608
flotwig Oct 11, 2019
0631585
make it possible for remote-debugging-port to get overridden
flotwig Oct 11, 2019
bda0e4f
Make CDP timeout 5s; add unit, e2e tests for CDP failure; add user-fr…
flotwig Oct 11, 2019
63d2474
Update tests
flotwig Oct 11, 2019
4e6bd31
Use CYPRESS_REMOTE_DEBUGGING_PORT to set CDP port; update CDP error m…
flotwig Oct 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/server/__snapshots__/2_cdp_spec.ts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
exports['e2e cdp fails when remote debugging port cannot be connected to 1'] = `

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (spec.ts) │
│ Searched: cypress/integration/spec.ts │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: spec.ts... (1 of 1)
Cypress could not make a connection to the Chrome DevTools Protocol after 5 seconds.

Without this, your tests can not run. Please check your Chrome installation and try again.

The CDP port requested was 777.

Error details:

Error: connect ECONNREFUSED 127.0.0.1:777
at stack trace line


`
10 changes: 9 additions & 1 deletion packages/server/__snapshots__/protocol_spec.ts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports['lib/browsers/protocol ._getDelayMsForRetry retries as expected 1'] = [
exports['lib/browsers/protocol ._getDelayMsForRetry retries as expected for up to 5 seconds 1'] = [
100,
100,
100,
Expand All @@ -7,6 +7,14 @@ exports['lib/browsers/protocol ._getDelayMsForRetry retries as expected 1'] = [
100,
100,
100,
100,
100,
500,
500,
500,
500,
500,
500,
500,
500
]
8 changes: 6 additions & 2 deletions packages/server/lib/browsers/protocol.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
const _ = require('lodash')
const CRI = require('chrome-remote-interface')
const { connect } = require('@packages/network')
const errors = require('../errors')
const Promise = require('bluebird')
const la = require('lazy-ass')
const is = require('check-more-types')
const debug = require('debug')('cypress:server:protocol')

function _getDelayMsForRetry (i) {
if (i < 8) {
if (i < 10) {
return 100
}

if (i < 10) {
if (i < 18) {
return 500
}
}
Expand All @@ -23,6 +24,9 @@ function connectAsync (opts) {
...opts,
}, cb)
})
.catch((err) => {
errors.throw('CDP_COULD_NOT_CONNECT', opts.port, err)
})
}

/**
Expand Down
12 changes: 12 additions & 0 deletions packages/server/lib/errors.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,18 @@ getMsgByType = (type, arg1 = {}, arg2) ->

Please do not modify CYPRESS_ENV value.
"""
when "CDP_COULD_NOT_CONNECT"
"""
Cypress could not make a connection to the Chrome DevTools Protocol after 5 seconds.

Without this, your tests can not run. Please check your Chrome installation and try again.
flotwig marked this conversation as resolved.
Show resolved Hide resolved

The CDP port requested was #{chalk.yellow(arg1)}.

Error details:

#{arg2.stack}
"""

get = (type, arg1, arg2) ->
msg = getMsgByType(type, arg1, arg2)
Expand Down
1 change: 1 addition & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"@cypress/debugging-proxy": "2.0.1",
"@cypress/json-schemas": "5.32.2",
"@cypress/sinon-chai": "1.1.0",
"@types/chai-as-promised": "7.1.2",
"babel-plugin-add-module-exports": "1.0.2",
"babelify": "10.0.0",
"bin-up": "1.2.2",
Expand Down
21 changes: 21 additions & 0 deletions packages/server/test/e2e/2_cdp_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const e2e = require('../support/helpers/e2e')
const Fixtures = require('../support/helpers/fixtures')

describe('e2e cdp', function () {
e2e.setup()

it('fails when remote debugging port cannot be connected to', function () {
return e2e.exec(this, {
project: Fixtures.projectPath('remote-debugging-port-removed'),
spec: 'spec.ts',
browser: 'chrome',
expectedExitCode: 1,
snapshot: true,
onStdout: (stdout: string) => {
return stdout
flotwig marked this conversation as resolved.
Show resolved Hide resolved
.replace(/(port requested was )(\d+)/, '$1777')
.replace(/(127\.0\.0\.1:)(\d+)/, '$1777')
},
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
describe('passes', () => {
it('passes', () => {})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const la = require('lazy-ass')

module.exports = (on) => {
on('before:browser:launch', (browser = {}, args) => {
la(browser.family === 'chrome', 'this test can only be run with a chrome-family browser')

// remove debugging port so that the browser connection fails
const newArgs = args.filter((arg) => !arg.startsWith('--remote-debugging-port='))

la(newArgs.length === args.length - 1, 'exactly one argument should have been removed')

return newArgs
})
}
25 changes: 23 additions & 2 deletions packages/server/test/unit/browsers/protocol_spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import '../../spec_helper'
import _ from 'lodash'
import 'chai-as-promised' // for the types!
import chalk from 'chalk'
import { connect } from '@packages/network'
import CRI from 'chrome-remote-interface'
import { expect } from 'chai'
import humanInterval from 'human-interval'
import protocol from '../../../lib/browsers/protocol'
import sinon from 'sinon'
import snapshot from 'snap-shot-it'
import { stripIndents } from 'common-tags'

describe('lib/browsers/protocol', function () {
context('._getDelayMsForRetry', function () {
it('retries as expected', function () {
it('retries as expected for up to 5 seconds', function () {
let delays = []
let delay : number
let i = 0
Expand All @@ -18,16 +23,32 @@ describe('lib/browsers/protocol', function () {
i++
}

expect(_.sum(delays)).to.eq(humanInterval('5 seconds'))

snapshot(delays)
})
})

context('.getWsTargetFor', function () {
it('rejects if CDP connection fails', function () {
sinon.stub(connect, 'createRetryingSocket').callsArgWith(1, new Error('cdp connection failure'))
const innerErr = new Error('cdp connection failure')

sinon.stub(connect, 'createRetryingSocket').callsArgWith(1, innerErr)
const p = protocol.getWsTargetFor(12345)

const expectedError = stripIndents`
Cypress could not make a connection to the Chrome DevTools Protocol after 5 seconds.

Without this, your tests can not run. Please check your Chrome installation and try again.

The CDP port requested was ${chalk.yellow('12345')}.

Error details:
`

return expect(p).to.eventually.be.rejected
.and.property('message').include(expectedError)
.and.include(innerErr.message)
})

it('returns the debugger URL of the first about:blank tab', function () {
Expand Down