public void CreateAndroidDriverInGridWithWebAppByDefaultPasses() { System.Console.WriteLine($"Thread # [{System.Threading.Thread.CurrentThread.ManagedThreadId}]"); //Check if this is true for IOSdriver AndroidDriver <AppiumWebElement> driver = MobileDriver.Get <AndroidDriver <AppiumWebElement> >(); // TestLogs.WriteDeviceLogs(); ServerCommandExecutor executor = new ServerCommandExecutor(this.GetParameters().ServerUri, driver.SessionId); Console.WriteLine($"Current device orientation is:{driver.Orientation}"); executor.Execute("setOrientation", new Dictionary <string, object> { { "orientation", "LANDSCAPE" } }); Console.WriteLine($"New device orientation is: {driver.Orientation}"); TestContext.WriteLine($"Web app SessionId is:[{driver.SessionId}]"); Assert.NotNull(driver, $"driver cannot be null"); /*System.Console.WriteLine($"Server running test [{driver.PlatformName}]");*/ driver.Navigate().GoToUrl("http://google.com"); System.Console.WriteLine($"Curretn activity:{driver.CurrentActivity}"); Wait.ForPageToLoad(); AppiumWebElement searchTextControl = driver.FindElement(By.CssSelector("div.SDkEP input.gLFyf"), 10); searchTextControl.Click(); searchTextControl.SendKeys("Hello there@@"); Wait.Seconds(3); Assert.AreEqual(driver.Contexts.Count, 2, "Multiple Contexts"); Assert.AreEqual(driver.Context.ToString(), "CHROMIUM", "Expected Chromium context"); OpenQA.Selenium.Remote.Response result1 = executor.Execute("getAvailableLogTypes"); Console.WriteLine($"Supported Log Types:\n {result1.ToJson()}"); }
public void CanExecuteValidServerCommandSuccessfully() { ServerCommandExecutor executor = new ServerCommandExecutor(); Response res = executor.Execute("getAvailableLogTypes"); Assert.True(res.Status == OpenQA.Selenium.WebDriverResult.Success, "Response should have been successful for valid command."); }
public void NullSessionIdThrows() { Uri uri = Helper.CreateUri("localhost", "1234", @"/wd/hub"); ServerCommandExecutor executor = new ServerCommandExecutor(uri, null); string commandToExecute = "someTestCommand"; Assert.Throws <ArgumentNullException>(() => executor.Execute(commandToExecute), "null session id should throw"); }
public void NullUriThrows() { Uri uri = Helper.CreateUri("localhost", "1234", @"/wd/hub"); SessionId id = new SessionId("testKey"); ServerCommandExecutor executor = new ServerCommandExecutor(null, id); string commandToExecute = "getAvailableLogs"; Assert.Throws <ArgumentNullException>(() => executor.Execute(commandToExecute), "null uri should throw"); }
public void InvalidCommandThrows() { Uri uri = Helper.CreateUri("localhost", "1234", @"/wd/hub"); SessionId id = new SessionId("testKey"); ServerCommandExecutor executor = new ServerCommandExecutor(uri, id); string commandToExecute = "someTestCommand"; Assert.Throws <NotSupportedException>(() => executor.Execute(commandToExecute), "unsupported command should throw"); }
public void NullCommandToExecuteParameterThrows() { Uri uri = Helper.CreateUri("localhost", "1234", @"/wd/hub"); SessionId id = new SessionId("testKey"); ServerCommandExecutor executor = new ServerCommandExecutor(uri, id); string commandToExecute = null; Assert.Throws <ArgumentNullException>(() => executor.Execute(commandToExecute), "null or empty command should throw."); }
public void Execute() { while (_responses.TryDequeue(out var response)) { switch (response) { case NetworkThreadResponse.StartSuccess: Logger.I.Log(this, "Server is working"); State = ServerState.Working; break; case NetworkThreadResponse.StartFailure: Logger.I.Log(this, "Server start failed"); State = ServerState.Stopped; break; case NetworkThreadResponse.Stoppoed: Logger.I.Log(this, "Server is stopped"); ClearBuffers(); while (_eventsToHandle.TryDequeue(out _)) { } State = ServerState.Stopped; break; } } if (State != ServerState.Working) { return; } while (_eventsToHandle.TryDequeue(out var @event)) { unsafe { switch (@event.EventType) { case EventType.Connect: _handler.OnClientConnected(@event.Peer); break; case EventType.Disconnect: _handler.OnClientDisconnected(@event.Peer); break; case EventType.Receive: _currentPeerId = (ushort)@event.Peer.ID; _handler.CurrentClientId = _currentPeerId; var e = _game.GetEntityWithConnection(_currentPeerId); if (e == null) { Marshal.FreeHGlobal(@event.Data); break; } var headerSpan = new ReadOnlySpan <ushort>(@event.Data.ToPointer(), 2); var commandCount = headerSpan[0]; var commandLength = headerSpan[1]; if (commandCount > 0) { var commandsSpan = new ReadOnlySpan <byte>(IntPtr.Add(@event.Data, 4).ToPointer(), commandLength); _fromClients.Clear(); _fromClients.FromSpan(ref commandsSpan, commandLength); ServerCommandExecutor.Execute(_handler, _fromClients, commandCount); } Marshal.FreeHGlobal(@event.Data); _currentPeerId = ushort.MaxValue; break; case EventType.Timeout: _handler.OnClientDisconnected(@event.Peer); break; } } } }
public void InvalidServerCommandThrows() { ServerCommandExecutor executor = new ServerCommandExecutor(); Assert.Throws <NotSupportedException>(() => executor.Execute("testCommand"), "Response should have been un-successful for valid command."); }