browser . addCommand ( 'chooseFile' , async function ( this , localFilePath ) { try { const remoteFile = await browser . uploadFile ( localFilePath ) ; return this . addValue ( remoteFile ) ; } catch { console . log ( 'Cannot upload file, fallback to add value.' ) ; return this . addValue ( localFilePath ) ; } } , true ) ;