How to re-install application before every test run
Scenario: For our application we have 2 login steps
- Manager Login that uses username and password( this is ideally a one time set up of the app with the correct business sites) followed by
- Operator login - 4 digit pin that allows operators to work on the same app.
Once step 1 is successful, on re-starting the app, it only takes you to operator login screen(step 2). The app has to be re-installed to see the manager login again.
Problem: How do I re-install application before every test run so that I am on step 1 before every test?
In the windows driver set-up, I have tried using
opt.AddAdditionalCapability("fullReset", "true");
opt.AddAdditionalCapability("noReset", "false");
but that still only launches the app with the login screen.
Full code snippet here :
` public static WindowsDriver
AppiumOptions opt = new AppiumOptions();
opt.AddAdditionalCapability("appiumVersion", "1.9.1");
opt.AddAdditionalCapability("WindowsDeviceName", "WindowsPC");
opt.AddAdditionalCapability("WindowsPlatformName", "Windows");
// this will let aplication uninstall after every test run
opt.AddAdditionalCapability("fullReset", "true");
opt.AddAdditionalCapability("noReset", "false");
opt.AddAdditionalCapability("app", "31e6402e-0407-4419-a6c3-7c6d18576017_8sedpwrx9t26a!App");
/* opt.AddAdditionalCapability("WindowsAppLocation", @""); opt.AddAdditionalCapability("appArguments", @""); opt.AddAdditionalCapability("appWorkingDir", "");*/
WindowsDriver<WindowsElement> driver = null;
while (true)
{
try
{
driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), opt);
break;
}
catch (WebDriverException e)
{
driver.Quit();
Console.WriteLine("Failed to start the windows driver. Attempt: " + retries);
Console.WriteLine(e);
if (--retries == 0)
{
throw;
}
else
{
// do nothing
}
}
}
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(60);
return driver;
}`
http://appium.io/docs/en/writing-running-appium/other/reset-strategies/index.html Just reading about noReset and fullReset capabilities and take it is not available for UWP apps?
WinAppDriver doesn't support resetting an App natively. You run a PowerShell script to manually uninstall / reinstall an app each time, or you could implement additional logic in your test case to ignore failing step 1 if it reaches step 2 first.
Thanks for confirming that WinAppDriver doesnt support resetting an App natively. I am not sure I want to implement logic to ignore a failing test :) Think we do support an api that unlinks/resets the device. So will do that as a background step before each scenario. Closing the issue now.
Hi, I have the same issue when using WinAppDriver(4.4.5) to run multiple ui tests based on NUnit in .NET 8. Is there any update from official Appium for solving this problem until now? I still can not find any working solution online.