/// <summary>
 /// A new browser session. Control the lifecycle of this session with using{} / session.Dispose()
 /// </summary>
 /// <param name="SessionConfigurationconfiguration for this session</param>
 /// <returns>The new session</returns>
 public BrowserSession(SessionConfiguration SessionConfiguration)
     : this(new ActivatorDriverFactory(),
            SessionConfiguration,
            new RetryUntilTimeoutRobustWrapper(),
            new StopwatchWaiter(),
            new WebClientWithCookies(),
            new FullyQualifiedUrlBuilder())
 {
 }
        public void SetUp()
        {
            SessionConfiguration = new SessionConfiguration();
            SessionConfiguration.AppHost = "http://www.google.co.uk";
            SessionConfiguration.Driver = typeof(SeleniumWebDriver);

            SessionConfiguration.Timeout = TimeSpan.FromSeconds(10);

            browser = new BrowserSession(SessionConfiguration);
        }
        public string GetFullyQualifiedUrl(string virtualPath, SessionConfiguration SessionConfiguration)
        {
            if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute))
                return virtualPath;

            virtualPath = virtualPath.TrimStart('/');
            var scheme = SessionConfiguration.SSL ? "https" : "http";

            return SessionConfiguration.Port == 80
                       ? String.Format("{0}://{1}/{2}", scheme, SessionConfiguration.AppHost, virtualPath)
                       : String.Format("{0}://{1}:{2}/{3}", scheme, SessionConfiguration.AppHost, SessionConfiguration.Port, virtualPath);
        }
 internal BrowserWindow(SessionConfiguration SessionConfiguration, ElementFinder elementFinder, Driver driver, RobustWrapper robustWrapper, Waiter waiter, UrlBuilder urlBuilder)
     : base(SessionConfiguration, elementFinder, driver, robustWrapper, waiter, urlBuilder)
 {
 }
 internal BrowserSession(DriverFactory driver, SessionConfiguration SessionConfiguration, RobustWrapper robustWrapper, Waiter waiter, RestrictedResourceDownloader restrictedResourceDownloader, UrlBuilder urlBuilder)
     : base(SessionConfiguration, null, driver.NewWebDriver(SessionConfiguration.Driver, SessionConfiguration.Browser), robustWrapper, waiter, urlBuilder)
 {
     this.restrictedResourceDownloader = restrictedResourceDownloader;
 }