Skip to content

Commit e757002

Browse files
committed
feat: automatically start the Appium server locally
1 parent 5ef02f8 commit e757002

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

Desktop.Tests/e2e/Drivers/AppiumWindowsDriver.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
using System;
2+
using System.IO;
23
using OpenQA.Selenium.Appium;
4+
using OpenQA.Selenium.Appium.Service;
35

46
namespace Desktop.Tests.e2e.Drivers;
57

68
public abstract class AppiumWindowsDriver : IDisposable
79
{
8-
private const string DefaultServerUri = "http://127.0.0.1:4723/";
10+
private const string AppiumServerLogPath = "AppiumServerLog.txt";
11+
12+
private const string AppiumServerIp = "127.0.0.1";
13+
private const int AppiumServerPort = 4723;
14+
15+
private static readonly string DefaultServerUri =
16+
$"http://{AppiumServerIp}:{AppiumServerPort}/";
917

1018
protected readonly Uri ServerUri = new(
1119
Environment.GetEnvironmentVariable("APPIUM_HOST") ?? DefaultServerUri);
@@ -17,5 +25,10 @@ public abstract class AppiumWindowsDriver : IDisposable
1725
PlatformName = "Windows"
1826
};
1927

28+
protected readonly AppiumLocalService AppiumLocalService = new AppiumServiceBuilder()
29+
.WithIPAddress(AppiumServerIp).UsingPort(AppiumServerPort)
30+
.WithLogFile(new FileInfo(AppiumServerLogPath))
31+
.Build();
32+
2033
public abstract void Dispose();
2134
}

Desktop.Tests/e2e/Drivers/MainWindowDriver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class MainWindowDriver : AppiumWindowsDriver
1212

1313
public MainWindowDriver()
1414
{
15+
AppiumLocalService.Start();
16+
1517
Options.App = Path.GetFullPath(
1618
Path.Combine(
1719
Environment.CurrentDirectory,

0 commit comments

Comments
 (0)