Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Removal of obsolete CloseApp #773

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/Appium.Net/Appium/AppiumCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public class AppiumCommand
new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.GetPerformanceDataTypes,
"/session/{sessionId}/appium/performanceData/types"),

#region (Deprecated) legacy app management
#region (WinAppDriver) legacy app management

new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.CloseApp,
new AppiumCommand(HttpCommandInfo.PostCommand, WindowsDriverCommand.CloseApp,
"/session/{sessionId}/appium/app/close"),

#endregion (Deprecated) legacy app management
#endregion (WinAppDriver) legacy app management

new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.BackgroundApp,
"/session/{sessionId}/appium/app/background"),
Expand Down
3 changes: 0 additions & 3 deletions src/Appium.Net/Appium/AppiumDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ public void PushFile(string pathOnDevice, byte[] base64Data) =>
public void PushFile(string pathOnDevice, FileInfo file) =>
AppiumCommandExecutionHelper.PushFile(this, pathOnDevice, file);

[Obsolete("The CloseApp API is deprecated and will be removed in future versions. Please use TerminateApp instead \r\n See https://github.com/appium/appium/issues/15807")]
public void CloseApp() => ((IExecuteMethod)this).Execute(AppiumDriverCommand.CloseApp);

public void FingerPrint(int fingerprintId) =>
AppiumCommandExecutionHelper.FingerPrint(this, fingerprintId);

Expand Down
9 changes: 0 additions & 9 deletions src/Appium.Net/Appium/AppiumDriverCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,6 @@ public class AppiumDriverCommand
/// </summary>
public const string ToggleLocationServices = "toggleLocationServices";

#region (Deprecated) legacy app management

/// <summary>
/// Close App Command.
/// </summary>
public const string CloseApp = "closeApp";

#endregion (Deprecated) legacy app management

/// <summary>
/// Background App Command.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions src/Appium.Net/Appium/Interfaces/IInteractsWithApps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public interface IInteractsWithApps : IExecuteMethod
/// <return>a boolean indicating if the app was terminated in the given timeout.</return>
bool TerminateApp(string appId, TimeSpan timeout);

/// <summary>
/// Closes the current app.
/// </summary>
void CloseApp();

/// <summary>
/// Gets the State of the app.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Appium.Net/Appium/Windows/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ public void LongPressKeyCode(int keyCode, int metastate = -1) =>

#region App management

public new void CloseApp()
public void CloseApp()
{
((IExecuteMethod)this).Execute(AppiumDriverCommand.CloseApp);
((IExecuteMethod)this).Execute(WindowsDriverCommand.CloseApp);
}

#endregion App management
Expand Down
30 changes: 30 additions & 0 deletions src/Appium.Net/Appium/Windows/WindowsDriverCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//See the NOTICE file distributed with this work for additional
//information regarding copyright ownership.
//You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.

namespace OpenQA.Selenium.Appium
{
public class WindowsDriverCommand
{

#region legacy app management

/// <summary>
/// Close App Command.
/// </summary>
public const string CloseApp = "closeApp";

#endregion legacy app management

}
}
7 changes: 4 additions & 3 deletions test/integration/Android/SettingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ namespace Appium.Net.Integration.Tests.Android
public class SettingTest
{
private AndroidDriver _driver;
private readonly string _appName = "androidApiDemos";

[OneTimeSetUp]
public void BeforeAll()
{
var capabilities = Env.ServerIsRemote()
? Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"))
: Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"));
? Caps.GetAndroidUIAutomatorCaps(Apps.Get(_appName))
: Caps.GetAndroidUIAutomatorCaps(Apps.Get(_appName));
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
_driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec);
_driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec;
_driver.CloseApp();
_driver.TerminateApp(Apps.GetId(_appName));
}

[Test]
Expand Down
13 changes: 7 additions & 6 deletions test/integration/Android/WaitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@ public class WaitTests
{
private AndroidDriver _driver;
private WebDriverWait _waitDriver;
private TimeSpan _driverTimeOut = TimeSpan.FromSeconds(5);
private readonly TimeSpan _driverTimeOut = TimeSpan.FromSeconds(5);
private readonly string _appKey = "androidApiDemos";

[OneTimeSetUp]
public void BeforeAll()
{
var capabilities = Env.ServerIsRemote()
? Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"))
: Caps.GetAndroidUIAutomatorCaps(Apps.Get("androidApiDemos"));
? Caps.GetAndroidUIAutomatorCaps(Apps.Get(_appKey))
: Caps.GetAndroidUIAutomatorCaps(Apps.Get(_appKey));
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
_driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec);
}

