Skip to content

Commit

Permalink
Retry Appium local server starting (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
mialeska authored Feb 20, 2023
1 parent 9613b1a commit 53037ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ namespace Aquality.Appium.Mobile.Applications
{
public abstract class ApplicationFactory : IApplicationFactory
{
protected virtual IActionRetrier ActionRetrier => new CustomActionRetrier();

public abstract IMobileApplication Application { get; }

protected virtual AppiumDriver GetDriver(Uri serviceUrl)
{
var platformName = AqualityServices.ApplicationProfile.PlatformName;
var driverOptions = AqualityServices.ApplicationProfile.DriverSettings.AppiumOptions;
var commandTimeout = AqualityServices.Get<ITimeoutConfiguration>().Command;
return new CustomActionRetrier().DoWithRetry(
return ActionRetrier.DoWithRetry(
() => CreateSession(platformName, serviceUrl, driverOptions, commandTimeout));
}

Expand Down Expand Up @@ -52,7 +54,8 @@ protected class CustomActionRetrier : ActionRetrier
"appium settings app is not running",
"socket hang up",
"stream was destroyed",
"invalid or unrecognized response"
"invalid or unrecognized response",
"has been expired"
};

public CustomActionRetrier()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenQA.Selenium.Appium.Service;
using OpenQA.Selenium.Appium.Service.Exceptions;

namespace Aquality.Appium.Mobile.Applications
{
Expand All @@ -9,7 +10,7 @@ public override IMobileApplication Application
get
{
var service = new AppiumServiceBuilder().WithArguments(AqualityServices.LocalServiceSettings.ServerOptions).Build();
service.Start();
ActionRetrier.DoWithRetry(service.Start, new [] { typeof(AppiumServerHasNotBeenStartedLocallyException)} );
var driver = GetDriver(service.ServiceUrl);
LogApplicationIsReady();
return new Application(driver, service);
Expand Down

0 comments on commit 53037ed

Please sign in to comment.