Skip to content

Commit 90fc594

Browse files
author
Jenkins
committed
activate app with timeout
1 parent 51087a5 commit 90fc594

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/Appium.Net/Appium/AppiumDriver.cs

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

140140
public void ActivateApp(string appId) =>
141141
Execute(AppiumDriverCommand.ActivateApp, AppiumCommandExecutionHelper.PrepareArgument("appId", appId));
142+
143+
public void ActivateApp(string appId, TimeSpan timeout) =>
144+
Execute(AppiumDriverCommand.ActivateApp,
145+
AppiumCommandExecutionHelper.PrepareArguments(new string[] {"appId", "options"},
146+
new object[]
147+
{appId, new Dictionary<string, object>() {{"timeout", (long) timeout.TotalMilliseconds}}}));
142148

143149
public bool TerminateApp(string appId) =>
144150
Convert.ToBoolean(Execute(AppiumDriverCommand.TerminateApp,

test/integration/Android/Device/AppTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ public void CanActivateAppTest()
4343
//Verify the expected app was activated
4444
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.Id(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)));
4652

53+
//Verify the expected app was activated
54+
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.Id(IntentAppElement)));
55+
}
4756
[Test]
4857
public void CanActivateAppFromBackgroundTest()
4958
{

test/integration/IOS/Device/AppTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ public void CanActivateAppTest()
4646
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.AccessibilityId(IosTestAppElement)));
4747
}
4848

49+
[Test]
50+
public void CanActivateAppWithTimeoutTest()
51+
{
52+
//Activate an app to foreground
53+
Assert.DoesNotThrow(() => _driver.ActivateApp(IosTestAppBundleId, TimeSpan.FromSeconds(20)));
54+
55+
//Verify the expected app was activated
56+
Assert.DoesNotThrow(() => _driver.FindElement(MobileBy.AccessibilityId(IosTestAppElement)));
57+
}
58+
4959
[Test]
5060
public void CanActivateViaScriptAppTest()
5161
{

0 commit comments

Comments
 (0)