From 2c2239427c2b2d5bbeed36019351439540872f58 Mon Sep 17 00:00:00 2001 From: maxluli Date: Tue, 2 May 2023 16:52:52 +0200 Subject: [PATCH] NOW IT FUCKING DOES NOT SUCK ANYMORE LETSGOOOOOOOOOOOO --- README.md | 7 +++++- Test_Merge/F1TVEmulator.cs | 45 +++++++++++++++++++++++++++++--------- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 793d234..69959d4 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,9 @@ you will need to take a couple of folders and files in the /bin/debug or /bin/re You need to take the recoverCookiesCSV.py in ./Test_Merge and put it in the /bin/... folder Same for the all geckodriver-v0.xx.x-win32 folder -You also have to change the TESS_DATA_FOLDER constant in the Windows.cs file. A small one is included in the project files \ No newline at end of file +You also have to change the TESS_DATA_FOLDER constant in the Windows.cs file. A small one is included in the project files + +Add those two environnement variables : + +1. MOZ_HEADLESS_WIDTH => 3840 +2. MOZ_HEADLESS_HEIGHT => 2160 \ No newline at end of file diff --git a/Test_Merge/F1TVEmulator.cs b/Test_Merge/F1TVEmulator.cs index eddbb5f..6946ce9 100644 --- a/Test_Merge/F1TVEmulator.cs +++ b/Test_Merge/F1TVEmulator.cs @@ -92,17 +92,30 @@ namespace Test_Merge string loginSessionValue = GetCookie(COOKIE_HOST, loginSessionCookieName); int windowWidth = 1920; - int windowHeight = 1200; + int windowHeight = 768; var service = FirefoxDriverService.CreateDefaultService(GECKODRIVER_FILENAME); service.Host = "127.0.0.1"; service.Port = 5555; + FirefoxProfile profile = new FirefoxProfile(); FirefoxOptions options = new FirefoxOptions(); + //profile.SetPreference("full-screen-api.ignore-widgets", true); + //profile.SetPreference("media.hardware-video-decoding.enabled", true); + //profile.SetPreference("full-screen-api.enabled", true); + options.Profile = profile; + profile.SetPreference("layout.css.devPixelsPerPx", "1.0"); + options.AcceptInsecureCertificates = true; options.AddArgument("--headless"); - options.AddArgument("--width="+windowWidth); - options.AddArgument("--height="+windowHeight); + //options.AddArgument("--start-maximized"); + //options.AddArgument("--window-size=1920x1080"); + //options.AddArgument("--width=" + windowWidth); + //options.AddArgument("--height=" + windowHeight); + //options.AddArgument("-window-size=1920x1080"); + //options.AddArgument("--width=1920"); + //options.AddArgument("--height=1080"); + //profile try { @@ -146,6 +159,7 @@ namespace Test_Merge catch { //Could not locate the cookie button + Screenshot("ERROR104"); Driver.Dispose(); return 104; } @@ -173,10 +187,10 @@ namespace Test_Merge // It does not matter if the feed is paused because when changing channel it autoplays actions.SendKeys(OpenQA.Selenium.Keys.Space).Perform(); //Clicks on the settings Icon - + int tries = 0; bool success = false; - while (tries < 50 && !success) + while (tries < 100 && !success) { Thread.Sleep(100); try @@ -196,16 +210,19 @@ namespace Test_Merge tries++; } } - - if(success = false) + + if (!success) { Screenshot("ERROR105"); Driver.Dispose(); return 105; } - + + Screenshot("BEFOREFULLSCREEN"); //Makes the feed fullscreen + //Driver.Manage().Window.Size = new System.Drawing.Size(windowWidth, windowHeight); + Driver.Manage().Window.Maximize(); WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10)); try { @@ -219,6 +236,8 @@ namespace Test_Merge return 106; } + Screenshot("AFTERFULLSCREEN"); + //STARTUP FINISHED READY TO SCREENSHOT Ready = true; return 0; @@ -228,13 +247,19 @@ namespace Test_Merge Bitmap result = new Bitmap(4242, 6969); try { - Screenshot scrsht = ((ITakesScreenshot)Driver).GetScreenshot(); + //Screenshot scrsht = ((ITakesScreenshot)Driver).GetScreenshot(); + //profileriver.SetPreference("layout.css.devPixelsPerPx", "1.0"); + + //Screenshot scrsht = Driver.GetFullPageScreenshot(); + Screenshot scrsht = Driver.GetScreenshot(); + byte[] screenshotBytes = Convert.FromBase64String(scrsht.AsBase64EncodedString); MemoryStream stream = new MemoryStream(screenshotBytes); result = new Bitmap(stream); - result.Save(name + ".png"); + //result.Save(name + ".png"); + scrsht.SaveAsFile(name + ".png"); } catch {