Hello,
I am quality assurance specialist. I am creating automatic tests and today
I encountered with a problem related to Jenkins. With Selenium Eclipse I
created automatic test for registration to website: opening website,
filling register information. After that opening new tab, fill gmail
information, open email letter and push register confirmation link.
Everything on Selenium works fine. But when I run my test on Jenkins it
fails. It doesn't open registration confirmation email. It does all the
steps till it: open website, fill register information, opens new tab,
logins to gmail account and what's it. After that it has to open
confirmation email, but nothing is going on. I am running the newest
version of Jenkins.
Sorry for my not fluent English language, but I hope you will understand
the problem. Thanks and will be waiting for answer.
I am adding my source code to make it more clear:
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/CAJjoRZm1DHJe-9-epPDwY%2BmEG-%3DGRyLkXrurr4rDPfJeH%3DLS9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
// ---------- Main registration method ------------
public boolean doRegistration () {
this.driver.get(this.account.getUrl());
this.clickMainPageRegister ();
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".row-fluid.agreement.agree-term>label")));
this.fill();
this.clickRegisterConfirm();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
this.addError();
try {
this.openNewTabForActivationEmail();
this.fillEmailLoginInformation();
Thread.sleep(5000);
this.openActivationEmail();
}catch (NoSuchElementException | InterruptedException ex) {
}
return (this.getErrors().size() == 0);
}
// ------ Fill registration information --------------
private void fill () {
this.enterUsername();
this.enterPassword();
this.retypePassword();
this.userAgreement();
}
private void addError() {
String error = this.findErrors();
if (error != null) {
this.errors.add(this.findErrors());
}
}
private void clickMainPageRegister () {
this.driver.findElement(this.MainPageRegister).click();
}
private void enterUsername() {
this.driver.findElement(By.id("UserRegistrationForm_username")).sendKeys(this.account.getUsername());;
}
private void enterPassword () {
this.driver.findElement(By.id("UserRegistrationForm_password")).sendKeys(this.account.getPassword());;
}
private void retypePassword () {
this.driver.findElement(By.id("UserRegistrationForm_verifyPassword")).sendKeys(this.account.getPassword());;
}
private void userAgreement () {
this.driver.findElement(By.id("UserRegistrationForm_agreeTerms")).click();
}
private void clickRegisterConfirm () {
this.driver.findElement(By.cssSelector("#registrationForm
.btn")).click();
}
private String findErrors() {
String error = null;
try {
error =
this.driver.findElement(By.className("errorMessage")).getText();
} catch (NoSuchElementException e) {
}
return error;
}
// --------- Open new email tab -------------------
public void openNewTabForActivationEmail () {
if
(this.driver.findElement(By.cssSelector(".alert.alert-dismissible.alert-info.registration-info.fade.in")).isDisplayed()){
this.driver.findElement(By.cssSelector("Body")).sendKeys(Keys.CONTROL+ "t");
this.driver.get("https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/&hl=lt#identifier");
}else {
Assert.fail();
System.out.println("No activation email was sent");
}
}
// ------ Fill email login information --------------------
public void fillEmailLoginInformation() {
this.driver.findElement(By.cssSelector("#Email")).sendKeys(this.account.getUsername());
this.driver.findElement(By.cssSelector("#next")).click();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#Passwd")));
this.driver.findElement(By.cssSelector("#Passwd")).sendKeys(this.account.getPassword());
this.driver.findElement(By.cssSelector("#signIn")).click();
WebDriverWait wait1 = new WebDriverWait(driver, 30);
wait1.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".aio.UKr6le")));
}
// --------- Open Cloud activation email ---------------------
private void openActivationEmail () {
System.out.println("Laukiu emailo");
List<WebElement> elements =
this.driver.findElements(By.cssSelector(".y2"));
if(elements.get(0).getText().contains("Activate your account")){
elements.get(0).click();
this.driver.findElement(By.cssSelector(".a3s fieldset
a")).click();
}
}
public ArrayList<String> getErrors() {
return errors;
}