Exemple #1
1
 internal RobustWindowScope(WindowFinder windowFinder, BrowserSession scope, Options options)
     : base(windowFinder, scope)
 {
     this.options = options;
 }
 protected void FullSizeTest(Action<BrowserSession> a)
 {
     using (var browser = new BrowserSession(SessionConfiguration))
     {
         browser.ResizeTo(1200, 1000);
         a(browser);
     }
 }
 public void Setup()
 {
     config = new SessionConfiguration
     {
         AppHost = "coypuspc.azurewebsites.net",
         Browser = Browser.Firefox
     };
     browser = new BrowserSession(config);
 }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BasePage"/> class.
        /// </summary>
        /// <param name="driver">An initialized instance of the WebDriver.</param>
        /// <exception cref="System.ArgumentNullException">driver</exception>
        public BasePage(BrowserSession browser)
        {
            if (browser == null)
            {
                throw new ArgumentNullException("driver");
            }

            _browser = browser;
        }
Exemple #5
0
 public void FixtureSetup()
 {
    browser = new BrowserSession(new SessionConfiguration 
                         {
                            AppHost = Settings.ApplicationHost(),
                            Browser = Settings.Browser()
                         });
    browser.ResizeTo(1280, 1024);
    browser.Visit(Settings.ApplicationFullAddress());
 }
 public void CheckSimplePageLoad()
 {
     var sessionConfiguration = new SessionConfiguration
                                	{
                                		AppHost = "teamaton.com",
                                		Browser = Browser.HtmlUnitWithJavaScript,
                                	};
     var browserSession = new BrowserSession(sessionConfiguration);
     browserSession.Visit("/");
     Assert.That(browserSession.HasContent("building web applications that work"));
 }
 private void Start()
 {
     Browser = new BrowserSession(new SessionConfiguration
     {
         AppHost = "localhost",
         Port = 5000,
         SSL = false,
         Driver = typeof(Coypu.Drivers.Selenium.SeleniumWebDriver),
         Browser = Coypu.Drivers.Browser.PhantomJS
     });
 }
            public async void AuthenticateAuthorizationCode_WhenGivenValidClientIdAndRedirectUri_ShouldReturnValidResponse(string clientId, string redirectUri)
            {
                var code = string.Empty;

                // Get authorization code
                using (var browser = new BrowserSession())
                {
                    browser.Visit(string.Format("{0}oauth/authorize?response_type=code&client_id={1}&state=&scope={2}&redirect_uri={3}", this.client.BaseAddress, clientId, Scope.Read, redirectUri));

                    Console.WriteLine("Opened authorize page");

                    browser.FillIn("Username").With("user");
                    browser.FillIn(GrantType.Password).With("pass");
                    browser.ClickButton("Sign in");

                    Console.WriteLine("Signing in");
                    browser.HasContent("The application NUnit wants to access your account", new Options() { RetryInterval = TimeSpan.FromSeconds(1) });

                    browser.ClickButton("Allow");

                    Console.WriteLine("Accepting authorization");
                    await Task.Delay(TimeSpan.FromSeconds(5));

                    var uri = browser.Location;
                    Console.WriteLine("Query String: {0}", uri.Query);

                    Assert.Contains("code", uri.ParseQueryString().AllKeys);

                    code = uri.ParseQueryString()["code"];
                }

                var request = new HttpRequestMessage(HttpMethod.Post, "oauth/token");
                request.Headers.Authorization = new BasicAuthenticationHeaderValue("NUnit", "NUnit");
                request.Content = new FormUrlEncodedContent(new Dictionary<string, string>()
                                                            {
                                                                { "grant_type", "authorization_code" },
                                                                { "redirect_uri", "http://localhost" },
                                                                { "code", code }
                                                            });

                Console.WriteLine("Request: {0}{1}", this.client.BaseAddress, request.RequestUri);

                var response = await this.client.SendAsync(request);

                var content = JsonConvert.DeserializeObject<AccessTokenResponse>(await response.Content.ReadAsStringAsync());

                Console.WriteLine("Response: [{0} {1}] {2}", (int)response.StatusCode, response.StatusCode, await response.Content.ReadAsStringAsync());

                Assert.IsNotNullOrEmpty(content.AccessToken, "No access token returned");

                var identity = await this.PrintIdentity(content.AccessToken);

                Assert.IsTrue(identity.HasClaim(ClaimType.Scope, Scope.Read));
            }
