Skip to content

Commit

Permalink
render script: attach functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
amitzur committed Jun 14, 2020
1 parent 792be17 commit e520e8c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/sdk-shared/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ const args = yargs
type: 'string',
coerce: processRunBefore,
})
.option('attach', {
describe: 'attach to existing chrome via remote debugging port',
type: 'boolean',
})
.help().argv

const [url] = args._
Expand Down Expand Up @@ -265,7 +269,9 @@ if (!url) {
logger.log(`[render script] process versions: ${JSON.stringify(process.versions)}`)
console.log('log file at:', logFilePath)

await spec.visit(driver, url)
if (!args.attach) {
await spec.visit(driver, url)
}

try {
if (runBeforeFunc) {
Expand Down Expand Up @@ -324,7 +330,9 @@ if (!url) {

console.log('\nRender results:\n', resultsStr)
} finally {
await spec.cleanup(driver)
if (!args.attach) {
await spec.cleanup(driver)
}
if (args.webdriverProxy) {
await chromedriver.stop()
}
Expand All @@ -341,12 +349,14 @@ function buildDriver({
driverServer,
isMobileEmulation,
deviceName,
attach,
} = {}) {
const capabilities = {
browserName: 'chrome',
'goog:chromeOptions': {
args: headless ? ['--headless'] : [],
mobileEmulation: isMobileEmulation ? {deviceName} : undefined,
debuggerAddress: attach ? '127.0.0.1:9222' : undefined,
},
...driverCapabilities,
}
Expand Down

0 comments on commit e520e8c

Please sign in to comment.