[SetUp]
public void SetUp()
{
_driver.StartActivity("io.appium.android.apis", ".ApiDemos");
_driver.StartActivity(Apps.GetId(_appKey), ".ApiDemos");
_waitDriver = new WebDriverWait(_driver, _driverTimeOut);
_waitDriver.IgnoreExceptionTypes(typeof(NoSuchElementException));
}
Expand All @@ -53,7 +54,7 @@ public void WebDriverWaitElementNotFoundTestCase()
[Test]
public void WebDriverWaitIsWaitingTestCase()
{
Stopwatch stopWatch = new Stopwatch();
Stopwatch stopWatch = new();
stopWatch.Start();

try
Expand All @@ -76,7 +77,7 @@ public void AfterAll()
{
if (_driver != null)
{
_driver.CloseApp();
_ = _driver.TerminateApp(Apps.GetId(_appKey));
_driver?.Quit();
}
if (!Env.ServerIsRemote())
Expand Down
5 changes: 2 additions & 3 deletions test/integration/ServerTests/StartingAppLocallyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public void StartingAndroidAppWithCapabilitiesAndServiceTest()
}
}


[Test]
public void StartingAndroidAppWithCapabilitiesOnTheServerSideTest()
{
Expand Down Expand Up @@ -97,7 +96,7 @@ public void StartingIosAppWithCapabilitiesOnlyTest()
try
{
driver = new IOSDriver(capabilities, Env.InitTimeoutSec);
driver.CloseApp();
driver.TerminateApp(Apps.GetId("iosTestApp"));
}
finally
{
Expand All @@ -120,7 +119,7 @@ public void StartingIosAppWithCapabilitiesAndServiceTest()
try
{
driver = new IOSDriver(builder, capabilities, Env.InitTimeoutSec);
driver.CloseApp();
driver.TerminateApp(Apps.GetId("iosTestApp"));
}
finally
{
Expand Down
17 changes: 10 additions & 7 deletions test/integration/Windows/ClickElementTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ public class ClickElementTest
{
private WindowsDriver _calculatorSession;
protected static WebElement CalculatorResult;
private readonly string _appId = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App";

[OneTimeSetUp]
public void BeforeAll()
{
var appCapabilities = new AppiumOptions();
appCapabilities.AutomationName = "Windows";
appCapabilities.App = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App";
appCapabilities.DeviceName = "WindowsPC";
appCapabilities.PlatformName = "Windows";
var appCapabilities = new AppiumOptions
{
AutomationName = "Windows",
App = _appId,
DeviceName = "WindowsPC",
PlatformName = "Windows"
};

var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
_calculatorSession = new WindowsDriver(serverUri, appCapabilities,
Expand All @@ -49,8 +52,8 @@ public void BeforeAll()
public void OneTimeTearDown()
{
CalculatorResult = null;
_calculatorSession.CloseApp();
_calculatorSession.Dispose();
_calculatorSession?.CloseApp();
_calculatorSession?.Dispose();
_calculatorSession = null;
}

Expand Down
13 changes: 8 additions & 5 deletions test/integration/Windows/ImagesComparisonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ public class ImagesComparisonTests
{
private WindowsDriver _calculatorSession;
protected static WebElement CalculatorResult;
private readonly string _appId = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App";

[OneTimeSetUp]
public void BeforeAll()
{
var appCapabilities = new AppiumOptions();
appCapabilities.App = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App";
appCapabilities.DeviceName = "WindowsPC";
appCapabilities.PlatformName = "Windows";
appCapabilities.AutomationName = "Windows";
var appCapabilities = new AppiumOptions
{
App = _appId,
DeviceName = "WindowsPC",
PlatformName = "Windows",
AutomationName = "Windows"
};

var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
_calculatorSession = new WindowsDriver(serverUri, appCapabilities,
Expand Down