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

Selenium: adapt selenium tests according to changes in a workspace creation flow #8349

Merged
merged 2 commits into from
Jan 18, 2018
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
Expand Up @@ -13,6 +13,7 @@
import static java.lang.String.format;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC;
import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated;

Expand Down Expand Up @@ -48,7 +49,7 @@ private interface Locators {
String WORKSPACE_NAME_INPUT = "workspace-name-input";
String ERROR_MESSAGE = "new-workspace-error-message";
String TOOLBAR_TITLE_ID = "New_Workspace";
String CREATE_BUTTON = "create-workspace-button";
String CREATE_BUTTON = "//che-button-save-flat[@name='saveButton']";
String SELECT_ALL_STACKS_TAB = "all-stacks-button";
String SELECT_QUICK_START_STACKS_TAB = "quick-start-button";
String SELECT_SINGLE_MACHINE_STACKS_TAB = "single-machine-button";
Expand All @@ -72,6 +73,9 @@ private interface Locators {
String INCREMENT_MEMORY_BUTTON =
"//*[@id='machine-%s-ram']//button[@aria-label='Increment memory']";
String MACHINE_RAM_VALUE = "//*[@id='machine-%s-ram']//input";
String WORKSPACE_CREATED_DIALOG = "//md-dialog/che-popup[@title='Workspace Is Created']";
String EDIT_WORKSPACE_DIALOG_BUTTON = "//che-button-primary//span[text()='Edit']";
String OPEN_IN_IDE_DIALOG_BUTTON = "//che-button-default//span[text()='Open In IDE']";
}

@FindBy(id = Locators.FILTERS_STACK_BUTTON)
Expand All @@ -86,7 +90,7 @@ private interface Locators {
@FindBy(id = Locators.WORKSPACE_NAME_INPUT)
WebElement workspaceNameInput;

@FindBy(id = Locators.CREATE_BUTTON)
@FindBy(xpath = Locators.CREATE_BUTTON)
WebElement createWorkspaceButton;

@FindBy(xpath = Locators.SEARCH_INPUT)
Expand Down Expand Up @@ -233,10 +237,6 @@ public boolean isCreateWorkspaceButtonEnabled() {
return !Boolean.valueOf(createWorkspaceButton.getAttribute("aria-disabled"));
}

public void clickOnCreateWorkspaceButton() {
createWorkspaceButton.click();
}

public void clickOnAllStacksTab() {
redrawUiElementsTimeout.until(visibilityOf(selectAllStacksTab)).click();
}
Expand All @@ -252,4 +252,34 @@ public void clickOnSingleMachineTab() {
public void clickOnMultiMachineTab() {
redrawUiElementsTimeout.until(visibilityOf(selectMultiMachineStacksTab)).click();
}

public void waitWorkspaceIsCreatedDialogIsVisible() {
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(Locators.WORKSPACE_CREATED_DIALOG)));
WaitUtils.sleepQuietly(1);
}

public void clickOnEditWorkspaceButton() {
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(elementToBeClickable(By.xpath(Locators.EDIT_WORKSPACE_DIALOG_BUTTON)))
.click();
}

public void clickOnOpenInIDEButton() {
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(elementToBeClickable(By.xpath(Locators.OPEN_IN_IDE_DIALOG_BUTTON)))
.click();
}

public void clickOnCreateButtonAndOpenInIDE() {
createWorkspaceButton.click();
waitWorkspaceIsCreatedDialogIsVisible();
clickOnOpenInIDEButton();
}

public void clickOnCreateButtonAndEditWorkspace() {
createWorkspaceButton.click();
waitWorkspaceIsCreatedDialogIsVisible();
clickOnEditWorkspaceButton();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.utils.WaitUtils;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.openqa.selenium.By;
Expand Down Expand Up @@ -181,7 +182,8 @@ public void clickOnSaveChangesBtn() {
}

public void clickOnCancelChangesBtn() {
loader.waitOnClosed();
// this timeout is needed for the Cancel to appears after renaming of a workspace
WaitUtils.sleepQuietly(3);
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOf(cancelBtn))
.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void createAndDeleteProjectTest() throws ExecutionException, InterruptedE
projectSourcePage.selectSample(WEB_JAVA_SPRING);
projectSourcePage.selectSample(CONSOLE_JAVA_SIMPLE);
projectSourcePage.clickOnAddProjectButton();
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

String dashboardWindow = seleniumWebDriver.getWindowHandle();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void checkAbilityImportMavenProjectTest() throws ExecutionException, Inte
projectSourcePage.typeGitRepositoryLocation("https://github.com/iedexmain1/guess-project.git");
projectSourcePage.clickOnAddProjectButton();

createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

seleniumWebDriver.switchFromDashboardIframeToIde();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void checkAbilityImportProjectFromGithub() throws Exception {
assertTrue(projectSourcePage.isGithubProjectsListDisplayed());
projectSourcePage.selectProjectFromList(GITHUB_PROJECT_NAME);
projectSourcePage.clickOnAddProjectButton();
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

seleniumWebDriver.switchFromDashboardIframeToIde(ELEMENT_TIMEOUT_SEC);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void importProjectFromZipTest() throws ExecutionException, InterruptedExc
projectSourcePage.skipRootFolder();
projectSourcePage.clickOnAddProjectButton();

createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();
seleniumWebDriver.switchFromDashboardIframeToIde();
loader.waitOnClosed();
explorer.waitItem(PROJECT_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@

import static org.eclipse.che.selenium.core.constant.TestStacksConstants.JAVA_MYSQL;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.PREPARING_WS_TIMEOUT_SEC;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.StateWorkspace.RUNNING;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.StateWorkspace.STOPPED;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.TabNames.ENV_VARIABLES;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.TabNames.MACHINES;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.TabNames.OVERVIEW;
import static org.testng.Assert.assertTrue;

import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -177,21 +175,9 @@ private void createWsFromJavaMySqlStack() {
loader.waitOnClosed();
createWorkspace.selectStack(JAVA_MYSQL.getId());
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndEditWorkspace();

seleniumWebDriver.switchFromDashboardIframeToIde(60);
projectExplorer.waitProjectExplorer();
terminal.waitTerminalTab(PREPARING_WS_TIMEOUT_SEC);

dashboard.open();
dashboard.waitDashboardToolbarTitle();
dashboard.selectWorkspacesItemOnDashboard();
dashboard.waitToolbarTitleName("Workspaces");
workspaces.selectWorkspaceItemName(WORKSPACE);
workspaces.waitToolbarTitleName(WORKSPACE);
workspaceDetails.selectTabInWorkspaceMenu(OVERVIEW);
workspaceDetails.checkStateOfWorkspace(RUNNING);
workspaceDetails.clickOnStopWorkspace();
workspaceDetails.checkStateOfWorkspace(STOPPED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void createWorkspaceOnDashboardTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(JAVA.getId());
createWorkspace.setMachineRAM("dev-machine", 2.0);
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

seleniumWebDriver.switchFromDashboardIframeToIde();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void checkJavaMySqlAndRunApp() {
projectSourcePage.clickOnAddOrImportProjectButton();
projectSourcePage.selectSample(PROJECT_NAME);
projectSourcePage.clickOnAddProjectButton();
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

seleniumWebDriver.switchFromDashboardIframeToIde(LOADER_TIMEOUT_SEC);
currentWindow = seleniumWebDriver.getWindowHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void checkNodeJsWsAndRunApp() {
projectSourcePage.clickOnAddOrImportProjectButton();
projectSourcePage.selectSample(PROJECT_NAME);
projectSourcePage.clickOnAddProjectButton();
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

seleniumWebDriver.switchFromDashboardIframeToIde();
currentWindow = seleniumWebDriver.getWindowHandle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createWorkspaceWithAndroidStackTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(TestStacksConstants.ANDROID.getId());
createWorkspace.setMachineRAM("2");
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

dashboard.waitNotificationIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void createWorkspaceWithBlankStackTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(TestStacksConstants.BLANK.getId());
createWorkspace.setMachineRAM("2");
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

dashboard.waitNotificationIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createWorkspaceWithCppStackTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(TestStacksConstants.CPP.getId());
createWorkspace.setMachineRAM("2");
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

dashboard.waitNotificationIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createWorkspaceWithNetStackTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(TestStacksConstants.DOTNET.getId());
createWorkspace.setMachineRAM("2");
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

dashboard.waitNotificationIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createWorkspaceWithNodeStackTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(TestStacksConstants.NODE.getId());
createWorkspace.setMachineRAM("2");
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

dashboard.waitNotificationIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createWorkspaceWithPHPStackTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(TestStacksConstants.PHP.getId());
createWorkspace.setMachineRAM("2");
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

dashboard.waitNotificationIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createWorkspaceWithPythonStackTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(TestStacksConstants.PYTHON.getId());
createWorkspace.setMachineRAM("2");
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

dashboard.waitNotificationIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createWorkspaceWithRailsStackTest() {
createWorkspace.typeWorkspaceName(WORKSPACE);
createWorkspace.selectStack(TestStacksConstants.RAILS.getId());
createWorkspace.setMachineRAM("2");
createWorkspace.clickOnCreateWorkspaceButton();
createWorkspace.clickOnCreateButtonAndOpenInIDE();

dashboard.waitNotificationIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down