Skip to content
Merged
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions app-runner/Private/DeviceProviders/SauceLabsProvider.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ class SauceLabsProvider : DeviceProvider {
}
}

[void] TerminateApp([string]$baseUri, [string]$packageName) {
$appParameter = if ($this.MobilePlatform -eq 'Android') { 'appId' } else { 'bundleId' }
try {
$body = @{
script = 'mobile: terminateApp'
args = @{ $appParameter = $packageName }
}
$this.InvokeSauceLabsApi('POST', "$baseUri/execute/sync", $body, $false, $null) | Out-Null
}
catch {
Write-Warning "$($this.Platform): Terminate request failed: $_"
}
}

[hashtable] RunApplication([string]$ExecutablePath, [string[]]$Arguments, [string]$LogFilePath = $null, [string]$WorkingDirectory = $null) {
Write-Debug "$($this.Platform): Running application: $ExecutablePath"

Expand All @@ -327,6 +341,9 @@ class SauceLabsProvider : DeviceProvider {
$activityName = $parsed.ActivityName
$this.CurrentPackageName = $packageName

# Terminate the app so the next launch starts fresh.
$this.TerminateApp($baseUri, $packageName)

# Launch activity with Intent extras
Write-Host "Launching: $packageName/$activityName" -ForegroundColor Cyan

Expand Down Expand Up @@ -361,6 +378,9 @@ class SauceLabsProvider : DeviceProvider {
$bundleId = $ExecutablePath
$this.CurrentPackageName = $bundleId

# Terminate the app so the next launch starts fresh.
$this.TerminateApp($baseUri, $bundleId)

Write-Host "Launching: $bundleId" -ForegroundColor Cyan
if ($Arguments) {
Write-Host " Arguments: $Arguments" -ForegroundColor Cyan
Expand Down
Loading