public void ScreenShot() { if (TestContext.CurrentContext.Result.Outcome == ResultState.Failure) { ScreenshotUtils.Snap(_driver); } }
public string ScreenshotBase64(Point start, Point end) { start.Offset(Window.Position); end.Offset(Window.Position); return(ScreenshotUtils.GetBase64(start, end)); }
void Awake() { if (ScreenshotUtils.Instance != null) { Destroy(gameObject); } instance = this; DontDestroyOnLoad(this); }
public void SetBlur() { Camera[] cameras = new Camera[] { Camera.main }; BlurUtils.BlurCameras(cameras); Texture2D texture2D = ScreenshotUtils.Screenshot(cameras, TextureFormat.RGB24); mask.color = Color.white; mask.texture = texture2D; BlurUtils.UnBlurCameras(cameras); }
public void GetShippingPageVP() { try { System.Threading.Thread.Sleep(4000); IWebElement element = navegador.FindElement(By.Id("HOOK_BEFORECARRIER")); Report.Log(LogStatus.Pass, "ShippingPage successfully acessed!", ScreenshotUtils.Capture()); } catch { Report.Log(LogStatus.Error, "Page Not Found!", ScreenshotUtils.Capture()); throw new NoSuchElementException("Page Not Found!"); } }
public void GetHomePageVP() { try { string element = navegador.FindElement(By.PartialLinkText("Faded Short Sleeve T-shirts")).Text; Assert.AreEqual(element, "Faded Short Sleeve T-shirts"); Report.Log(LogStatus.Pass, "Test Automation Practice Homepage successfully executed!", ScreenshotUtils.Capture()); } catch { Report.Log(LogStatus.Error, "Page Not Found!", ScreenshotUtils.Capture()); throw new NoSuchElementException("Page Not Found!"); } }
public void GetAddressPageVP() { try { System.Threading.Thread.Sleep(4000); IWebElement element = navegador.FindElement(By.Id("customer_firstname")); Report.Log(LogStatus.Pass, "AddressPage successfully acessed!", ScreenshotUtils.Capture()); } catch { Report.Log(LogStatus.Error, "Page Not Found!", ScreenshotUtils.Capture()); throw new NoSuchElementException("Page Not Found!"); } }
public void Setup() { extentReportUtils.createATestCase("Setup"); string browserType = configuration["browserType"]; url = configuration["baseUrl"]; extentReportUtils.addTestLog(Status.Info, "Browser Type - " + browserType); extentReportUtils.addTestLog(Status.Info, "Base Url - " + url); CmdDriver = new CommonDriver(browserType); CmdDriver.NavigateTo(url); screenshot = new ScreenshotUtils(CmdDriver.Driver); }
public void GetSignInPageVP() { try { IWebElement element = navegador.FindElement(By.Id("authentication")); System.Threading.Thread.Sleep(10000); IJavaScriptExecutor jse = (IJavaScriptExecutor)navegador; jse.ExecuteScript("window.scrollBy(0,650)"); Report.Log(LogStatus.Pass, "SignInPage successfully acessed!", ScreenshotUtils.Capture()); } catch { Report.Log(LogStatus.Error, "Page Not Found!", ScreenshotUtils.Capture()); throw new NoSuchElementException("Page Not Found!"); } }
public ScreenshotModel() { var status = new Subject <string>().AddTo(Disposer); StatusMsg = status.AsObservable(); SaveToSpecified .Select(_ => ScreenshotUtils.Take(SaveFolder.Value)) .Do(OpenImageFile) .Select(_ => "スクリーンショットを取得しました。") .Catch(Observable.Return("スクリーンショットの取得に失敗しました。")) .Repeat() .Subscribe(status) .AddTo(Disposer); var result = new Subject <string>().AddTo(Disposer); DragAreaMouseMove .Where(e => e.Button.HasFlag(MouseButtons.Left)) .Select(_ => ScreenshotUtils.Take(Path.GetTempPath())) .Do(f => CompleteSaveToTemp(f)) .Catch(Observable.Return("")) .Repeat() .Subscribe(result) .AddTo(Disposer); result .Select(f => string.IsNullOrEmpty(f) ? "スクリーンショットの取得に失敗しました。" : "スクリーンショットを取得しました。") .Subscribe(status) .AddTo(Disposer); result .Where(f => !string.IsNullOrEmpty(f)) .Delay(TimeSpan.FromSeconds(5)) .Do(File.Delete) .Repeat() .Subscribe() .AddTo(Disposer); OpenSaveFolder .Select(_ => SaveFolder.Value) .StartProcess() .Select(r => r ? "フォルダを開きました。" : "フォルダを開けませんでした。") .Subscribe(status) .AddTo(Disposer); }
public String GetTituloVP() { try { String titulo; titulo = navegador.FindElement(By.XPath("//h3[contains(text(),'More info')]")).Text; Assert.AreEqual(titulo, "MORE INFO"); Report.Log(LogStatus.Pass, "DescriptionPage successfully accessed!", ScreenshotUtils.Capture()); return(titulo); } catch { Report.Log(LogStatus.Error, "Page Not Found!", ScreenshotUtils.Capture()); throw new NoSuchElementException("Page Not Found!"); } }
public String GetTituloVP() { try { String titulo; titulo = navegador.FindElement(By.LinkText("Proceed to checkout")).Text; Assert.AreEqual(titulo, "Proceed to checkout"); Report.Log(LogStatus.Pass, "ConfirmationPage successfully acessed!", ScreenshotUtils.Capture()); return(titulo); } catch { Report.Log(LogStatus.Error, "Page Not Found!", ScreenshotUtils.Capture()); throw new NoSuchElementException("Page Not Found!"); } }
public String GetTituloVP2() { try { String titulo; titulo = navegador.FindElement(By.XPath("//span [text()='Faded Short Sleeve T-shirts']")).Text; Assert.AreEqual(titulo, "Faded Short Sleeve T-shirts"); Report.Log(LogStatus.Pass, "Product Added!", ScreenshotUtils.Capture()); return(titulo); } catch { Report.Log(LogStatus.Error, "Product Not Added!", ScreenshotUtils.Capture()); throw new NoSuchElementException("Product Not Added!"); } }
void TakeScreenshot() { _isWritingScreenshot = true; var renderTexture = RenderTexture.GetTemporary(_screenshotResolution.Width, _screenshotResolution.Height, 24, RenderTextureFormat.Default); _cameraRenderer.Render(renderTexture); try { var screenshot = ScreenshotUtils.CopyFromRenderTexture(renderTexture, _screenshotTexture); WriteScreenshot(screenshot); } catch (Exception) { _isWritingScreenshot = false; throw; } finally { RenderTexture.ReleaseTemporary(renderTexture); } }
/// <summary> /// Shares a screenshot on one of the available social platforms. /// </summary> /// <param name="screenshotWidth">Width of the screenshot.</param> /// <param name="screenshotHeight">Height of the screenshot.</param> /// <param name="screenshotCamera">The camera used to take the screenshot.</param> /// <param name="useOneCamera">if set to <c>true</c> take screenshot as seen by one camera. /// Else, take screenshot as seen by player (views of all cameras combined).</param> /// <param name="shareMessage">The message to share along with the screenshot.</param> /// <param name="screenshotFilePath">The path to the prepared screenshot, if available. /// Else, this is the path to save the screenshot to.</param> /// <param name="screenshotProvided">if set to <c>true</c> the screenshot is already provided /// in the specified file path, and needs only to be shared.</param> /// <param name="deleteOnShare">if set to <c>true</c> delete the local copy of the screenshot /// after it has been successfully shared.</param> private void MultiShareScreenshot(int screenshotWidth, int screenshotHeight, Camera screenshotCamera, bool useOneCamera, string shareMessage, string screenshotFilePath, bool screenshotProvided, bool deleteOnShare) { // If width is not specified, use screen width int width = (screenshotWidth > 0) ? screenshotWidth : Screen.width; // If height is not specified, use screen height int height = (screenshotHeight > 0) ? screenshotHeight : Screen.height; // If camera is not specified, use main camera Camera camera = (screenshotCamera != null) ? screenshotCamera : Camera.main; // If file path is not specified, save the screenshot to a generic location string filePath = !string.IsNullOrEmpty(screenshotFilePath) ? screenshotFilePath : Application.persistentDataPath + "/CRCScreen_" + DateTime.Now.GetTimestamp() + ".png"; // Take screenshot and save it to file if (!screenshotProvided || (screenshotProvided && string.IsNullOrEmpty(screenshotFilePath))) { if (useOneCamera) { // Screenshot as seen from one camera Texture2D screenshot = ScreenshotUtils.TakeScreenshotSave(width, height, camera, filePath); UpdateScreenshot(screenshot); } else { // Screenshot as seen by player Application.CaptureScreenshot(filePath); } } // Open the multishare window and pass in the screenshot path SoomlaProfile.MultiShare(shareMessage, filePath); // Delete local copy of screenshot // TODO: Wait until multishare finishes before deleting if (deleteOnShare && ScreenshotUtils.IsScreenshotReady(filePath)) { //System.IO.File.Delete(filePath); } }
public void SetUp() { extentReport.CreateATestCase("Setup"); string browserType = _configuration["browserType"]; extentReport.AddTestLog(Status.Info, "Browsertype - " + browserType); cmnDriver = new CommonDriver(browserType); string baseUrl = _configuration["baseUrl"];; cmnDriver.navigateToFirstUrl(baseUrl); driver = cmnDriver.Driver; loginPage = new Guru99LoginPage(driver); screenshotUtils = new ScreenshotUtils(driver); }
public void TearDown() { ScreenshotUtils.TakeScreenshot(TestContext); QuitBrowser(); }
/// <summary> /// Takes a screenshot. /// </summary> /// <param name="focus">The focus of the screenshot.</param> /// <param name="screenshotDir">The screenshot direction.</param> /// <returns>The screenshot texture</returns> public Texture2D TakeScreenshot(Vector3 focus, ScreenshotDir screenshotDir, string scoreText, string topScoreText) { // Enable screenshot camera to take the screenshot m_screenshotCamera.gameObject.SetActive(true); // Lazy init UIText if (!m_scoreText.IsInitialized) { m_scoreText.Initialize(); } if (!m_topScoreText.IsInitialized) { m_topScoreText.Initialize(); } // Set up score and top score display m_scoreText.SetText(scoreText); m_topScoreText.SetText(topScoreText); // Rotate dir around the x and y axes float vertAngle = m_vertAngleOffset + Random.Range(-m_randomDeltaAngle, m_randomDeltaAngle); float horAngle = Random.Range(-m_randomDeltaAngle, m_randomDeltaAngle); // Screenshot can be taken obliquely from the right or from the left of the subject float horAngleOffsetSign = (Random.value > 0.5f) ? 1.0f : -1.0f; switch (screenshotDir) { case ScreenshotDir.Front: horAngle += m_horAngleOffset * horAngleOffsetSign; break; case ScreenshotDir.Side_Left: horAngle += -90.0f; break; case ScreenshotDir.Side_Right: horAngle += 90.0f; break; case ScreenshotDir.Back: horAngle += 180.0f + m_horAngleOffset * horAngleOffsetSign; break; } // Get the direction vector from the subject to the screenshot position // (i.e. where camera should take the screenshot from) Vector3 focusToScreenshotPosDir = Quaternion.Euler(vertAngle, -horAngle, 0.0f) * Vector3.back; // Set camera distance and vertical offset from the subject float camDist = m_screenshotCamDist + Random.Range(-m_randomDeltaDist, m_randomDeltaDist); focus.y += m_verticalOffset; // Move camera to the screenshot position and make it look at the focus point m_screenshotCamera.transform.position = focus + focusToScreenshotPosDir * camDist; m_screenshotCamera.transform.LookAt(focus); // Take screenshot m_screenshotResult = ScreenshotUtils.TakeScreenshot(m_screenshotWidth, m_screenshotHeight, m_screenshotCamera); // Disable screenshot camera once screenshot has been taken m_screenshotCamera.gameObject.SetActive(false); return(m_screenshotResult); }
/// <summary> /// Saves the last screenshot taken. /// </summary> /// <param name="filePath">The file path.</param> /// <returns>Whether screenshot saving was successful</returns> public bool SaveLastScreenshot(string filePath) { return(ScreenshotUtils.SaveScreenshot(m_screenshotResult, filePath)); }
private void WriteScreenshot(Screenshot screenshot) { Debug.Log(_screenshotsPath); ScreenshotUtils.Write2File(_screenshotsPath, screenshot, useAlphaChannel: false, onComplete: _onWritingScreenshotComplete); }