Esempio n. 1
0
func RequestPasswordResetFor(inEmailAddr string, t *testing.T) {
	url := "https://plog.org:8004/#/password"
	err := webdriver.Drv.Get(url)
	if err != nil {
		t.Fatalf("Failed to load %s: %s\n", url, err)
	}
	webdriver.WaitFor(5*time.Second, webdriver.ElementToVanish, "div[class='selenium-flag']")

	// Get elements
	elements, err := webdriver.FindNamedElements([]string{"Message", "EmailAddr", "ResetPasswordButton"})
	if err != nil {
		t.Fatalf("FindNamedElements failed: %s", err)
	}

	// Fill
	elements["EmailAddr"].Clear()
	elements["EmailAddr"].SendKeys(inEmailAddr)

	// Submit
	elements["ResetPasswordButton"].Click()

	webdriver.WaitFor(5*time.Second, webdriver.ElementToVanish, "div[class='selenium-flag']")

	// Verify expected results
	actualMsg, err := webdriver.FetchText("p[name='Message']")
	if err != nil {
		t.Fatalf("Failed to fetch the main message: %s", err)
	}

	expectMsg := fmt.Sprintf("Check email (%s) for a reset token", inEmailAddr)

	if actualMsg != expectMsg {
		t.Fatalf("Expected message \"%s\", got \"%s\"", expectMsg, actualMsg)
	}
}
Esempio n. 2
0
func ExpectOnProfilePage(t *testing.T) {

	webdriver.WaitFor(5*time.Second, webdriver.ElementToVanish, "div[class='selenium-flag']")

	elist := []string{"editProfileForm", "Message", "UserId", "FirstName", "LastName", "EmailAddr",
		"ClearPassword", "ConfirmPassword", "SaveProfileButton"}

	// Get elements
	elements, err := webdriver.FindNamedElements(elist)
	if err != nil {
		t.Fatalf("FindNamedElements failed: %s", err)
	}

	var val string

	for k, v := range profExpected {
		val, err = elements[k].GetAttribute("value")
		if err != nil {
			t.Fatalf("Failed to get vlaue in %s: %s", k, err)
		}

		if val != v {
			t.Fatalf("Expected %s value \"%s\", got \"%s\"", k, v, val)
		}
	}

}
Esempio n. 3
0
func SubmitLogin(in Login, t *testing.T) {

	// Get elements
	elements, err := webdriver.FindNamedElements([]string{"UserIdentifier", "ClearPassword", "LoginButton"})
	if err != nil {
		t.Fatalf("FindNamedElements failed: %s", err)
	}

	// Fill in
	elements["UserIdentifier"].Clear()
	elements["UserIdentifier"].SendKeys(in.UserIdentifier)
	elements["ClearPassword"].Clear()
	elements["ClearPassword"].SendKeys(in.ClearPassword)

	// Submit
	elements["LoginButton"].Click()
}
Esempio n. 4
0
func ExpectProfileChangeSuccess(t *testing.T) {

	webdriver.WaitFor(5*time.Second, webdriver.ElementToVanish, "div[class='selenium-flag']")

	// Get elements
	elements, err := webdriver.FindNamedElements([]string{"Message", "UserId", "FirstName", "LastName", "EmailAddr",
		"TzName", "ClearPassword", "ConfirmPassword", "SaveProfileButton"})
	if err != nil {
		t.Fatalf("FindNamedElements failed: %s", err)
	}

	msg, err := elements["Message"].Text()
	if err != nil {
		t.Fatalf("Could not get Message")
	}
	if msg != "Save successful" {
		t.Fatalf("Main message did not reflect success, got %s", msg)
	}
}
Esempio n. 5
0
// SubmitProfileChange fills in the form and presses the save button. It does not wait after the click.
func SubmitProfileChange(profU UserProfile, t *testing.T) {

	webdriver.WaitFor(5*time.Second, webdriver.ElementToVanish, "div[class='selenium-flag']")

	// Get elements
	elements, err := webdriver.FindNamedElements([]string{"UserId", "FirstName", "LastName", "EmailAddr",
		"TzName", "ClearPassword", "ConfirmPassword", "SaveProfileButton"})
	if err != nil {
		t.Fatalf("FindNamedElements failed: %s", err)
	}

	// Fill
	if profU.UserId != "" {
		elements["UserId"].Clear()
		elements["UserId"].SendKeys(profU.UserId)
	}
	if profU.FirstName != "" {
		elements["FirstName"].Clear()
		elements["FirstName"].SendKeys(profU.FirstName)
	}
	if profU.LastName != "" {
		elements["LastName"].Clear()
		elements["LastName"].SendKeys(profU.LastName)
	}
	if profU.EmailAddr != "" {
		elements["EmailAddr"].Clear()
		elements["EmailAddr"].SendKeys(profU.EmailAddr)
	}
	if profU.ClearPassword != "" {
		elements["ClearPassword"].Clear()
		elements["ClearPassword"].SendKeys(profU.ClearPassword)
	}
	if profU.ConfirmPassword != "" {
		elements["ConfirmPassword"].Clear()
		elements["ConfirmPassword"].SendKeys(profU.ConfirmPassword)
	}

	// Submit
	elements["SaveProfileButton"].Click()

	// NOT waiting here
}
Esempio n. 6
0
// SubmitRegistration fills in the form and presses the register button. It does not wait after the click.
func SubmitRegistration(regU RegisterUser, t *testing.T) {

	// Get and wait
	err := webdriver.Drv.Get(`https://plog.org:8004/#/register`)
	if err != nil {
		t.Fatalf("Failed to load page: %s", err)
	}
	webdriver.WaitFor(5*time.Second, webdriver.ElementToVanish, "div[class='selenium-flag']")

	// Check page title
	pageTitle := "ZM Plog"
	if title, err := webdriver.Drv.Title(); err == nil {
		if title != pageTitle {
			t.Fatalf("Title page, expected \"%s\" but actually got \"%s\"\n", pageTitle, title)
		}
	} else {
		t.Fatalf("Failed to get page title: %s", err)
	}

	// Get elements
	elements, err := webdriver.FindNamedElements([]string{"UserId", "FirstName", "LastName", "EmailAddr",
		"TzName", "ClearPassword", "ConfirmPassword", "RegisterButton"})
	if err != nil {
		t.Fatalf("FindNamedElements failed: %s", err)
	}

	// Fill
	elements["UserId"].SendKeys(regU.UserId)
	elements["FirstName"].SendKeys(regU.FirstName)
	elements["LastName"].SendKeys(regU.LastName)
	elements["EmailAddr"].SendKeys(regU.EmailAddr)
	elements["ClearPassword"].SendKeys(regU.ClearPassword)
	elements["ConfirmPassword"].SendKeys(regU.ConfirmPassword)

	// Submit
	elements["RegisterButton"].Click()

	// NOT waiting here
}