@@ -6,12 +6,13 @@ import os from 'os';
66import path from 'path' ;
77import untildify from 'untildify' ;
88import { prompt } from 'inquirer' ;
9+ import boxen from 'boxen' ;
910
1011import Logger from '../../logger' ;
1112import { getPlatformName , symbols } from '../../utils' ;
1213import { getAlreadyRunningAvd , killEmulatorWithoutWait , launchAVD } from './adb' ;
1314import {
14- ABI , AVAILABLE_OPTIONS , BINARY_TO_PACKAGE_NAME , DEFAULT_CHROME_VERSION ,
15+ ABI , AVAILABLE_OPTIONS , BINARY_TO_PACKAGE_NAME , DEFAULT_CHROME_VERSIONS ,
1516 DEFAULT_FIREFOX_VERSION , NIGHTWATCH_AVD , SETUP_CONFIG_QUES
1617} from './constants' ;
1718import { AndroidSetupResult , Options , OtherInfo , Platform , SdkBinary , SetupConfigs } from './interfaces' ;
@@ -736,7 +737,7 @@ export class AndroidSetup {
736737 const verifyChrome = browsers . includes ( 'chrome' ) ;
737738
738739 let firefoxLatestVersion = '' ;
739- let installedChromeVersion = DEFAULT_CHROME_VERSION ;
740+ let installedChromeVersion = '' ;
740741
741742 let installFirefox = false ;
742743 let downloadChromedriver = false ;
@@ -921,11 +922,13 @@ export class AndroidSetup {
921922 }
922923
923924 if ( downloadChromedriver ) {
924- if ( installedChromeVersion === DEFAULT_CHROME_VERSION ) {
925+ const chromeMajorVersion = installedChromeVersion . split ( '.' ) [ 0 ] ;
926+ if ( DEFAULT_CHROME_VERSIONS . includes ( chromeMajorVersion ) ) {
925927 Logger . log ( 'Downloading chromedriver to work with the factory version of Chrome browser...' ) ;
926928
929+ const chromedriverDownloadLink = ( DOWNLOADS . chromedriver as any ) [ chromeMajorVersion ] [ this . platform ] ;
927930 const result = await downloadWithProgressBar (
928- DOWNLOADS . chromedriver [ this . platform ] ,
931+ chromedriverDownloadLink ,
929932 chromedriverDownloadDir ,
930933 true
931934 ) ;
@@ -935,7 +938,7 @@ export class AndroidSetup {
935938 status . setupChrome = true ;
936939 } else {
937940 Logger . log ( `\n${ colors . red ( 'Failed!' ) } You can download the chromedriver yourself from the below link:` ) ;
938- Logger . log ( colors . cyan ( ` ${ DOWNLOADS . chromedriver [ this . platform ] } ` ) ) ;
941+ Logger . log ( colors . cyan ( ` ${ chromedriverDownloadLink } ` ) ) ;
939942 Logger . log (
940943 ' (Extract and copy the chromedriver binary and paste it in your Nightwatch project inside \'chromedriver-mobile\' folder.)' ,
941944 '\n'
@@ -945,16 +948,17 @@ export class AndroidSetup {
945948 if ( status . setupChrome ) {
946949 Logger . log ( 'You can run your tests now on your Android Emulator\'s Chrome browser.\n' ) ;
947950 }
951+ } else if ( installedChromeVersion === '' ) {
952+ Logger . log ( colors . red ( symbols ( ) . fail ) , 'chromedriver could not be downloaded (installed browser version unknown).\n' ) ;
948953 } else {
949- Logger . log ( colors . cyan ( '[CHROMEDRIVER]' ) ) ;
950- Logger . log ( 'Installed Chrome browser version is different from factory version.\n' ) ;
951- Logger . log ( 'You can download the chromedriver for current version from the below link:' ) ;
952- Logger . log ( colors . cyan ( ' https://chromedriver.storage.googleapis.com/index.html' ) ) ;
953- Logger . log (
954- ' (Extract and copy the chromedriver binary and paste it in your Nightwatch project inside \'chromedriver-mobile\' folder.)' ,
955- '\n'
956- ) ;
957- status . setupChrome = true ; // because we have done what we could do, i.e., setup from our side is complete.
954+ Logger . log ( boxen (
955+ colors . cyan ( '[CHROMEDRIVER]\n\n' ) +
956+ colors . red ( 'Could not download chromedriver (installed Chrome version is different from the factory versions).\n\n' ) +
957+ 'You can download chromedriver for the installed Chrome version from the below link:\n' +
958+ colors . cyan ( ' https://chromedriver.storage.googleapis.com/index.html\n\n' ) +
959+ 'After downloading, extract the zip file, copy the extracted chromedriver binary, and put in inside \'chromedriver-mobile\' folder in your Nightwatch project.' ,
960+ { padding : 1 }
961+ ) , '\n' ) ;
958962 }
959963 }
960964 }
@@ -995,7 +999,7 @@ export class AndroidSetup {
995999 }
9961000 } else {
9971001 Logger . log ( `${ colors . red ( 'Error:' ) } Some requirements failed to set up.` ) ;
998- Logger . log ( 'Please try running the failed commands by yourself and then re-run this tool.\n' ) ;
1002+ Logger . log ( 'Please look for the errors above and try running any failed commands by yourself and then re-run this tool.\n' ) ;
9991003
10001004 Logger . log ( 'If it still fails, please raise an issue with us at:' ) ;
10011005 Logger . log ( colors . cyan ( ' https://github.com/nightwatchjs/mobile-helper-tool/issues' ) , '\n' ) ;
0 commit comments