<commit_before>using System;
using MaintainableSelenium.MvcPages.BrowserCamera.Lens;
using MaintainableSelenium.MvcPages.SeleniumUtils;
using MaintainableSelenium.MvcPages.Utils;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Remote;

namespace MaintainableSelenium.MvcPages.BrowserCamera
{
    /// <summary>
    /// Responsible for taking screenshots of the page
    /// </summary>
    public class BrowserCamera : IBrowserCamera
    {
        private readonly RemoteWebDriver driver;
        private readonly IBrowserCameraLens lens;

        public BrowserCamera(RemoteWebDriver driver, IBrowserCameraLens lens)
        {
            this.driver = driver;
            this.lens = lens;
        }

        public byte[] TakeScreenshot()
        {
            try
            {
                driver.Blur();
                var currentActiveElement = driver.GetActiveElement();
                MoveMouseOffTheScreen();
                var screenshot = this.lens.TakeScreenshot();
                if (currentActiveElement.TagName != "body")
                {
                    driver.HoverOn(currentActiveElement);
                }
                return screenshot;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.GetFullExceptionMessage());
                throw;
            }
        }

        private void MoveMouseOffTheScreen()
        {
            var body = driver.FindElementByTagName("body");
            var scrollY = driver.GetScrollY();
            new Actions(driver).MoveToElement(body, 0, scrollY).Perform();
        }
<commit_msg>Fix taking off mouse from the screen. Ignore exception.<commit_after>using System;
using MaintainableSelenium.MvcPages.BrowserCamera.Lens;
using MaintainableSelenium.MvcPages.SeleniumUtils;
using MaintainableSelenium.MvcPages.Utils;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Remote;

namespace MaintainableSelenium.MvcPages.BrowserCamera
{
    /// <summary>
    /// Responsible for taking screenshots of the page
    /// </summary>
    public class BrowserCamera : IBrowserCamera
    {
        private readonly RemoteWebDriver driver;
        private readonly IBrowserCameraLens lens;

        public BrowserCamera(RemoteWebDriver driver, IBrowserCameraLens lens)
        {
            this.driver = driver;
            this.lens = lens;
        }

        public byte[] TakeScreenshot()
        {
            try
            {
                driver.Blur();
                var currentActiveElement = driver.GetActiveElement();
                MoveMouseOffTheScreen();
                var screenshot = this.lens.TakeScreenshot();
                if (currentActiveElement.TagName != "body")
                {
                    driver.HoverOn(currentActiveElement);
                }
                return screenshot;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.GetFullExceptionMessage());
                throw;
            }
        }

        private void MoveMouseOffTheScreen()
        {
            try
            {
                var body = driver.FindElementByTagName("body");
                var scrollY = driver.GetScrollY();
                new Actions(driver).MoveToElement(body, 0, scrollY + 1).Perform();
           }
           catch {}
        }

{'fraction_non_alphanumeric': 0.08027454491196657, 'fraction_numerical': 0.0008952551477170994, 'mean_word_length': 1.7748344370860927, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7491570', 'n_tokens_mistral': 886, 'n_tokens_neox': 833, 'n_words': 171}