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

Appium Android Fixes #438

Merged
merged 5 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicAppiumSample", "MauiApp\BasicAppiumNunitSample.csproj", "{9F570461-4215-4CF7-A157-BFEB7BDACFCE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicAppiumNunitSample", "MauiApp\BasicAppiumNunitSample.csproj", "{9F570461-4215-4CF7-A157-BFEB7BDACFCE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UITests.Android", "UITests.Android\UITests.Android.csproj", "{9C1F3C00-352A-4E7C-93E1-441E7B85DC7A}"
EndProject
Expand All @@ -26,6 +26,7 @@ Global
{9F570461-4215-4CF7-A157-BFEB7BDACFCE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{9F570461-4215-4CF7-A157-BFEB7BDACFCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F570461-4215-4CF7-A157-BFEB7BDACFCE}.Release|Any CPU.Build.0 = Release|Any CPU
{9F570461-4215-4CF7-A157-BFEB7BDACFCE}.Release|Any CPU.Deploy.0 = Release|Any CPU
{9C1F3C00-352A-4E7C-93E1-441E7B85DC7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C1F3C00-352A-4E7C-93E1-441E7B85DC7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C1F3C00-352A-4E7C-93E1-441E7B85DC7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' AND $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' ">
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
using Android.Runtime;

namespace BasicAppiumSample;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[Register("com.companyname.basicappiumsample.MainActivity")]
public class MainActivity : MauiAppCompatActivity
{
}
38 changes: 27 additions & 11 deletions 8.0/UITesting/BasicAppiumNunitSample/UITests.Android/AppiumSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.Enums;

namespace UITests;

Expand All @@ -19,27 +20,42 @@ public void RunBeforeAnyTests()
// This line starts a local Appium server for you as part of the test run
AppiumServerHelper.StartAppiumLocalServer();


var androidOptions = new AppiumOptions
{
// Specify UIAutomator2 as the driver, typically don't need to change this
AutomationName = "UIAutomator2",
// Always Android for Android
PlatformName = "Android",
// This is the Android version, not API level
// This is ignored if you use the avd option below
PlatformVersion = "13",
// The full path to the .apk file to test or the package name if the app is already installed on the device
App = "com.companyname.basicappiumsample",

// RELEASE BUILDS
// The full path to the .apk file
// This only works with release builds because debug builds have fast deployment enabled
// and Appium isn't compatible with fast deployment
// App = Path.Join(TestContext.CurrentContext.TestDirectory, "../../../../MauiApp/bin/Release/net8.0-android/com.companyname.basicappiumsample-Signed.apk"),
};

// Specifying the avd option will boot the emulator for you
// make sure there is an emulator with the name below
// If not specified, make sure you have an emulator booted
//androidOptions.AddAdditionalAppiumOption("avd", "pixel_5_-_api_33");
// DEBUG BUILD SETUP
// If you're running your tests against debug builds you'll need to set NoReset to true
// otherwise appium will delete all the libraries used for Fast Deployment on Android
// Release builds have Fast Deployment disabled
// https://learn.microsoft.com/en-us/xamarin/android/deploy-test/building-apps/build-process#fast-deployment
jfversluis marked this conversation as resolved.
Show resolved Hide resolved
androidOptions.AddAdditionalAppiumOption(MobileCapabilityType.NoReset, "true");
androidOptions.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppPackage, "com.companyname.basicappiumsample");

//Make sure to set [Register("com.companyname.basicappiumsample.MainActivity")] on the MainActivity of your android application
androidOptions.AddAdditionalAppiumOption(AndroidMobileCapabilityType.AppActivity, $"com.companyname.basicappiumsample.MainActivity");
// END DEBUG BUILD SETUP


// Specifying the avd option will boot the emulator for you
// make sure there is an emulator with the name below
// If not specified, make sure you have an emulator booted
//androidOptions.AddAdditionalAppiumOption("avd", "pixel_5_-_api_33");

// Note there are many more options that you can use to influence the app under test according to your needs
// Note there are many more options that you can use to influence the app under test according to your needs

driver = new AndroidDriver(androidOptions);
driver = new AndroidDriver(androidOptions);
}

[OneTimeTearDown]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\UITests.Shared\**\*.cs" LinkBase="Shared" Visible="false" />
<Compile Include="..\UITests.Shared\**\*.cs" LinkBase="Shared" Visible="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="Appium.WebDriver" Version="5.0.0-rc.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\UITests.Shared\**\*.cs" LinkBase="Shared" Visible="false" />
<Compile Include="..\UITests.Shared\**\*.cs" LinkBase="Shared" Visible="false" />
</ItemGroup>

</Project>
Loading