public void DragNDrop_ExtensionApi_IsExecuted() { Navigate("/E2ETestDragnDrop"); try { // Given var tempFile = Path.GetTempFileName(); File.WriteAllText(tempFile, "Hello world"); Disposables.Add(() => File.Delete(tempFile)); // When Browser.FindElement(By.Id("testDropEvents")).Click(); var dropZone = Browser.FindElement(By.Id("drop-zone")); DropFile(Browser, new FileInfo(tempFile), dropZone, 0, 0); // Then var value = Browser.FindElement(By.Id("testDropEventsValues")).GetAttribute("value"); var nl = Environment.NewLine; Assert.Equal(@$ "{nl}OnDragOverMethod{nl}OnDragOverScript{nl}OnDropMethod{nl}OnDropScript", value); } finally { Disposables?.ForEach(d => d?.Invoke()); } }
public void DragNDropHotPath_ReadsFile() { Navigate("/E2ETestDragnDrop"); try { var dropZone = Browser.FindElement(By.Id("drop-zone")); var tempFile = Path.GetTempFileName(); var expectedOutput = $@"IFileInfo.Name: {Path.GetFileName(tempFile)} Read 11 bytes. 11 / 11 --DONE"; File.WriteAllText(tempFile, "Hello world"); Disposables.Add(() => File.Delete(tempFile)); DropFile(Browser, new FileInfo(tempFile), dropZone, 0, 0); var gobutton = Browser.FindElement(By.Id("read-file")); gobutton.Click(); try { new WebDriverWait(Browser, TimeSpan.FromSeconds(5)).Until( driver => driver.FindElement(By.Id("debug-output")).Text.Contains("--DONE")); } catch (OpenQA.Selenium.WebDriverTimeoutException) { Assert.Equal(expectedOutput, Browser.FindElement(By.Id("debug-output")).Text); } var finalOutput = Browser.FindElement(By.Id("debug-output")).Text; Assert.Equal(expectedOutput, Browser.FindElement(By.Id("debug-output")).Text); } finally { Disposables?.ForEach(d => d?.Invoke()); } }
private void HashFileHotPath(bool useMemoryStream, int?bufferSize) { //Arrange Navigate("/E2ETestHash"); try { var(filePath, expectedOutput) = HashFile(useMemoryStream, true, bufferSize); //Act var fileInputElement = Browser.FindElement(By.Id("file-input")); fileInputElement.SendKeys(filePath); if (bufferSize.HasValue) { var bufferSizeElement = Browser.FindElement(By.Id("buffer-size")); bufferSizeElement.SendKeys(bufferSize.Value.ToString()); } var gobutton = Browser.FindElement(By.Id(useMemoryStream ? "full-ram-button" : "chunked-button")); gobutton.Click(); try { new WebDriverWait(Browser, TimeSpan.FromSeconds(5)).Until( driver => driver.FindElement(By.Id("debug-output")).Text.Contains("--DONE")); } catch (OpenQA.Selenium.WebDriverTimeoutException) { Assert.Equal(expectedOutput, Browser.FindElement(By.Id("debug-output")).Text); } var expectedOutputList = expectedOutput.Split(Environment.NewLine); var actualList = Browser.FindElement(By.Id("debug-output")).Text.Split(Environment.NewLine); var lineCount = 0; //Assert for (int i = 0; i < expectedOutputList.Length; i++) { var lineInd = $"Line {lineCount.ToString().PadLeft(2)}:"; var expected = expectedOutputList[i]; var actual = actualList.Length > i ? actualList[i] : $"index out of bounds (length={actualList.Length})"; Assert.Equal($"{lineInd}:{expected}", $"{lineInd}:{actual}"); lineCount++; } // Act 2 fileInputElement.SendKeys(filePath); gobutton = Browser.FindElement(By.Id(useMemoryStream ? "full-ram-offset-button" : "chunked-offset-button")); gobutton.Click(); try { new WebDriverWait(Browser, TimeSpan.FromSeconds(5)).Until( driver => driver.FindElement(By.Id("debug-output")).Text.Contains("--DONE")); } catch (OpenQA.Selenium.WebDriverTimeoutException) { Assert.Equal(expectedOutput, Browser.FindElement(By.Id("debug-output")).Text); } actualList = Browser.FindElement(By.Id("debug-output")).Text.Split(Environment.NewLine); lineCount = 0; //Assert for (int i = 0; i < expectedOutputList.Length; i++) { var lineInd = $"Line {lineCount.ToString().PadLeft(2)}:"; var expected = expectedOutputList[i]; var actual = actualList.Length > i ? actualList[i] : $"index out of bounds (length={actualList.Length})"; Assert.Equal($"{lineInd}:{expected}", $"{lineInd}:{actual}"); lineCount++; } } finally { Disposables?.ForEach(d => d?.Invoke()); } }
public void Dispose() => Disposables?.ForEach(disposable => disposable?.Dispose());
public void Dispose() => Disposables.ForEach(disposable => { try { disposable?.Dispose(); disposable = null; } catch (Exception) {; } });