public void Create_Role_Test() { username = RandomString(); password = RandomString(); string roleName = "role_" + RandomString(); var user = CreateUser(username, password, roles: new string[] { "Access", "Edit", "Admin" }); Login(); Open($"{rootUrl}Lookups/"); PageSource.ShouldContain("Lookup Codes"); Find(text: "Roles").Click(); CurrentUrl.ShouldBe($"{rootUrl}Roles"); RepeatUntil(() => Find(css: ".box-tools button[type=submit]")?.Click(), condition: () => Find(id: "RoleName.NEW") != null); var newRole = Find(id: "RoleName.NEW"); ScrollTo(newRole); RepeatUntil(() => newRole.Click(), condition: () => Find(css: ".editable-input input[type=text]") != null); Find(css: ".editable-input input[type=text]").Clear(); Find(css: ".editable-input input[type=text]").SendKeys(roleName); Find(css: ".editable-buttons button[type=submit]").Click(); Wait(2); var adminRole = db.Roles.SingleOrDefault(r => r.RoleName == "Admin"); var role = db.Roles.SingleOrDefault(r => r.RoleName == roleName); role.ShouldNotBeNull(); role.Priority.GetValueOrDefault().ShouldBeGreaterThan(adminRole.Priority.GetValueOrDefault()); }
public void MyData_User_ChangePassword_Test() { username = RandomString(); password = RandomString(); var user = CreateUser(); Login(); var newPassword = RandomString() + "1!"; Find(css: profileMenu).Click(); Find(text: "Change Password").Click(); CurrentUrl.ShouldBe($"{rootUrl}Account/ChangePassword/"); Find(id: "currentPassword").SendKeys(password); Find(id: "newPassword").SendKeys(newPassword); Find(id: "confirmPassword").SendKeys(newPassword); Find(css: "input[type=submit]").Click(); PageSource.ShouldContain("Password Changed"); Find(text: "Return to Home").Click(); Logout(); Login(withPassword: newPassword); PageSource.ShouldContain(user.Person.Name); PageSource.ShouldContain(user.Person.EmailAddress); }
public void OneTimeGiving_Processes_Payment() { username = RandomString(); password = RandomString(); var user = CreateUser(username, password); var org = db.Organizations.First(o => o.RegistrationTypeId == RegistrationTypeCode.OnlineGiving); org.ShouldNotBeNull(); var orgId = org.OrganizationId; FinanceTestUtils.CreateMockPaymentProcessor(db, PaymentProcessTypes.OneTimeGiving, GatewayTypes.Transnational); Login(); Open($"{rootUrl}Person2/{user.PeopleId}"); WaitForPageLoad(); Find(css: @"a[href=""#giving""]").Click(); Wait(1); WaitForElementToDisappear(loadingUI); Find(text: "Make a One Time Gift").Click(); Wait(3); SwitchToWindow(d => d.Title == "Online Registration"); CurrentUrl.ShouldBe($"{rootUrl}OnlineReg/{orgId}"); }
public static string ResolveCurrentUrl(string url) { if (CurrentUrl.EndsWith("/")) { return(ResolveUrl("~/" + CurrentUrl + url)); } return(ResolveUrl("~/" + CurrentUrl + "/" + url)); }
public void MyData_User_ForgotPassword_Test() { username = RandomString(); password = RandomString(); var newPassword = RandomString() + "1!"; var user = CreateUser(); Open(rootUrl); WaitForElement("#inputEmail", 30); Find(text: "Forgot?").Click(); CurrentUrl.ShouldBe($"{rootUrl}Account/ForgotPassword"); var input = "[name=UsernameOrEmail]"; var button = "input[type=submit]"; RepeatUntil(() => { Find(css: input)?.SendKeys(username); Find(css: button)?.Click(); }, () => PageSource.Contains("Password Sent")); db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, user); user.ResetPasswordCode.ShouldNotBeNull(); Open($"{rootUrl}Account/SetPassword/{user.ResetPasswordCode}"); PageSource.ShouldContain("Confirm Password Reset"); Find(css: "button[type=submit]").Click(); CurrentUrl.ShouldBe($"{rootUrl}Account/SetPasswordConfirm"); RepeatUntil(() => { Find(id: "newPassword").SendKeys(newPassword); Find(id: "confirmPassword").SendKeys(newPassword); Find(css: button).Click(); }, () => PageSource.Contains("Password Changed")); Find(text: "Return to Home").Click(); WaitForPageLoad(); Logout(); Login(withPassword: newPassword); PageSource.ShouldContain(user.Person.Name); PageSource.ShouldContain(user.Person.EmailAddress); }
public void can_automatically_follow_redirects() { // Do it manually Get("/redirect-three-times"); LastResponse.Status.ShouldEqual(302); LastResponse.Body.ShouldEqual("Redirecting"); LastResponse.Headers["Location"].ShouldEqual("/redirect-twice"); CurrentPath.ShouldEqual("/redirect-three-times"); CurrentUrl.ShouldEqual("http://localhost:3000/redirect-three-times"); FollowRedirect(); LastResponse.Status.ShouldEqual(301); LastResponse.Body.ShouldEqual("Redirecting"); LastResponse.Headers["Location"].ShouldEqual("/redirect"); CurrentPath.ShouldEqual("/redirect-twice"); CurrentUrl.ShouldEqual("http://localhost:3000/redirect-twice"); FollowRedirect(); LastResponse.Body.ShouldEqual("Redirecting"); LastResponse.Headers.Keys.ShouldContain("Location"); LastResponse.Headers["Location"].ShouldEqual("/info?redirected=true"); CurrentPath.ShouldEqual("/redirect"); CurrentUrl.ShouldEqual("http://localhost:3000/redirect"); FollowRedirect(); LastResponse.Status.ShouldEqual(200); LastResponse.Body.ShouldContain("GET /info"); LastResponse.Headers.Keys.ShouldNotContain("Location"); CurrentPath.ShouldEqual("/info?redirected=true"); CurrentUrl.ShouldEqual("http://localhost:3000/info?redirected=true"); // Do it automatically AutoRedirect = true; Get("/redirect-three-times"); LastResponse.Status.ShouldEqual(200); LastResponse.Body.ShouldContain("GET /info"); LastResponse.Headers.Keys.ShouldNotContain("Location"); CurrentPath.ShouldEqual("/info?redirected=true"); CurrentUrl.ShouldEqual("http://localhost:3000/info?redirected=true"); }
protected override void OnInit(EventArgs e) { if (!CurrentUrl.EndsWith("/Login.aspx")) { if (CurrentAdmin == null) { Response.Write("<script>alert('连接超时!');parent.window.location.href='../Master/Login.aspx';</script>"); Response.End(); } else { //Sys只有超管可以访问 if (CurrentUrl.Contains("/Sys/") && !CurrentAdmin.IsSuper) { Response.Write("<script>alert('没有访问的权限!');history.go(-1);</script>"); Response.End(); } } } base.OnInit(e); }
/// <summary> /// GetComment /// </summary> /// <returns></returns> private IDictionary <string, string> GetComment() { var dic = new Dictionary <string, string>(); var refer = CurrentUrl.EndsWith("/") ? CurrentUrl : $"{CurrentUrl}/"; var url = $"{refer}event/app/winport_bsr/getBsrData.htm"; //var url = "https://shop1397148954914.1688.com/event/app/winport_bsr/getBsrData.htm"; var httpHelper = new HttpHelper { Cookies = $"cna={GetCna()}", Referer = CurrentUrl }; var html = httpHelper.GetHtmlByPost(url, $"site_id=winport&page_type=index&_csrf_token={GetRandom32()}&site_key={GetRandom32()}"); var jArray = JArray.Parse(JObject.Parse(html)["result"]["bsrDataList"].ToString()); var Comment_MatchDescripRate = jArray[0]?["compareLineRate"]?.ToString().Replace("%", string.Empty); if (Comment_MatchDescripRate == "-1") { Comment_MatchDescripRate = string.Empty; } else if (Comment_MatchDescripRate == "0") { Comment_MatchDescripRate = "0"; } else { var compareTag = int.Parse(jArray[0]?["compareTag"]?.ToString() ?? "0"); Comment_MatchDescripRate = compareTag == -1 ? $"-{Comment_MatchDescripRate}" : $"+{Comment_MatchDescripRate}"; } var Comment_ServiceStatueRate = jArray[1]?["compareLineRate"]?.ToString().Replace("%", string.Empty); if (Comment_ServiceStatueRate == "-1") { Comment_ServiceStatueRate = string.Empty; } else if (Comment_ServiceStatueRate == "0") { Comment_ServiceStatueRate = "0"; } else { var compareTag = int.Parse(jArray[1]?["compareTag"]?.ToString() ?? "0"); Comment_ServiceStatueRate = compareTag == -1 ? $"-{Comment_ServiceStatueRate}" : $"+{Comment_ServiceStatueRate}"; } var Comment_ShipSpeedRate = jArray[2]?["compareLineRate"]?.ToString().Replace("%", string.Empty); if (Comment_ShipSpeedRate == "-1") { Comment_ShipSpeedRate = string.Empty; } else if (Comment_ShipSpeedRate == "0") { Comment_ShipSpeedRate = "0"; } else { var compareTag = int.Parse(jArray[2]?["compareTag"]?.ToString() ?? "0"); Comment_ShipSpeedRate = compareTag == -1 ? $"-{Comment_ShipSpeedRate}" : $"+{Comment_ShipSpeedRate}"; } dic.Add("Comment_MatchDescripRate", Comment_MatchDescripRate); dic.Add("Comment_ServiceStatueRate", Comment_ServiceStatueRate); dic.Add("Comment_ShipSpeedRate", Comment_ShipSpeedRate); return(dic); }
private bool ItemHasCurrentUrl(PaginationItemTagHelper item) { ; return(CurrentUrl.EndsWith("/" + item.Href.Trim('/'), StringComparison.CurrentCultureIgnoreCase) || CurrentUrl.Equals(item.Href, StringComparison.CurrentCultureIgnoreCase)); }
public void ThenTheSubmittingOfDataWasNotPossible() { _actor.AsksFor(CurrentUrl.FromBrowser()).Should().NotEndWith("Success", "the input form page should be displayed again"); }
public void ThenTheSubmittingOfDataWasPossible() { _actor.AsksFor(CurrentUrl.FromBrowser()).Should().EndWith("Success", "because the success page should be displayed"); }
public void TestGetUrl() { WebDriver.SetupGet(x => x.Url).Returns("google.com"); Actor.AsksFor(CurrentUrl.FromBrowser()).Should().Be("google.com"); }