Skip to content

Commit

Permalink
[Selenium] Adapt selenium tests to work with workspaces from Che7 sta…
Browse files Browse the repository at this point in the history
…cks (#14594)
  • Loading branch information
SkorikSergey committed Sep 26, 2019
1 parent dd47af6 commit 8761154
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 743 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,37 @@ public class CreateWorkspaceHelper {

public TestWorkspace createWorkspaceFromDevfileWithProject(
Devfile devfile, String workspaceName, String projectName) {
return createWorkspaceFromStack(devfile, workspaceName, ImmutableList.of(projectName), null);
return createAndStartWorkspaceFromStack(
devfile, workspaceName, ImmutableList.of(projectName), null);
}

public TestWorkspace createWorkspaceFromDevfileWithoutProject(
Devfile devfile, String workspaceName) {
return createWorkspaceFromStack(devfile, workspaceName, Collections.emptyList(), null);
return createAndStartWorkspaceFromStack(devfile, workspaceName, Collections.emptyList(), null);
}

public TestWorkspace createWorkspaceFromStackWithProjects(
Devfile devfile, String workspaceName, List<String> projectNames) {
return createWorkspaceFromStack(devfile, workspaceName, projectNames, null);
public TestWorkspace createAndStartWorkspaceFromStack(
Devfile devfile, String workspaceName, List<String> projectNames, Double machineRam) {
prepareWorkspace(devfile, workspaceName, machineRam);

projectSourcePage.clickOnAddOrImportProjectButton();
projectNames.forEach(projectSourcePage::selectSample);

projectSourcePage.clickOnAddProjectButton();
newWorkspace.clickOnCreateButtonAndOpenInIDE();

return testWorkspaceProvider.getWorkspace(workspaceName, defaultTestUser);
}

public TestWorkspace createWorkspaceFromStack(
public TestWorkspace createAndEditWorkspaceFromStack(
Devfile devfile, String workspaceName, List<String> projectNames, Double machineRam) {
prepareWorkspace(devfile, workspaceName, machineRam);

projectSourcePage.clickOnAddOrImportProjectButton();
projectNames.forEach(projectSourcePage::selectSample);

projectSourcePage.clickOnAddProjectButton();
newWorkspace.clickOnCreateButtonAndOpenInIDE();
newWorkspace.clickOnCreateButtonAndEditWorkspace();

return testWorkspaceProvider.getWorkspace(workspaceName, defaultTestUser);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public WorkspaceOverview(

public interface Locators {
String NAME_WORKSPACE_INPUT = "//input[@placeholder='Name of the workspace *']";
String DELETE_WORKSPACE_BTN = "//button/span[text()='Delete']";
String DELETE_WORKSPACE_BTN = "//button[text()='Delete']";
String WORKSPACE_TITLE = "//div[contains(@class,'toolbar-info')]/span[text()='%s']";
String EXPORT_WORKSPACE_BTN =
"//button[contains(@class, 'che-button')]/span[text()='Export as a file']";
"//button[contains(@class, 'che-button')][text()='Export as a file']";
String DOWNLOAD_WORKSPACE_BTN = "//che-button-default[@che-button-title='download']";
String CLIPBOARD_JSON_WS_BTN = "//che-button-default[@che-button-title='clipboard']";
String HIDE_JSON_WS_BTN = "//span[text()='Close']";
Expand All @@ -70,8 +70,7 @@ public interface Locators {
String EXPORT_WS_FORM_XPATH = "//che-popup[@title='Export Workspace']";
String AS_FILE_CONFIG_BODY_XPATH =
"//che-popup[@title='Export Workspace']//div[@class='CodeMirror-code']";

String SAVE_BUTTON_XPATH = "//button[@name='save-button' ]";
String SAVE_BUTTON_XPATH = "//che-button-save-flat[@che-button-title='Save']";
String AS_FILE_BUTTON_XPATH = "//md-tab-item/span[text()='As a File']";
String PRIVATE_CLOUD_BUTTON_XPATH = "//md-tab-item/span[text()='To Private Cloud']";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public interface Locators {
String SEARCH_WORKSPACE_FIELD = "//input[@ng-placeholder='Search']";
String NO_WORKSPACE_FOUND = "//span[text()='No workspaces found.']";
String WORKSPACE_ITEM_NAME = "//div[@class='workspace-name-clip' and contains(@id, '/%s')]";
String WORKSPACE_ITEM_XPATH = "//div[@id='ws-name-%s']";
String WORKSPACE_ITEM_FULL_NAME = "//div[@id='ws-full-name-%s']";
String WORKSPACE_ITEM_CHECKBOX = "//div[@id='ws-name-%s']//md-checkbox";
String WORKSPACE_ITEM_RAM = "//div[@id='ws-name-%s']//span[@name='workspace-ram-value']";
Expand Down Expand Up @@ -132,7 +133,7 @@ public String getWorkspaceStatus(String workspaceName) {
return new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
visibilityOfElementLocated(
By.xpath(format(Locators.WORKSPACE_ITEM_NAME, workspaceName))))
By.xpath(format(Locators.WORKSPACE_ITEM_XPATH, workspaceName))))
.getAttribute("data-ws-status");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOADER_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.PREPARING_WS_TIMEOUT_SEC;
import static org.eclipse.che.selenium.pageobject.theia.TheiaIde.Locators.NOTIFICATION_CLOSE_BUTTON;
Expand Down Expand Up @@ -57,6 +58,8 @@ public interface Locators {
String ABOUT_DIALOG_TITLE_XPATH = ABOUT_DIALOG_XPATH + "//div[@class='dialogTitle']";
String ABOUT_DIALOG_CONTENT_XPATH = ABOUT_DIALOG_XPATH + "//div[@class='dialogContent']";
String ABOUT_DIALOG_OK_BUTTON_XPATH = ABOUT_DIALOG_XPATH + "//button";
String NOTIFICATION_ITEM_XPATH =
"//div[@class='theia-notification-list-item']//div[@class='theia-notification-message']";
String NOTIFICATION_MESSAGE_EQUALS_TO_XPATH_TEMPLATE =
"//div[@class='theia-notification-list-item']//div[@class='theia-notification-message']//span[text()='%s']";
String NOTIFICATION_MESSAGE_CONTAINS_XPATH_TEMPLATE =
Expand Down Expand Up @@ -151,6 +154,11 @@ public void waitNotificationPanelClosed() {
seleniumWebDriverHelper.waitInvisibility(By.className("theia-Notification"));
}

public void waitAllNotificationsClosed() {
seleniumWebDriverHelper.waitInvisibility(
By.xpath((Locators.NOTIFICATION_ITEM_XPATH)), LOADER_TIMEOUT_SEC);
}

public void waitTheiaIde() {
try {
seleniumWebDriverHelper.waitVisibility(theiaIde, PREPARING_WS_TIMEOUT_SEC);
Expand Down

0 comments on commit 8761154

Please sign in to comment.