Exemple #9
0
 public void Do(Action<BrowserSession> action)
 {
     using (var browser = new BrowserSession(new SessionConfiguration
     {
         Driver = typeof(SeleniumWebDriver),
         Browser = Coypu.Drivers.Browser.Chrome,
         AppHost = Settings.AppHost, Port = Settings.Port, SSL = Settings.SSL
     }))
     {
         action(browser);
     }
 }
Exemple #10
0
        public void Before()
        {
            _browser = new BrowserSession(new SessionConfiguration
            {
                AppHost = "localhost",
                Port = 57414,
                Browser = Browser.Chrome
            });

            _objectContainer.RegisterInstanceAs(_browser);

        }
Exemple #11
0
 public void SetUp()
 {
     var configuration = new SessionConfiguration { Driver = typeof(SauceLabsDriver) };
     var desiredCapabilites = new DesiredCapabilities("chrome", "46", Platform.CurrentPlatform);
     desiredCapabilites.SetCapability("platform", "Windows 7");
     desiredCapabilites.SetCapability("username", "sebllabres");
     desiredCapabilites.SetCapability("accessKey", "892fdc2f-7409-4979-a592-e5e3d3ee73bc");
     desiredCapabilites.SetCapability("name", TestContext.CurrentContext.Test.Name);
     _driver = new SauceLabsDriver(Browser.Parse(ConfigurationSettings.AppSettings["browser"]), desiredCapabilites, new CustomRemoteDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"), desiredCapabilites));
     _browserSession = new BrowserSession(configuration, _driver);
     _browserSession.MaximiseWindow();
 }
 public virtual void SetUp()
 {
     Directory.CreateDirectory(ScreenshotsDir);
     Directory.EnumerateFiles(ScreenshotsDir, "*.png").ForEach(File.Delete);
     Browser = new BrowserSession(new SessionConfiguration
     {
         Browser = Coypu.Drivers.Browser.Chrome,
         AppHost = "localhost",
         Port = 3107
     });
     Browser.VisitTest("/test/cleardatabase");
 }
        public static void Start()
        {
            var sessionConfiguration = new SessionConfiguration
            {
                AppHost = "localhost/lateseats",
                Port = 80,
                Driver = typeof(SeleniumWebDriver)
            };
            Browser = new BrowserSession(sessionConfiguration);
            Browser.MaximiseWindow();

            ScenarioContext.Current.Add("Browser", Browser);
        }
Exemple #14
0
        private static BrowserSession CreateNewBrowserSession()
        {
            BrowserSession browser;

            var configuration =
                new SessionConfiguration
                    {
                        Timeout = TimeSpan.FromSeconds(TestSessionContext.Current.Configuration.TimeoutSeconds),
                        Browser = TestSessionContext.Current.Configuration.BrowserType,
                    };

            browser = new BrowserSession(configuration);
            return browser;
        }
Exemple #15
0
 public void BeforeScenario()
 {
     BrowserSession browserAtual;
     if (ScenarioContext.Current.TryGetValue<BrowserSession>(out browserAtual))
     {
         Browser = browserAtual;
         return;
     }
     var config = new SessionConfiguration { Port = CassiniDevConfig.PortaServidor,
         AppHost = "localhost",
         Browser = Coypu.Drivers.Browser.HtmlUnitWithJavaScript,
         Timeout = TimeSpan.FromSeconds(5),
         RetryInterval = TimeSpan.FromSeconds(0.1)};
     Browser = new BrowserSession(config);
     ScenarioContext.Current.Set<BrowserSession>(Browser);
 }
 protected PageObject(BrowserSession browser)
 {
     Browser = browser;
 }
            public async void AuthenticateAuthorizationCode_WhenGivenValidAuthorizationCodeAndInvalidRedirectUri_ShouldReturnInvalidRequest(string clientId, string clientSecret, string redirectUri)
            {
                var code = string.Empty;

                // Get authorization code
                using (var browser = new BrowserSession())
                {
                    var url = string.Format("{0}oauth/authorize?response_type=code&client_id={1}&redirect_uri={2}", this.client.BaseAddress, clientId, redirectUri);

                    browser.Visit(url);

                    Console.WriteLine("Opened authorize page: {0}", url);

                    browser.FillIn("Username").With("user");
                    browser.FillIn(GrantType.Password).With("pass");
                    browser.ClickButton("Sign in");

                    Console.WriteLine("Signing in");
                    browser.HasContent("The application NUnit wants to access your account", new Options() { RetryInterval = TimeSpan.FromSeconds(1) });

                    browser.ClickButton("Allow");

                    Console.WriteLine("Accepting authorization");
                    await Task.Delay(TimeSpan.FromSeconds(5));

                    var uri = browser.Location;
                    Console.WriteLine("Query String: {0}", uri.Query);

                    Assert.Contains("code", uri.ParseQueryString().AllKeys);

                    code = uri.ParseQueryString()["code"];
                }

                var request = new HttpRequestMessage(HttpMethod.Post, "oauth/token");
                request.Headers.Authorization = new BasicAuthenticationHeaderValue(clientId, clientSecret);
                request.Content = new FormUrlEncodedContent(new Dictionary<string, string>()
                                                            {
                                                                { "grant_type", GrantType.AuthorizationCode },
                                                                { "code", code }
                                                            });

                Console.WriteLine("Request: {0}{1}", this.client.BaseAddress, request.RequestUri);

                var response = await this.client.SendAsync(request);

                var content = await response.Content.ReadAsStringAsync();

                Console.WriteLine("Response: [{0} {1}] {2}", (int)response.StatusCode, response.StatusCode, await response.Content.ReadAsStringAsync());

                Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
                Assert.AreEqual("{\"error\":\"invalid_request\"}", content);
            }
            public async void AuthenticateAuthorizationCode_WhenGivenValidClientAndInvalidRedirectUri_ShouldReturnInvalidRequest(string clientId, string clientSecret)
            {
                // Get authorization code
                using (var browser = new BrowserSession())
                {
                    var url = string.Format("{0}oauth/authorize?response_type=code&client_id={1}", this.client.BaseAddress, clientId);

                    browser.Visit(url);

                    Console.WriteLine("Opened authorize page: {0}", url);

                    Assert.That(browser.HasContent("invalid_request"));
                }
            }
 public LetMeGoogleThatForYouPage(BrowserSession browser)
     : base(browser)
 {
 }
 public GoogleSearchPage(BrowserSession browser)
     : base(browser)
 {
 }
 public static void Start()
 {
     //_browserSession = new BrowserSession(new SessionConfiguration() { Port = IisExpressInstance.Port, Browser = Browser.Firefox});
       _browserSession = new BrowserSession(new SessionConfiguration() { Port = IisExpressInstance.Port, Browser = Browser.Chrome});
 }
 public EventSupport(BrowserSession browser)
 {
     this.browser = browser;
 }
Exemple #23
0
 private static bool GetMoneyValueForPlayer(BrowserSession browserSession, int cash, int playerNumber)
 {
     return browserSession.FindCss(string.Format(".player-card#player-{0} .cash", playerNumber)).HasContent("$" + cash);
 }
Exemple #24
0
 public ITGuysPage(BrowserSession session)
 {
     _session = session;
 }
Exemple #25
0
        /// <summary>
        /// Helper method to take a screenshot of the browser and save out to the TestResults folder.
        /// </summary>
        /// <param name="browser">BrowserSession to use for taking screenshot.</param>
        private void TakeScreenshot(BrowserSession browser)
        {
            try
            {
                var artifactDirectory = Path.Combine(Directory.GetCurrentDirectory(), ZukiniConfig.ScreenshotDirectory);
                if (!Directory.Exists(artifactDirectory))
                {
                    Directory.CreateDirectory(artifactDirectory);
                }

                string screenshotFilePath = Path.Combine(artifactDirectory, GetScreenshotName());
                browser.SaveScreenshot(screenshotFilePath, System.Drawing.Imaging.ImageFormat.Jpeg);

                // TODO: Add to the report transform to interpret this as a link (XSLT - yuck)
                Console.WriteLine("Screenshot: {0}", new Uri(screenshotFilePath));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while taking screenshot: {0}", ex);
            }
        }
 public void Before()
 {
     browser = new BrowserSession(new SessionConfiguration { AppHost = "localhost", Port = 6660 });
 }
Exemple #27
0
 public UniqueValues(BrowserSession browser)
     : base(browser)
 {
 }
Exemple #28
0
 public WWFPage(BrowserSession browser)
     : base(browser)
 {
 }
Exemple #29
0
 public void Start()
 {
     //   _browser = new BrowserSession(new SessionConfiguration{AppHost = "localhost", Port = 1974, Browser = Coypu.Drivers.Browser.HtmlUnit});
     _browser = new BrowserSession(new SessionConfiguration {AppHost = "localhost", Port = 1974});
     _objectContainer.RegisterInstanceAs(_browser);
 }
 private BrowserSession CreateBrowser()
 {
     var browser = new BrowserSession();
     return browser;
 }