internal static void EnsureLoggedIn(this BrowserSession browser) { var loggedIn = new State(() => browser.HasContent("Log off")); var loggedOut = new State(() => browser.HasContent("Login")); if (browser.FindState(loggedIn, loggedOut) == loggedIn) { return; } browser.ClickLink("Login"); browser.ClickButton("Google"); browser.FillIn("Email").With("*****@*****.**"); browser.FillIn("Password").With(Environment.GetEnvironmentVariable("RegisterKeeperTestData")); browser.ClickButton("Sign in"); if (browser.HasContent("Associate your Google account")) { browser.ClickButton("Register"); } if (!browser.FindCss("div.navbar").HasContent("*****@*****.**")) { throw new Exception("Login process failed."); } }
public async void GetAccessToken_WhenGivenValidAuthorizationCodeAndValidRedirectUri_ShouldReturnAccessToken(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("user"); browser.ClickButton("Login"); 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 }, { "redirect_uri", redirectUri }, { "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(); var accessTokenResponse = JsonConvert.DeserializeObject <AccessTokenResponse>(content); Console.WriteLine("Response: [{0} {1}] {2}", (int)response.StatusCode, response.StatusCode, await response.Content.ReadAsStringAsync()); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNullOrEmpty(accessTokenResponse.AccessToken); Assert.IsNotNullOrEmpty(accessTokenResponse.RefreshToken); }
public async void GetAuthorizationCode_WhenConsentIsNotGuven_ShouldReturnErrorRedirect(string clientId, string redirectUri) { // Get authorization code using (var browser = new BrowserSession()) { browser.Visit($"{this.client.BaseAddress}oauth/authorize?response_type=code&client_id={clientId}&state=xyz&redirect_uri={redirectUri}"); Console.WriteLine("Opened authorize page"); browser.FillIn("Username").With("user"); browser.FillIn("Password").With("user"); browser.ClickButton("Login"); Console.WriteLine("Signing in"); browser.HasContent("The application NUnit wants to access your account", new Options() { RetryInterval = TimeSpan.FromSeconds(1) }); browser.ClickButton("Cancel"); Console.WriteLine("Declining authorization"); await Task.Delay(TimeSpan.FromSeconds(5)); var uri = browser.Location; Console.WriteLine("Query String: {0}", uri.Query); var error = uri.ParseQueryString()["error"]; var state = uri.ParseQueryString()["state"]; Assert.AreEqual("access_denied", error); Assert.AreEqual("xyz", state); } }
public void ValidateDeleteTweet() { _browser.FindCss(".Icon--caretDownLight").Click(); _browser.ClickButton("Delete Tweet"); _browser.ClickButton("Delete"); Assert.IsTrue(_browser.FindCss(".HomeEmptyTimeline-header").Exists(), "Tweet has not been deleted."); }
public void FillNovajusFields(string tenantNovajus, string userNovajus, string passwordNovajus) { loginOption.Goto(loginOption.loginUrlNovajusPath); _browser.ClickButton(loginOption.novajusAccessButton); _browser.FillIn(tenantInput).With(tenantNovajus); _browser.FillIn(novajusUserInput).With(userNovajus); _browser.FillIn(novajusPasswordInput).With(passwordNovajus); _browser.ClickButton(novajusLoginButton); }
//Custom actions dentro do page objects public void Whit(string email, string pass) { _browser.ClickButton("age-gate-button-yes"); _browser.ClickButton("welcome-button-sign-in"); _browser.ClickButton("login-home-email-button-sign-in"); _browser.FillIn("login-mail-input-email").With(email); _browser.FillIn("login-mail-input-password").With(pass); _browser.ClickButton("login-mail-button-sign-in"); }
/// <summary> /// We should be in event editor /// </summary> public void FillEditor(TestEvent e) { browser.FillIn("Name").With(e.Name); browser.FillIn("StartDate").With(e.StartDate); browser.FillIn("Description").With(e.Description); foreach (var checkbox in GetActiveBroCheckboxes()) { checkbox.Click(); } foreach (string bro in e.Bros) { browser.ClickButton(bro); } }
public void GivenIRegisterAContactWithEmail(string emailAddress) { var addresses = emailAddress.Split(';').ToList(); addresses.ForEach(x => { _browser.Visit("http://localhost"); _browser.ClickLink("Register Contact"); _browser.ClickLink("Create New"); _browser.FillIn("FirstName").With("1stname"); _browser.FillIn("Email").With(x.Replace("\"", "")); Assert.AreEqual(x.Replace("\"", ""), _browser.FindField("Email").Value); _browser.ClickButton("Create"); }); }
public void With(string email, string pass) { this.Load(); _browser.FillIn("email").With(email); _browser.FindCss("#passId").SendKeys(pass); _browser.ClickButton("Entrar"); }
static void Main(string[] args) { var sessionConfiguration = new SessionConfiguration { SSL = true | false }; sessionConfiguration.Driver = typeof(SeleniumWebDriver); sessionConfiguration.Browser = Coypu.Drivers.Browser.Chrome; using (var browser = new BrowserSession(sessionConfiguration)) { browser.Visit("https://ebilet.tcddtasimacilik.gov.tr/view/eybis/tnmGenel/tcddWebContent.jsf"); browser.FillIn("nereden").With("Eski"); browser.FindCss("ul li", text: "Eskişehir").Click(); browser.FillIn("nereye").With("İstanbul"); browser.FindCss("ul li", text: "İstanbul").Click(); browser.ClickButton("btnSeferSorgula"); //sonuç sayfasında data alınacak //yer var ise bildirim yollanacak } }
public void Login() { _browser.FindCss(".StaticLoggedOutHomePage-buttonLogin").Click(); _browser.FindCss(".js-username-field").FillInWith(ConfigurationManager.AppSettings["Email"]); _browser.FindCss(".js-password-field").FillInWith(ConfigurationManager.AppSettings["Password"]); _browser.ClickButton("Log in"); }
public void Dados(string nome, string email, string senha) { this.TelaCadastroUsuario(); _browser.FillIn("name").With(nome); _browser.FillIn("email").With(email); _browser.FillIn("password").With(senha); _browser.ClickButton("register"); }
public void Width(string email, string password) { this.Load(); _browser.FillIn("identifierId").With(email); _browser.FindId("identifierNext").Click(); _browser.FillIn("password").With(password); _browser.ClickButton("Próxima"); }
public void With(string email, string senha) { this.Acessa(); _browser.FindCss("div.Header__login", text: "Entrar").Click(); _browser.FillIn("email").With(email); _browser.FillIn("senha").With(senha); _browser.ClickButton("Entrar"); Thread.Sleep(3000); }
public void CleanupTweet() { BrowserSession _browser = FeatureContextWrapper.BrowserSession; try { if (_browser.FindCss(".Icon--caretDownLight").Exists() == false) { return; } _browser.FindCss(".Icon--caretDownLight").Click(); _browser.ClickButton("Delete Tweet"); _browser.ClickButton("Delete"); } catch (Exception e) { Console.WriteLine("Cleaning up tweet."); } }
public void GivenXmanLogoSEmailAddressLxGmail_ComIsRegisteredInSystem(string firstName, string lastName, string email) { _browser.Visit("http://localhost"); _browser.ClickLink("Register Contact"); _browser.ClickLink("Create New"); _browser.FillIn("FirstName").With(firstName.Replace("\"", "")); _browser.FillIn("LastName").With(lastName.Replace("\"", "")); _browser.FillIn("Email").With(email.Replace("\"", "")); _browser.ClickButton("Create"); }
public void Save(MovieModel movie) { _browser.FindCss("input[name='title']").SendKeys(movie.Title); SelectStatus(movie.Status); _browser.FindCss("input[name='year']").SendKeys(movie.Year.ToString()); _browser.FindCss("input[name='release_date']").SendKeys(movie.ReleaseDate); InputCast(movie.Cast); _browser.FindCss("textarea[name='overview']").SendKeys(movie.Plot); UploadCover(movie.Cover); _browser.ClickButton("Cadastrar"); }
public void WhenIRegisterWithMyGoogleAccount() { _browser.ClickButton("Google"); // Google login page var email = ScenarioContext.Current.Get <Email>(); _browser.FillIn("Email").With(email.Address); _browser.FillIn("Passwd").With(email.Password); _browser.Uncheck("PersistentCookie"); // don't remember me _browser.FindId("signIn").Click(); // sign in to Google // Google OpenID acceptance page: to revoke access, go to: https://www.google.com/accounts/b/0/IssuedAuthSubTokens var notApprovedYet = new State(() => _browser.Has(_browser.FindId("submit_approve_access"))); var approved = new State(() => _browser.HasNo(_browser.FindId("submit_approve_access"))); if (_browser.FindState(notApprovedYet, approved) == notApprovedYet) { _browser.FindId("submit_approve_access").Click(); // authenticate using Google } }
public void SuccessfullyLogin() { browser.Visit("/login"); browser.FillIn("emailId").With("*****@*****.**"); browser.FindCss("input[placeholder=senha]").SendKeys("pwd123"); browser.ClickButton("login"); var loggedUser = browser.FindCss(".user .info span"); Assert.AreEqual("Papito", loggedUser.Text); }
public void _34ProtonsLoginTest1() { BeforeTest(); browser.Visit("/demo_2_0/login.php"); browser.FillIn("username").With("user"); browser.FillIn("password").With("123"); browser.ClickButton("Submit"); browser.HasNoContent("Login page", new Options { Timeout = TimeSpan.FromSeconds(6) }); Assert.AreEqual(browser.Title, "Demo page for selenium code"); AfterTest(); }
public void EditExistingSupplier() { using (var browser = new BrowserSession(sessionConfiguration)) { browser.Visit("/Supplier/Edit/1"); browser.FillIn("Name").With("name_" + currentMoment); browser.ClickButton("Save"); var newName = browser.FindXPath("//tr[2]/td[1]").InnerHTML.Trim(); Assert.AreEqual("name_" + currentMoment, newName); } }
public async void GetAuthorizationCode_WhenGivenValidClientIdAndRedirectUri_ShouldReturnValidResponse(string clientId, string redirectUri) { string code; // Get authorization code using (var browser = new BrowserSession()) { browser.Visit($"{this.client.BaseAddress}oauth/authorize?response_type=code&client_id={clientId}&state=&scope={Constants.Scope.Read}&redirect_uri={redirectUri}"); Console.WriteLine("Opened authorize page"); browser.FillIn("Username").With("user"); browser.FillIn("Password").With("user"); browser.ClickButton("Login"); 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"]; } Assert.IsNotNullOrEmpty(code, "No authorization code returned"); }
public void LoginTest() { var sessionConfiguration = new SessionConfiguration { Browser = Browser.InternetExplorer, AppHost = "at.dayforce.com" }; var browser = new BrowserSession(sessionConfiguration); browser.Visit("/root/mydayforce/MyDayforce.aspx"); browser.FillIn("txtCompanyName").With("at855plat6"); browser.FillIn("txtUserName").With("cadmin"); browser.FillIn("txtUserPass").With("1"); browser.ClickButton("Login"); }
public void FindingStuff_CarBuzz() { browser.Visit("http://carbuzz.heroku.com/car_search"); Console.WriteLine(browser.Has(browser.FindSection("Make"))); Console.WriteLine(browser.HasNo(browser.FindSection("Bake"))); browser.Check("Audi"); browser.Check("BMW"); browser.Check("Mercedes"); Assert.That(browser.HasContentMatch(new Regex(@"\b83 car reviews found"))); browser.FindSection("Seats").Click(); browser.ClickButton("4"); Assert.That(browser.HasContentMatch(new Regex(@"\b28 car reviews found"))); }
public void CreateNewSupplier() { using (var browser = new BrowserSession(sessionConfiguration)) { browser.Visit("/"); var numberOfSupplierRows = browser.FindAllXPath("//tr").Count(); browser.Visit("/Supplier/Create"); browser.FillIn("Name").With("name_" + currentMoment); browser.FillIn("Address").With("address_" + currentMoment); browser.FillIn("EmailAddress").With("*****@*****.**"); browser.FillIn("PhoneNumber").With("123123123"); browser.Select("Security").From("GroupId"); browser.ClickButton("Create"); var numberOfSupplierRowsAfterCreation = browser.FindAllXPath("//tr").Count(); Assert.AreEqual("http://localhost:54401/", browser.Location.ToString()); //redirected to index page Assert.AreEqual(numberOfSupplierRowsAfterCreation, numberOfSupplierRows + 1); //we have one more row } }
public void ConfirmPaymentCreditCard() { _browser.ClickButton("Pagar com cartão de crédito"); Thread.Sleep(5000); }
public void WhenIClickTheButton(string name) { BrowserSession.ClickButton(name); }
public async void GetAccessToken_WhenGivenValidAuthorizationCodeAndOpenIdScope_ShouldReturnValidIdToken(string clientId, string clientSecret, string redirectUri) { var code = string.Empty; // Get authorization code using (var browser = new BrowserSession()) { var url = $"{this.client.BaseAddress}oauth/authorize?response_type=code&client_id={clientId}&redirect_uri={redirectUri}&scope=openid"; browser.Visit(url); Console.WriteLine("Opened authorize page: {0}", url); browser.FillIn("Username").With("user"); browser.FillIn(GrantType.Password).With("user"); browser.ClickButton("Login"); 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 }, { "redirect_uri", redirectUri }, { "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(); var accessTokenResponse = JsonConvert.DeserializeObject <AccessTokenResponse>(content); Console.WriteLine("Response: [{0} {1}] {2}", (int)response.StatusCode, response.StatusCode, await response.Content.ReadAsStringAsync()); var jwt = new JsonWebToken(accessTokenResponse.IdToken); var principal = new SentinelPrincipal(jwt.ToIdentity()); Console.WriteLine($"Header: {JsonConvert.SerializeObject(jwt.Header)}"); Console.WriteLine($"Payload: {JsonConvert.SerializeObject(jwt.Payload)}"); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNullOrEmpty(accessTokenResponse.IdToken); Assert.AreEqual("user", jwt.Payload.Subject); Assert.IsTrue(principal.Scopes.Count(x => x == "openid") == 1, "The openid scope was included more than once or not at all"); Assert.IsTrue(jwt.ValidateAuthorizationCode(code), "The authentication code is invalid for this JWT"); Assert.IsTrue(jwt.ValidateAccessToken(accessTokenResponse.AccessToken), "The access token is invalid for this JWT"); //Assert.IsTrue(jwt.ValidateSignature(clientSecret)); }
public void ConfirmPaymentTransferencia() { _browser.ClickButton("Pagar via transferência"); Thread.Sleep(5000); }
public void ConfirmaEdit() { _browser.ClickButton("Update User"); }