public void ScreenRecordWithOptionsTest() { _driver.StartRecordingScreen( AndroidStartScreenRecordingOptions.GetAndroidStartScreenRecordingOptions() .WithTimeLimit(TimeSpan.FromSeconds(10)) .WithBitRate(500000) .WithVideoSize("720x1280")); Thread.Sleep(1000); var result = _driver.StopRecordingScreen(); Assert.IsNotEmpty(result); }
////For returning the value inside of a text field of a keyword given //public string ReturnTextBoxValue(string locator) //{ // IWebElement Control = waitDriver.Until(ExpectedConditions.ElementIsVisible(By.Id(locator))); // return Control.GetAttribute("value"); //} ////Method For Scrolling //public void Scroll(string locator) //{ // waitDriver.Until(ExpectedConditions.ElementExists(By.Id(locator))); // { // IWebElement elementbutton = waitDriver.Until(ExpectedConditions.ElementExists(By.Id(locator))); // IJavaScriptExecutor js = (IJavaScriptExecutor)driver; // js.ExecuteScript("arguments[0].scrollIntoView();", elementbutton); // // var elmnt = document.getElementById("content"); // // elmnt.scrollIntoView(); // IWebElement button = waitDriver.Until(ExpectedConditions.ElementToBeClickable(By.Id(locator))); // // js.executeScript("arguments[0].scrollIntoView();", locator); // } //} ////For returning the background color from the web page of the keyword given //public string ReturnBackgroundColorKeywordValue(string locator) //{ // IWebElement Control = waitDriver.Until(ExpectedConditions.ElementIsVisible(By.Id(locator))); // string color = Control.GetCssValue("background-color"); // String[] hexValue = color.Replace("rgba(", "").Replace(")", "").Split(','); // int hexValue1 = Convert.ToInt32(hexValue[0]); // hexValue[1] = hexValue[1].Trim(); // int hexValue2 = Convert.ToInt32(hexValue[1]); // hexValue[2] = hexValue[2].Trim(); // int hexValue3 = Convert.ToInt32(hexValue[2]); // //string color_actual = ColorTranslator.FromHtml(color); // Color myColor = Color.FromArgb(hexValue1, hexValue2, hexValue3); // string hex = myColor.R.ToString("X2") + myColor.G.ToString("X2") + myColor.B.ToString("X2"); // return hex; //} ////For Taking Video public static void Start_Video() { try { AndroidDriver <AndroidElement> driver = (AndroidDriver <AndroidElement>)ContextPage.Driver; AndroidStartScreenRecordingOptions sd = new AndroidStartScreenRecordingOptions(); sd.WithBitRate(500000); sd.WithVideoSize("720x1280"); driver.StartRecordingScreen(sd); } catch (Exception exception) { throw new AssertFailedException(exception.Message); } }
/// <summary> /// 开始录制屏幕 /// </summary> /// <param name="logOutput"> 是否打印执行日志 </param> public void StartRecordingScreen(bool logOutput = true) { try { AndroidDriver.StartRecordingScreen(AndroidStartScreenRecordingOptions .GetAndroidStartScreenRecordingOptions() .WithTimeLimit(TimeSpan.FromSeconds(10)) .WithBitRate(500000) .WithVideoSize("720x1280")); if (logOutput) { LogServe.Info($"设备开始录制屏幕"); } } catch (Exception Err) { LogServe.Error($"Error:: 设备录制屏幕异常: { Err.Message }"); throw; } }