From 66e8699afe28497fd85135d7df31172e9ba1c19b Mon Sep 17 00:00:00 2001 From: maxluli Date: Thu, 27 Apr 2023 15:59:52 +0200 Subject: [PATCH] Still not working lol --- Test_Merge/F1TVEmulator.cs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Test_Merge/F1TVEmulator.cs b/Test_Merge/F1TVEmulator.cs index c5d6ecc..17cbd58 100644 --- a/Test_Merge/F1TVEmulator.cs +++ b/Test_Merge/F1TVEmulator.cs @@ -68,6 +68,17 @@ namespace Test_Merge service.Port = 5555; FirefoxOptions options = new FirefoxOptions(); + options.SetPreference("media.peerconnection.enabled", false); + + //FirefoxProfile profile = new FirefoxProfile(); + //profile.SetPreference("layout.css.devPixelsPerPx", "2.0"); + //options.Profile = profile; + + FirefoxProfile profile = new FirefoxProfile(); + profile.SetPreference("media.navigator.video.default_width", 1920); + profile.SetPreference("media.navigator.video.default_height", 1080); + options.Profile = profile; + options.AddArgument("--window-size=" + windowWidth + "," + windowHeight + ""); options.AddArgument("--disable-web-security"); options.AddArgument("--same-site-none-secure"); @@ -93,9 +104,15 @@ namespace Test_Merge var loginSessionCookie = new Cookie(loginSessionCookieName, loginSessionValue, COOKIE_HOST, "/", DateTime.Now.AddDays(5)); Actions actions = new Actions(Driver); - Driver.Navigate().GoToUrl("https://f1tv.formula1.com/"); + //TEST + //Driver.Manage().Window.Position = new Point(0, 0); + //Driver.Manage().Window.Size = new Size(1920, 1080); + Screenshot screenshot = ((ITakesScreenshot)Driver).GetScreenshot(); + screenshot.SaveAsFile(@"C:\Users\Moi\Desktop\imgDump\Decode\FirstTest.png", ScreenshotImageFormat.Png); + //TEST + Driver.Manage().Cookies.AddCookie(loginCookie); Driver.Manage().Cookies.AddCookie(loginSessionCookie); @@ -181,18 +198,27 @@ namespace Test_Merge } public Bitmap Screenshot() { + //bitmovinplayer-video-slave-embeddedPlayer Bitmap result = new Bitmap(100, 100); if (Ready) { + /* Screenshot scrsht = ((ITakesScreenshot)Driver).GetScreenshot(); // Get the raw bytes of the screenshot + */ + //Driver.Manage().Window.Position = new Point(0, 0); + //Driver.Manage().Window.Size = new Size(1920, 1080); + + IWebElement element = Driver.FindElement(By.Id("bitmovinplayer-video-slave-embeddedPlayer")); + Screenshot scrsht = ((ITakesScreenshot)element).GetScreenshot(); + byte[] screenshotBytes = Convert.FromBase64String(scrsht.AsBase64EncodedString); // Create a new MemoryStream from the bytes MemoryStream stream = new MemoryStream(screenshotBytes); // Create a new Bitmap object from the MemoryStream result = new Bitmap(stream); } - + result.Save(@"C:\Users\Moi\Desktop\imgDump\Decode\Test.png"); return result; } public string GetCookie(string host, string name)