using System; using OpenQA.Selenium.Appium.Windows; using Xamarin.UITest; namespace Xamarin.Forms.Core.UITests { internal class WindowsTestServer : ITestServer { readonly WindowsDriver _session; readonly WinDriverApp _winDriverApp; public WindowsTestServer(WindowsDriver session, WinDriverApp winDriverApp) { _session = session; _winDriverApp = winDriverApp; } public string Post(string endpoint, object arguments = null) { throw new NotImplementedException(); } public string Put(string endpoint, byte[] data) { throw new NotImplementedException(); } public string Get(string endpoint) { if (endpoint == "version") { try { return _session.CurrentWindowHandle; } catch (OpenQA.Selenium.WebDriverException we) when (we.Message.Contains("Currently selected window has been closed")) { _winDriverApp.RestartFromCrash(); } catch (Exception exception) { WindowsTestBase.HandleAppClosed(exception); throw; } } return endpoint; } } }