Example #1
0
 /// <summary>
 /// Cookies the get set.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="cookies">The cookies.</param>
 /// <returns>CookieCollection.</returns>
 public static CookieCollection CookieGetSet(this AutomaContext source, CookieCollection cookies)
 {
     if (cookies != null)
     {
         source.Cookies = cookies;
         source.CookiesFlush();
     }
     return(source.Cookies);
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Automa" /> class.
        /// </summary>
        /// <param name="connector">The connector.</param>
        /// <param name="automationFactory">The automation factory.</param>
        /// <param name="defaultTimeoutIsSeconds">The default timeout is seconds.</param>
        public Automa(AutomaContext connector, Func <IAutoma, IWebDriver, IAutomation> automationFactory, decimal defaultTimeoutIsSeconds = 30M)
        {
            // [http://stackoverflow.com/questions/33265701/protractor-allow-notifications-chrome-46]
            var chromeOptions = new ChromeOptions();

            chromeOptions.AddUserProfilePreference("profile.managed_default_content_settings.notifications", 1);
            _d = new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory, chromeOptions);
            _d.Manage().Timeouts().ImplicitWait = TimeSpan.FromMinutes(5);
            _connector              = connector;
            _automation             = automationFactory(this, _d);
            DefaultTimeoutIsSeconds = defaultTimeoutIsSeconds;
        }
Example #3
0
        /// <summary>
        /// Merges the specified cookies.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="cookies">The cookies.</param>
        public static void CookieMerge(this AutomaContext source, CookieCollection cookies)
        {
            var cookiesByName = cookies.Cast <Cookie>().ToDictionary(x => x.Name);
            var newCookies    = new CookieCollection {
                cookies
            };
            Cookie c;

            foreach (Cookie cookie in source.Cookies)
            {
                if (!cookiesByName.TryGetValue(cookie.Name, out c))
                {
                    newCookies.Add(cookie);
                }
            }
            source.Cookies = newCookies;
        }