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: Update the E2E selenium tests according to the changes on dashboard #13589

Merged
merged 6 commits into from
Jun 21, 2019
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 @@ -74,7 +74,7 @@ public interface Locators {
String BULK_CHECKBOX = "//md-checkbox[@aria-label='Workspace list']";
String SEARCH_WORKSPACE_FIELD = "//input[@ng-placeholder='Search']";
String NO_WORKSPACE_FOUND = "//span[text()='No workspaces found.']";
String WORKSPACE_ITEM_NAME = "//div[@id='ws-name-%s']";
String WORKSPACE_ITEM_NAME = "//div[@class='workspace-name-clip' and contains(@id, '/%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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class TheiaIde {
}

public interface Locators {
String THEIA_CHE_DASHBOARD_XPATH = "//div[@class='che-dashboard']";
String THEIA_IDE_ID = "theia-app-shell";
String THEIA_IDE_TOP_PANEL_ID = "theia-top-panel";
String LOADER_XPATH = "//div[@class='theia-preload theia-hidden']";
Expand All @@ -63,6 +64,9 @@ public interface Locators {
"//div[@class='theia-NotificationsContainer']//button[text()='Close']";
}

@FindBy(xpath = Locators.THEIA_CHE_DASHBOARD_XPATH)
WebElement theiaCheDashboard;

@FindBy(id = Locators.THEIA_IDE_ID)
WebElement theiaIde;

Expand All @@ -84,6 +88,10 @@ public interface Locators {
@FindBy(xpath = Locators.ABOUT_DIALOG_OK_BUTTON_XPATH)
WebElement aboutDialogOkButton;

public void openNavbarMenu() {
seleniumWebDriverHelper.waitAndClick(theiaCheDashboard);
}

private String getNotificationEqualsToXpath(String messageText) {
return format(NOTIFICATION_MESSAGE_EQUALS_TO_XPATH_TEMPLATE, messageText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ public boolean isRootItemSelected() {
public void openItem(String itemPath) {
clickOnItem(itemPath);
waitItemSelected(itemPath);
doubleClickOnItem(itemPath);
}

public boolean isItemVisible(String itemPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public String getProposalKeyBinding(int proposalIndex) {
final String keyBindingContainerXpath =
format(PROPOSAL_KEY_BINDING_XPATH_TEMPLATE, adoptedIndex);

if (isKeyBindingFieldExisted(proposalIndex)) {
if (isKeyBindingFieldExisted(adoptedIndex)) {
return seleniumWebDriverHelper.waitVisibilityAndGetText(By.xpath(keyBindingContainerXpath));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
package org.eclipse.che.selenium.dashboard;

import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.pageobject.ProjectExplorer.FolderTypes.PROJECT_FOLDER;
import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE;
import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.WEB_JAVA_SPRING;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.WorkspaceDetailsTab.PROJECTS;
Expand All @@ -21,21 +20,18 @@
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.core.workspace.TestWorkspaceProvider;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.MavenPluginStatusBar;
import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.ToastLoader;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.NavigationBar;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Stack;
import org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceProjects;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.eclipse.che.selenium.pageobject.theia.TheiaIde;
import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand All @@ -53,17 +49,14 @@ public class CreateAndDeleteProjectsTest {
@Inject private WorkspaceDetails workspaceDetails;
@Inject private NewWorkspace newWorkspace;
@Inject private ProjectSourcePage projectSourcePage;
@Inject private ProjectExplorer explorer;
@Inject private SeleniumWebDriver seleniumWebDriver;
@Inject private SeleniumWebDriverHelper seleniumWebDriverHelper;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private DefaultTestUser defaultTestUser;
@Inject private NotificationsPopupPanel notificationsPopupPanel;
@Inject private MavenPluginStatusBar mavenPluginStatusBar;
@Inject private Workspaces workspaces;
@Inject private Ide ide;
@Inject private ToastLoader toastLoader;
@Inject private TestWorkspaceProvider testWorkspaceProvider;
@Inject private TheiaIde theiaIde;
@Inject private TheiaProjectTree theiaProjectTree;
@Inject private NavigationBar navigationBar;

// it is used to read workspace logs on test failure
private TestWorkspace testWorkspace;
Expand All @@ -84,6 +77,7 @@ public void createProjectTest() {
dashboard.selectWorkspacesItemOnDashboard();
workspaces.clickOnAddWorkspaceBtn();
newWorkspace.waitToolbar();
dashboardWindow = seleniumWebDriver.getWindowHandle();

// we are selecting 'Java' stack from the 'All Stack' tab for compatibility with OSIO
newWorkspace.selectStack(Stack.JAVA_MAVEN);
Expand All @@ -106,25 +100,27 @@ public void createProjectTest() {
testWorkspace = testWorkspaceProvider.getWorkspace(WORKSPACE, defaultTestUser);

// switch to the IDE and wait for workspace is ready to use
dashboardWindow = seleniumWebDriverHelper.switchToIdeFrameAndWaitAvailability();
toastLoader.waitToastLoaderAndClickStartButton();
ide.waitOpenedWorkspaceIsReadyToUse();

// wait for projects initializing
explorer.waitItem(WEB_JAVA_SPRING);
explorer.waitItem(CONSOLE_JAVA_SIMPLE);
explorer.waitItem(SECOND_WEB_JAVA_SPRING_PROJECT_NAME);
notificationsPopupPanel.waitPopupPanelsAreClosed();
mavenPluginStatusBar.waitClosingInfoPanel();
explorer.waitDefinedTypeOfFolder(CONSOLE_JAVA_SIMPLE, PROJECT_FOLDER);
explorer.waitDefinedTypeOfFolder(WEB_JAVA_SPRING, PROJECT_FOLDER);
notificationsPopupPanel.waitPopupPanelsAreClosed();
theiaIde.switchToIdeFrame();
theiaIde.waitTheiaIde();
theiaIde.waitLoaderInvisibility();
theiaIde.waitTheiaIdeTopPanel();
theiaProjectTree.waitFilesTab();

// wait for projects in the tree
theiaProjectTree.clickOnFilesTab();
theiaProjectTree.waitProjectsRootItem();
theiaProjectTree.waitProjectAreaOpened();
theiaProjectTree.waitItem(WEB_JAVA_SPRING);
theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE);
}

@Test(priority = 1)
public void deleteProjectsFromDashboardTest() {
theiaIde.openNavbarMenu();
seleniumWebDriver.switchTo().window(dashboardWindow);
navigationBar.waitNavigationBar();
dashboard.selectWorkspacesItemOnDashboard();
workspaces.waitAddWorkspaceButton();
workspaces.selectWorkspaceItemName(WORKSPACE);
workspaceDetails.selectTabInWorkspaceMenu(PROJECTS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.core.workspace.TestWorkspaceProvider;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.ToastLoader;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Stack;
import org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.eclipse.che.selenium.pageobject.theia.TheiaIde;
import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand All @@ -43,17 +41,15 @@ public class ImportMavenProjectFromGitTest {
private String testProjectName;

@Inject private Dashboard dashboard;
@Inject private ProjectExplorer explorer;
@Inject private NewWorkspace newWorkspace;
@Inject private ProjectSourcePage projectSourcePage;
@Inject private SeleniumWebDriverHelper seleniumWebDriverHelper;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestWorkspaceProvider testWorkspaceProvider;
@Inject private DefaultTestUser defaultTestUser;
@Inject private Workspaces workspaces;
@Inject private Ide ide;
@Inject private ToastLoader toastLoader;
@Inject private TestGitHubRepository testRepo;
@Inject private TheiaIde theiaIde;
@Inject private TheiaProjectTree theiaProjectTree;

// it is used to read workspace logs on test failure
private TestWorkspace testWorkspace;
Expand Down Expand Up @@ -96,10 +92,15 @@ public void checkAbilityImportMavenProjectTest() {
// possible to read logs in case of test failure
testWorkspace = testWorkspaceProvider.getWorkspace(WORKSPACE, defaultTestUser);

seleniumWebDriverHelper.switchToIdeFrameAndWaitAvailability();
theiaIde.switchToIdeFrame();
theiaIde.waitTheiaIde();
theiaIde.waitLoaderInvisibility();
theiaIde.waitTheiaIdeTopPanel();

toastLoader.waitToastLoaderAndClickStartButton();
ide.waitOpenedWorkspaceIsReadyToUse();
explorer.waitItem(testProjectName);
// wait the project in the tree
theiaProjectTree.clickOnFilesTab();
theiaProjectTree.waitProjectsRootItem();
theiaProjectTree.waitProjectAreaOpened();
theiaProjectTree.waitItem(testProjectName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.core.utils.WaitUtils.sleepQuietly;
import static org.eclipse.che.selenium.pageobject.ProjectExplorer.FolderTypes.PROJECT_FOLDER;
import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Sources.GITHUB;
import static org.testng.AssertJUnit.assertTrue;

Expand All @@ -30,13 +29,13 @@
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.core.workspace.TestWorkspaceProvider;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.ToastLoader;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Stack;
import org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.eclipse.che.selenium.pageobject.theia.TheiaIde;
import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand All @@ -61,15 +60,15 @@ public class ImportProjectFromGitHubTest {
@Inject private Dashboard dashboard;
@Inject private Workspaces workspaces;
@Inject private DefaultTestUser defaultTestUser;
@Inject private ProjectExplorer projectExplorer;
@Inject private NewWorkspace newWorkspace;
@Inject private ToastLoader toastLoader;
@Inject private ProjectSourcePage projectSourcePage;
@Inject private SeleniumWebDriver seleniumWebDriver;
@Inject private SeleniumWebDriverHelper seleniumWebDriverHelper;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestWorkspaceProvider testWorkspaceProvider;
@Inject private TestGitHubRepository testRepo;
@Inject private TheiaIde theiaIde;
@Inject private TheiaProjectTree theiaProjectTree;

// it is used to read workspace logs on test failure
private TestWorkspace testWorkspace;
Expand Down Expand Up @@ -117,11 +116,16 @@ public void checkAbilityImportProjectFromGithub() {
// possible to read logs in case of test failure
testWorkspace = testWorkspaceProvider.getWorkspace(WORKSPACE, defaultTestUser);

seleniumWebDriverHelper.switchToIdeFrameAndWaitAvailability();
toastLoader.waitToastLoaderAndClickStartButton();
ide.waitOpenedWorkspaceIsReadyToUse();
projectExplorer.waitItem(projectName);
projectExplorer.waitDefinedTypeOfFolder(projectName, PROJECT_FOLDER);
theiaIde.switchToIdeFrame();
theiaIde.waitTheiaIde();
theiaIde.waitLoaderInvisibility();
theiaIde.waitTheiaIdeTopPanel();

// wait the project in the tree
theiaProjectTree.clickOnFilesTab();
theiaProjectTree.waitProjectsRootItem();
theiaProjectTree.waitProjectAreaOpened();
theiaProjectTree.waitItem(projectName);
}

private void connectGithubAccount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
package org.eclipse.che.selenium.dashboard;

import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.core.TestGroup.UNDER_REPAIR;
import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Sources.ZIP;
import static org.testng.Assert.fail;

import com.google.inject.Inject;
import java.io.IOException;
Expand All @@ -21,39 +23,37 @@
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.core.workspace.TestWorkspaceProvider;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.ToastLoader;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Stack;
import org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.eclipse.che.selenium.pageobject.theia.TheiaIde;
import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree;
import org.openqa.selenium.TimeoutException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/** @author Andrey Chizhikov */
@Test(groups = UNDER_REPAIR)
public class ImportProjectFromZipTest {

private final String WORKSPACE = generate("ImptPrjFromZip", 4);
private static final String PROJECT_NAME = "master";

@Inject private Dashboard dashboard;
@Inject private ProjectExplorer explorer;
@Inject private NewWorkspace newWorkspace;
@Inject private ProjectSourcePage projectSourcePage;
@Inject private ToastLoader toastLoader;
@Inject private SeleniumWebDriverHelper seleniumWebDriverHelper;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private DefaultTestUser defaultTestUser;
@Inject private Workspaces workspaces;
@Inject private Ide ide;
@Inject private TestGitHubRepository testRepo;
@Inject private TestWorkspaceProvider testWorkspaceProvider;
@Inject private TheiaIde theiaIde;
@Inject private TheiaProjectTree theiaProjectTree;

// it is used to read workspace logs on test failure
private TestWorkspace testWorkspace;
Expand Down Expand Up @@ -98,11 +98,24 @@ public void importProjectFromZipTest() {
// possible to read logs in case of test failure
testWorkspace = testWorkspaceProvider.getWorkspace(WORKSPACE, defaultTestUser);

seleniumWebDriverHelper.switchToIdeFrameAndWaitAvailability();
toastLoader.waitToastLoaderAndClickStartButton();
ide.waitOpenedWorkspaceIsReadyToUse();
explorer.waitItem(PROJECT_NAME);
explorer.waitAndSelectItem(PROJECT_NAME);
explorer.openContextMenuByPathSelectedItem(PROJECT_NAME);
theiaIde.switchToIdeFrame();
theiaIde.waitTheiaIde();
theiaIde.waitLoaderInvisibility();
theiaIde.waitTheiaIdeTopPanel();
theiaProjectTree.waitFilesTab();

// wait the project in the tree
theiaProjectTree.clickOnFilesTab();
theiaProjectTree.waitProjectsRootItem();
theiaProjectTree.waitProjectAreaOpened();
theiaIde.waitTheiaIdeTopPanel();
theiaProjectTree.waitFilesTab();

try {
theiaProjectTree.waitItem(PROJECT_NAME);
} catch (TimeoutException ex) {
// remove try-catch block after issue has been resolved
fail("Known permanent failure https://github.com/eclipse/che/issues/13579");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is permanent failure, let's set @Test(groups = UNDER_REPAIR) for the test to exclude it from regular test execution.

Copy link
Contributor Author

@artaleks9 artaleks9 Jun 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.
I simply wanted to verify that it "works" as expected when is run the test suite.

}
}
}
Loading