Last active
February 7, 2018 12:08
-
-
Save trix0/871aa9cb3f1d7d5fb0487e323b2d5fb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const opts = { | |
port: jArguments.port, | |
desiredCapabilities: { | |
platformName: "Android", | |
deviceName: "Android", | |
systemPort:jArguments.systemPort, | |
//automationName: "uiautomator2", | |
udid:"", //cd21ccc5 emulator-5554 | |
//app: __dirname+"/apk/pl.apk", | |
appPackage:"com.gorro.nothing", | |
appActivity:"com.gorro.nothing.NothingActivity", | |
// appPackage:"com.pointvoucher.playlondonpv", | |
// appActivity:"com.unity3d.player.UnityPlayerActivity", | |
noReset:jArguments.noReset,////value is true now !!!/////// false adds around 3Sec | |
fullReset:false, | |
newCommandTimeout:120000, | |
skipUnlock:true, | |
} | |
}; | |
async function fnCleanInstall(client,appPackage,activityName,apkFileName){ | |
try{ | |
logger.info("Running clean Install test with following paramters, appPackage: "+appPackage+" activityName: "+activityName+" apkFile: " + __dirname+'/apk/'+apkFileName+'.apk'); | |
// is apk installed ? | |
let appExists= await client.isAppInstalled(appPackage); | |
if(appExists.value){ //if apk installed -> remove | |
logger.info("App exists in device => trying to remove"); | |
await client.removeApp(appPackage).then(()=>{ | |
logger.info("App removed") | |
}) | |
} | |
else{ | |
logger.info("App does not exist in device "); | |
} | |
logger.info("Installing app to device "+ __dirname+'/apk/'+apkFileName+'.apk'); | |
await client.installApp(__dirname+'/apk/'+apkFileName+'.apk') | |
let appExistsAfter= await client.isAppInstalled(appPackage); | |
if(!appExistsAfter.value){ //if apk not installed error | |
logger.info("apk was not installed:"+ appExistsAfter); | |
throw new Error(appExistsAfter+"Apk is not installed"); | |
} | |
logger.info("starting package : " + appPackage+" with activity name: "+activityName); | |
await client.startActivity(appPackage,activityName,"com.android.packageinstaller","com.android.packageinstaller.permission.ui.GrantPermissionsActivity"); | |
await fnPermission(5,true,client); | |
loading=await fnLoading(40,client); | |
client.end(); | |
} | |
catch(err){ | |
client.end(); | |
throw err; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment