Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mission control view plugin: test basis and two test cases #320

Merged
merged 6 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package org.jenkinsci.test.acceptance.plugins.mission_control;

import org.jenkinsci.test.acceptance.po.PageAreaImpl;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;

/**
* A {@link PageAreaImpl} of the {@link MissionControlView} which offers specific methods to retrieve informations from it.
*/
public class BuildHistoryArea extends PageAreaImpl {

// The parent mission control view of the build history area
private MissionControlView parent;
// The basic element of the page area
private WebElement buildHistory;

/**
* Constructor.
*
* @param view The parent mission control view.
*/
public BuildHistoryArea(MissionControlView view) {
super(view, "");
this.parent = view;
}

/**
* Ensures that the parent {@link MissionControlView} is open. Subsequently, sets the internal buildHistory
* to eliminate the risk of a {@link org.openqa.selenium.StaleElementReferenceException}.
*/
private void setBuildHistory() {
parent.ensureViewIsOpen();
buildHistory = driver.findElement(By.id("jenkinsBuildHistory"));
}

/**
* Determines the size of the build history.
*
* @return The size of the build history.
*/
public int getBuildHistorySize() {
setBuildHistory();
return buildHistory.findElements(By.xpath(".//tbody/tr")).size();
}

/**
* Retrieves all builds as {@link WebElement} of a specific job.
*
* @param jobname The name of the job.
* @return A {@link List} of all builds of the job.
*/
public List<WebElement> getBuildsByJobName(String jobname) {
setBuildHistory();
return buildHistory.findElements(By.xpath(".//tbody/tr[td='" + jobname + "']"));
}

/**
* Retrieves all failed builds as {@link WebElement} of all jobs.
*
* @return A {@link List} of all failed builds of all jobs.
*/
public List<WebElement> getFailedBuilds() {
setBuildHistory();
return buildHistory.findElements(By.xpath(".//tbody/tr[@class='danger']"));
}

/**
* Retrieves all failed builds as {@link WebElement} of a specific job.
*
* @return A {@link List} of all failed builds of the job.
*/
public List<WebElement> getFailedBuildsOfJob(String jobname) {
setBuildHistory();
return buildHistory.findElements(By.xpath(".//tbody/tr[td='" + jobname + "' and @class='danger']"));
}

/**
* Retrieves all successful builds as {@link WebElement} of all jobs.
*
* @return A {@link List} of all successful builds of all jobs.
*/
public List<WebElement> getSuccessfulBuilds() {
setBuildHistory();
return buildHistory.findElements(By.xpath(".//tbody/tr[@class='']"));
}

/**
* Retrieves all successful builds as {@link WebElement} of a specific job.
*
* @return A {@link List} of all successful builds of the job.
*/
public List<WebElement> getSuccessfulBuildsOfJob(String jobname) {
setBuildHistory();
return buildHistory.findElements(By.xpath(".//tbody/tr[td='" + jobname + "' and @class='']"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.jenkinsci.test.acceptance.plugins.mission_control;

import org.jenkinsci.test.acceptance.po.PageAreaImpl;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

/**
* A {@link PageAreaImpl} of the {@link MissionControlView} which offers specific methods to retrieve informations from it.
*/
public class BuildQueueArea extends PageAreaImpl {

// The parent mission control view of the build history area
private MissionControlView parent;
// The basic element of the page area
public WebElement buildQueue;

/**
* Constructor.
*
* @param view The parent mission control view.
*/
public BuildQueueArea(MissionControlView view) {
super(view, "");
this.parent = view;
}

/**
* Ensures that the parent {@link MissionControlView} is open. Subsequently, sets the internal buildQueue
* to eliminate the risk of {@link org.openqa.selenium.StaleElementReferenceException}.
*/
private void setBuildQueue() {
parent.ensureViewIsOpen();
buildQueue = driver.findElement(By.id("jenkinsBuildQueue"));
}

/**
* Determines the current size of the build queue.
*
* @return The size of the build queue.
*/
public int getBuildQueueSize() {
setBuildQueue();
return buildQueue.findElements(By.xpath(".//tbody/tr")).size();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package org.jenkinsci.test.acceptance.plugins.mission_control;

import org.jenkinsci.test.acceptance.po.PageAreaImpl;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.List;

/**
* A {@link PageAreaImpl} of the {@link MissionControlView} which offers specific methods to retrieve informations from it.
*/
public class JobStatusArea extends PageAreaImpl {

// The parent mission control view of the build history area
private MissionControlView parent;
// The basic element of the page area
public WebElement jobContainer;

/**
* Constructor.
*
* @param view The parent mission control view.
*/
public JobStatusArea(MissionControlView view) {
super(view, "");
this.parent = view;
}

/**
* Ensures that the parent {@link MissionControlView} is open. Subsequently, sets the internal jobStatuses
* to eliminate the risk of {@link org.openqa.selenium.StaleElementReferenceException}.
*/
private void setJobContainer() {
parent.ensureViewIsOpen();
jobContainer = driver.findElement(By.id("jenkinsJobStatuses"));
}

/**
* Determines the current number of jobs.
*
* @return The current number of jobs.
*/
public int getNumberOfJobs(){
setJobContainer();
return jobContainer.findElements(By.xpath("//button")).size();
}

/**
* Retrieves a job by name from the job container
*
* @param jobname The name of the job.
* @return A single job entry.
*/
public WebElement getJobByName(String jobname){
setJobContainer();
return jobContainer.findElement(By.xpath("//button[text()='" + jobname + "']"));
}

/**
* Retrieves the status of a job, which is indicated by the class-attribute.
*
* @param jobname The name of the job.
* @return The class-attribute, which contains the current status of the job.
*/
public String getStatusOfJob(String jobname){
setJobContainer();
WebElement e = jobContainer.findElement(By.xpath("//button[text()='" + jobname + "']"));
return e.getAttribute("class");
}

/**
* Retrieves all jobs that are not build yet. This is indicated by the class-attribute of the job-element.
*
* @return A {@link List} of all jobs that are not build yet.
*/
public List<WebElement> getNotBuildJobs(){
setJobContainer();
return jobContainer.findElements(By.xpath("//button[@class='invert-text-color']"));
}

/**
* Retrieves all jobs that are successfully build. This is indicated by the class-attribute of the job-element.
*
* @return A {@link List} of all successfully build jobs.
*/
public List<WebElement> getSuccessfulJobs(){
setJobContainer();
return jobContainer.findElements(By.xpath("//button[@class='btn-success']"));
}

/**
* Retrieves all jobs that failed to build. This is indicated by the class-attribute of the job-element.
*
* @return A {@link List} of all jobs that failed to build.
*/
public List<WebElement> getFailedJobs(){
setJobContainer();
return jobContainer.findElements(By.xpath("//button[@class='btn-danger']"));
}
}
Loading