Skip to content

Commit ad0296d

Browse files
authored
feat: added the ability to activate the app with timeout (#570)
1 parent 16663cb commit ad0296d

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Appium.Net/Appium/AppiumDriver.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ public void RemoveApp(string appId) =>
241241

242242
public void ActivateApp(string appId) =>
243243
Execute(AppiumDriverCommand.ActivateApp, AppiumCommandExecutionHelper.PrepareArgument("appId", appId));
244+
245+
public void ActivateApp(string appId, TimeSpan timeout) =>
246+
Execute(AppiumDriverCommand.ActivateApp,
247+
AppiumCommandExecutionHelper.PrepareArguments(new string[] {"appId", "options"},
248+
new object[]
249+
{appId, new Dictionary<string, object>() {{"timeout", (long) timeout.TotalMilliseconds}}}));
244250

245251
public bool TerminateApp(string appId) =>
246252
Convert.ToBoolean(Execute(AppiumDriverCommand.TerminateApp,

test/integration/Android/Device/AppTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ public void CanActivateAppTest()
4343
//Verify the expected app was activated
4444
Assert.DoesNotThrow(() => _driver.FindElementById(IntentAppElement));
4545
}
46+
47+
[Test]
48+
public void CanActivateAppWithTimeoutTest()
49+
{
50+
//Activate an app to foreground
51+
Assert.DoesNotThrow(() => _driver.ActivateApp(IntentAppPackageName, TimeSpan.FromSeconds(20)));
52+
53+
//Verify the expected app was activated
54+
Assert.DoesNotThrow(() => _driver.FindElementById(IntentAppElement));
55+
}
4656

4757
[Test]
4858
public void CanActivateAppFromBackgroundTest()

test/integration/IOS/Device/AppTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@ public void CanActivateAppTest()
4545
//Verify the expected app was activated
4646
Assert.DoesNotThrow(() => _driver.FindElementByAccessibilityId(IosTestAppElement));
4747
}
48+
49+
[Test]
50+
public void CanActivateAppWithTimeoutTest()
51+
{
52+
//Activate an app to foreground
53+
Assert.DoesNotThrow(() => _driver.ActivateApp(IosTestAppBundleId, TimeSpan.FromSeconds(20)));
4854

55+
//Verify the expected app was activated
56+
Assert.DoesNotThrow(() => _driver.FindElementById(IosTestAppBundleId));
57+
}
58+
4959
[Test]
5060
public void CanActivateViaScriptAppTest()
5161
{

0 commit comments

Comments
 (0)