<commit_before>﻿using OpenQA.Selenium;
using Riganti.Utils.Testing.Selenium.Core.Exceptions;
using System;
using System.Drawing.Imaging;
using System.Linq;
using System.Net;
using System.Threading;
using OpenQA.Selenium.Interactions;
using Riganti.Utils.Testing.Selenium.Core.Api;
using Riganti.Utils.Testing.Selenium.Core.Configuration;
using Riganti.Utils.Testing.Selenium.Core.Drivers;

namespace Riganti.Utils.Testing.Selenium.Core
{
    public class BrowserWrapper
    {

        private readonly IWebBrowser browser;
        private readonly IWebDriver driver;
        private readonly ITestInstance testInstance;

        public int ActionWaitTime { get; set; }

        public string BaseUrl => testInstance.TestConfiguration.BaseUrl;


        /// <summary>
        /// Generic representation of browser driver.
        /// </summary>
        public IWebDriver Driver
        {
            get
            {
                ActivateScope();
                return driver;
            }
        }

        private ScopeOptions ScopeOptions { get; set; }

        public BrowserWrapper(IWebBrowser browser, IWebDriver driver, ITestInstance testInstance, ScopeOptions scope)
        {
            this.browser = browser;
            this.driver = driver;

            this.testInstance = testInstance;
            ActionWaitTime = browser.Factory?.TestSuiteRunner?.Configuration.TestRunOptions.ActionTimeout ?? 250;

            ScopeOptions = scope;
            SetCssSelector();
        }

        public void SetTimeouts(TimeSpan pageLoadTimeout, TimeSpan implicitlyWait)
        {
            var timeouts = Driver.Manage().Timeouts();
            timeouts.PageLoad = pageLoadTimeout;
            timeouts.ImplicitWait = implicitlyWait;
        }

        private Func<string, By> selectMethodFunc;

        public virtual Func<string, By> SelectMethod
        {
            get { return selectMethodFunc; }
            set
            {
                if (value == null)
                { throw new ArgumentException("SelectMethod cannot be null. This method is used to select elements from loaded page."); }
                selectMethodFunc = value;
            }
        }<commit_msg>Comment for SetTimeouts method<commit_after>﻿using OpenQA.Selenium;
using Riganti.Utils.Testing.Selenium.Core.Exceptions;
using System;
using System.Drawing.Imaging;
using System.Linq;
using System.Net;
using System.Threading;
using OpenQA.Selenium.Interactions;
using Riganti.Utils.Testing.Selenium.Core.Api;
using Riganti.Utils.Testing.Selenium.Core.Configuration;
using Riganti.Utils.Testing.Selenium.Core.Drivers;

namespace Riganti.Utils.Testing.Selenium.Core
{
    public class BrowserWrapper
    {

        private readonly IWebBrowser browser;
        private readonly IWebDriver driver;
        private readonly ITestInstance testInstance;

        public int ActionWaitTime { get; set; }

        public string BaseUrl => testInstance.TestConfiguration.BaseUrl;


        /// <summary>
        /// Generic representation of browser driver.
        /// </summary>
        public IWebDriver Driver
        {
            get
            {
                ActivateScope();
                return driver;
            }
        }

        private ScopeOptions ScopeOptions { get; set; }

        public BrowserWrapper(IWebBrowser browser, IWebDriver driver, ITestInstance testInstance, ScopeOptions scope)
        {
            this.browser = browser;
            this.driver = driver;

            this.testInstance = testInstance;
            ActionWaitTime = browser.Factory?.TestSuiteRunner?.Configuration.TestRunOptions.ActionTimeout ?? 250;

            ScopeOptions = scope;
            SetCssSelector();
        }
        /// <summary>
        /// Sets implicit timeouts for page load and the time range between actions.
        /// </summary>
        public void SetTimeouts(TimeSpan pageLoadTimeout, TimeSpan implicitlyWait)
        {
            var timeouts = Driver.Manage().Timeouts();
            timeouts.PageLoad = pageLoadTimeout;
            timeouts.ImplicitWait = implicitlyWait;
        }

        private Func<string, By> selectMethodFunc;

        public virtual Func<string, By> SelectMethod
        {
            get { return selectMethodFunc; }
            set
            {
                if (value == null)
                { throw new ArgumentException("SelectMethod cannot be null. This method is used to select elements from loaded page."); }
                selectMethodFunc = value;
            }
        }
{'fraction_non_alphanumeric': 0.0772787318361955, 'fraction_numerical': 0.001321003963011889, 'mean_word_length': 2.126634549208534, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '6038990', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1111, 'n_words': 289}