Skip to content

Commit 968886b

Browse files
authored
[Tests] Update to Appium 5.0.0 (#23118)
* Update to appium 5.0.0 Their driver has some removed methods (LaunchApp/CloseApp) which seem to be now implemented for windows. Also removed an extra explicit ref to system.drawing.common since it comes in transitively from appium.webdriver package (and the version was causing issues since the newer appium.webdriver uses a newer version). * Fix windows launchapp/closeapp for newer appium In Appium's dotnet driver in v5.0.0 they removed `LaunchApp` from the driver: appium/dotnet-client#766 The deprecation suggests using `ActivateApp` as an alternative, but that throws an error saying it's not implemented on the windows driver. Curiously, `CloseApp` which was also marked as deprecated was _moved_ from the base appium driver to the `WindowsDriver` here: appium/dotnet-client#773 I think the same treatment should have been done to the `LaunchApp` method since there's no alternative in windows. For now the workaround is to invoke the command manually: `windowsDriver.ExecuteScript("windows: launchApp", [_app.GetAppId()]);`
1 parent 51720b9 commit 968886b

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.7" />
13+
<PackageReference Include="Appium.WebDriver" Version="5.0.0" />
1414
<PackageReference Include="NUnit" Version="4.0.1" />
1515
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
1616
</ItemGroup>

src/Controls/tests/TestCases.Mac.Tests/Controls.TestCases.Mac.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.7" />
13+
<PackageReference Include="Appium.WebDriver" Version="5.0.0" />
1414
<PackageReference Include="NUnit" Version="4.0.1" />
1515
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
1616
</ItemGroup>

src/Controls/tests/TestCases.WinUI.Tests/Controls.TestCases.WinUI.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.7" />
13+
<PackageReference Include="Appium.WebDriver" Version="5.0.0" />
1414
<PackageReference Include="NUnit" Version="4.0.1" />
1515
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
1616
</ItemGroup>

src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.7" />
13+
<PackageReference Include="Appium.WebDriver" Version="5.0.0" />
1414
<PackageReference Include="NUnit" Version="4.0.1" />
1515
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
1616
</ItemGroup>

src/TestUtils/src/UITest.Appium/Actions/AppiumLifecycleActions.cs

+14-11
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,21 @@ CommandResponse LaunchApp(IDictionary<string, object> parameters)
5555
return CommandResponse.FailedEmptyResponse;
5656

5757
if (_app.GetTestDevice() == TestDevice.Mac)
58-
{
58+
{
5959
_app.Driver.ExecuteScript("macos: activateApp", new Dictionary<string, object>
6060
{
6161
{ "bundleId", _app.GetAppId() },
6262
});
6363
}
64-
else if (_app.GetTestDevice() == TestDevice.Windows)
64+
else if (_app.Driver is WindowsDriver windowsDriver)
6565
{
66-
#pragma warning disable CS0618 // Type or member is obsolete
67-
_app.Driver.LaunchApp();
68-
#pragma warning restore CS0618 // Type or member is obsolete
66+
// Appium driver removed the LaunchApp method in 5.0.0, so we need to use the executeScript method instead
67+
// Currently the appium-windows-driver reports the following commands as compatible:
68+
// startRecordingScreen,stopRecordingScreen,launchApp,closeApp,deleteFile,deleteFolder,
69+
// click,scroll,clickAndDrag,hover,keys,setClipboard,getClipboard
70+
windowsDriver.ExecuteScript("windows: launchApp", [_app.GetAppId()]);
6971
}
70-
else
72+
else
7173
{
7274
_app.Driver.ActivateApp(_app.GetAppId());
7375
}
@@ -127,7 +129,7 @@ CommandResponse CloseApp(IDictionary<string, object> parameters)
127129
}
128130
catch (Exception)
129131
{
130-
// TODO Pass in logger so we can log these exceptions
132+
// TODO: Pass in logger so we can log these exceptions
131133

132134
// Occasionally the app seems to get so locked up it can't
133135
// even report back the appstate. In that case, we'll just
@@ -143,11 +145,12 @@ CommandResponse CloseApp(IDictionary<string, object> parameters)
143145
{ "bundleId", _app.GetAppId() },
144146
});
145147
}
146-
else if (_app.GetTestDevice() == TestDevice.Windows)
148+
else if (_app.Driver is WindowsDriver windowsDriver)
147149
{
148-
#pragma warning disable CS0618 // Type or member is obsolete
149-
_app.Driver.CloseApp();
150-
#pragma warning restore CS0618 // Type or member is obsolete
150+
// This is still here for now, but it looks like it will get removed just like
151+
// LaunchApp was in 5.0.0, in which case we may need to use:
152+
// windowsDriver.ExecuteScript("windows: closeApp", [_app.GetAppId()]);
153+
windowsDriver.CloseApp();
151154
}
152155
else
153156
{

src/TestUtils/src/UITest.Appium/UITest.Appium.csproj

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.7" />
11-
<PackageReference Include="System.Drawing.Common" Version="8.0.3" />
10+
<PackageReference Include="Appium.WebDriver" Version="5.0.0" />
1211
</ItemGroup>
1312

1413
<ItemGroup>

0 commit comments

Comments
 (0)