[Selenium] Fix unstable selenium tests from dashboard and organizations packages (#15475)

7.20.x
Sergey Skorik 2019-12-17 15:26:43 +02:00 committed by GitHub
parent aa8e24f73a
commit 15a1114709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 56 deletions

View File

@ -278,7 +278,7 @@ public class ProjectSourcePage {
}
public void waitGithubProjectList() {
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
new WebDriverWait(seleniumWebDriver, LOADER_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(Locators.GITHUB_PROJECTS_LIST)))
.isDisplayed();
}

View File

@ -57,8 +57,7 @@ public class WorkspaceDetails {
String APPLY_CHANGES_BUTTON = "//che-button-save-flat[@class='apply-button']";
String CANCEL_CHANGES_BUTTON = "//button[@name='cancel-button']";
String CANCEL_DIALOG_BUTTON = "//md-dialog[@role='dialog']//button/span[text()='Cancel']";
String CLOSE_DIALOG_BUTTON =
"//*[@id='cancel-dialog-button']//*[contains(@class, 'che-button')]";
String CLOSE_DIALOG_BUTTON_NAME = "close-dialog-button";
String DELETE_DIALOG_BUTTON = "//*[@id='ok-dialog-button']/*[contains(@class, 'che-button')]";
String UPDATE_DIALOG_BUTTON = "//md-dialog[@role='dialog']//button/span[text()='Update']";
String ADD_DIALOG_BUTTON = "//md-dialog[@role='dialog']//button/span[text()='Add']";
@ -160,7 +159,7 @@ public class WorkspaceDetails {
@FindBy(xpath = Locators.DELETE_DIALOG_BUTTON)
WebElement deleteBtn;
@FindBy(xpath = Locators.CLOSE_DIALOG_BUTTON)
@FindBy(name = Locators.CLOSE_DIALOG_BUTTON_NAME)
WebElement closeBtn;
public WebElement wait(ActionButton actionButton) {

View File

@ -229,6 +229,10 @@ public class WorkspaceOverview {
return errorMessages.getText().equals(message);
}
public void waitWorkspaceNameErrorMessageNotVisible() {
seleniumWebDriverHelper.waitInvisibility(errorMessages);
}
public void checkOnWorkspaceNameErrorAbsence() {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(invisibilityOfElementLocated(By.xpath("//che-error-messages/div")));

View File

@ -126,4 +126,9 @@ public class WorkspaceShare {
seleniumWebDriverHelper.waitAndClick(
By.xpath(Locators.NO_MEMBERS_IN_ORGANIZATION_DIALOG_XPATH));
}
public void waitNoMembersDialogClosed() {
seleniumWebDriverHelper.waitInvisibility(
By.xpath("//div[@class='md-dialog-container ng-scope']"));
}
}

View File

@ -89,7 +89,7 @@ public class Workspaces {
String WORKSPACE_ITEM_ADD_PROJECT_BUTTON =
"//div[@id='ws-name-%s']//span[@name='add-project-button']";
String WORKSPACE_ITEM_STOP_START_WORKSPACE_BUTTON =
"//div[@id='ws-name-%s']//*[@name='workspace-stop-start-button']/div";
"//div[@id='ws-name-%s']//*[@name='workspace-stop-start-button']";
String WORKSPACE_LIST_HEADER = "//md-item[@class='noselect']//span";
String WORKSPACE_LIST_ITEM =
"(//div[@class='workspace-name-clip']/parent::div/parent::div/parent::div)[%s]";
@ -265,20 +265,14 @@ public class Workspaces {
.getText();
}
public void clickOnWorkspaceActionsButton(String workspaceName) {
redrawUiElementsTimeout
.until(
visibilityOfElementLocated(
By.xpath(format(Locators.WORKSPACE_ITEM_ACTIONS, workspaceName))))
.click();
}
public void clickOnWorkspaceActionsButton(String workspaceName, String actionButton) {
moveCursorToWorkspaceRamSection(workspaceName);
waitWorkspaceActionTooltipDisappearance();
public void clickOnWorkspaceConfigureButton(String workspaceName) {
redrawUiElementsTimeout
.until(
visibilityOfElementLocated(
By.xpath(format(Locators.WORKSPACE_ITEM_CONFIGURE_BUTTON, workspaceName))))
.click();
seleniumWebDriverHelper.moveCursorTo(By.xpath(format(actionButton, workspaceName)));
seleniumWebDriverHelper.isVisible(
By.xpath("//che-workspace-status//div[@uib-tooltip-popup and @is-open='isOpen']"));
seleniumWebDriverHelper.waitAndClick((By.xpath(format(actionButton, workspaceName))));
}
public void clickOnWorkspaceListItem(String userName, String workspaceName) {
@ -286,14 +280,6 @@ public class Workspaces {
seleniumWebDriverHelper.waitAndClick(By.id(itemId));
}
public void clickOnWorkspaceAddProjectButton(String workspaceName) {
redrawUiElementsTimeout
.until(
visibilityOfElementLocated(
By.xpath(format(Locators.WORKSPACE_ITEM_ADD_PROJECT_BUTTON, workspaceName))))
.click();
}
public void clickOnRamButton() {
seleniumWebDriverHelper.waitVisibility(By.xpath("//div[@che-column-title='RAM']/div")).click();
}

View File

@ -13,8 +13,6 @@ package org.eclipse.che.selenium.dashboard;
import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.WorkspaceDetailsTab.OVERVIEW;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import com.google.inject.Inject;
import java.io.IOException;
@ -79,14 +77,14 @@ public class RenameWorkspaceTest {
// type name with 1 characters and check error message that this name is too short
workspaceOverview.enterNameWorkspace("w");
workspaceDetails.waitAllDisabled(ActionButton.SAVE_BUTTON, ActionButton.APPLY_BUTTON);
assertTrue(workspaceOverview.isWorkspaceNameErrorMessageEquals(WS_NAME_TOO_SHORT));
workspaceOverview.waitNameErrorMessage(WS_NAME_TOO_SHORT);
workspaceDetails.clickOnCancelChangesBtn();
workspaceOverview.checkNameWorkspace(WORKSPACE_NAME);
// type name with 101 characters and check error message that this name is too long
workspaceOverview.enterNameWorkspace(MAX_WORKSPACE_NAME + "a");
workspaceDetails.waitAllDisabled(ActionButton.SAVE_BUTTON, ActionButton.APPLY_BUTTON);
assertTrue(workspaceOverview.isWorkspaceNameErrorMessageEquals(WS_NAME_TOO_LONG));
workspaceOverview.waitNameErrorMessage(WS_NAME_TOO_LONG);
workspaceDetails.clickOnCancelChangesBtn();
workspaceOverview.checkNameWorkspace(WORKSPACE_NAME);
@ -100,8 +98,7 @@ public class RenameWorkspaceTest {
private void renameWorkspace(String name) {
workspaceOverview.enterNameWorkspace(name);
workspaceOverview.checkOnWorkspaceNameErrorAbsence();
assertFalse(workspaceOverview.isWorkspaceNameErrorMessageEquals(WS_NAME_TOO_SHORT));
assertFalse(workspaceOverview.isWorkspaceNameErrorMessageEquals(WS_NAME_TOO_LONG));
workspaceOverview.waitWorkspaceNameErrorMessageNotVisible();
saveAndWaitWorkspaceRestarted();
workspaceOverview.checkNameWorkspace(name);
}

View File

@ -16,11 +16,11 @@ import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspace
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import com.google.inject.Inject;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.selenium.core.TestGroup;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.organization.InjectTestOrganization;
import org.eclipse.che.selenium.core.organization.TestOrganization;
import org.eclipse.che.selenium.core.user.AdminTestUser;
@ -32,12 +32,12 @@ import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Devfile;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceShare;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.openqa.selenium.WebDriverException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test(groups = {TestGroup.MULTIUSER, TestGroup.OPENSHIFT, TestGroup.K8S, TestGroup.FLAKY})
@Test(groups = {TestGroup.MULTIUSER, TestGroup.OPENSHIFT, TestGroup.K8S})
public class ShareWorkspaceOwnerTest {
private static final String WORKSPACE_NAME = generate("workspace", 4);
@ -58,6 +58,7 @@ public class ShareWorkspaceOwnerTest {
@Inject private Workspaces workspaces;
@Inject private TestUser testUser;
@Inject private WorkspaceShare workspaceShare;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@BeforeClass
public void setUp() throws Exception {
@ -75,18 +76,18 @@ public class ShareWorkspaceOwnerTest {
navigationBar.waitNavigationBar();
dashboard.selectWorkspacesItemOnDashboard();
try {
workspaces.selectWorkspaceItemName(WORKSPACE_NAME);
} catch (WebDriverException ex) {
// remove try-catch block after issue has been resolved
fail("Known random failure https://github.com/eclipse/che/issues/8594");
}
workspaces.selectWorkspaceItemName(WORKSPACE_NAME);
workspaceDetails.waitToolbarTitleName(WORKSPACE_NAME);
workspaceDetails.selectTabInWorkspaceMenu(SHARE);
}
@AfterClass
public void tearDown() throws Exception {
workspaceServiceClient.delete(WORKSPACE_NAME, adminTestUser.getName());
org.delete();
}
@Test
public void checkShareWorkspaceTab() {
// check workspace owner permissions
@ -137,6 +138,7 @@ public class ShareWorkspaceOwnerTest {
assertEquals(workspaceShare.getMemberPermissions(memberName), MEMBER_PERMISSIONS);
// check the 'No members in team' dialog
workspaceShare.waitNoMembersDialogClosed();
workspaceShare.clickOnAddDeveloperButton();
workspaceShare.waitNoMembersDialog();
workspaceDetails.clickOnCloseButtonInDialogWindow();

View File

@ -13,8 +13,10 @@ package org.eclipse.che.selenium.dashboard.workspaces;
import static java.util.Arrays.asList;
import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.core.TestGroup.FLAKY;
import static org.eclipse.che.selenium.core.TestGroup.UNDER_REPAIR;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Locators.WORKSPACE_ITEM_ADD_PROJECT_BUTTON;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Locators.WORKSPACE_ITEM_CONFIGURE_BUTTON;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Locators.WORKSPACE_ITEM_STOP_START_WORKSPACE_BUTTON;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
@ -44,7 +46,7 @@ import org.testng.annotations.Test;
* @author Sergey Skorik
* @author Ihor Okhrimenko
*/
@Test(groups = {FLAKY})
@Test
public class WorkspacesListTest {
private static final String EXPECTED_JAVA_PROJECT_NAME = "console-java-simple";
private static final String NEWEST_CREATED_WORKSPACE_NAME = "just-created-workspace";
@ -224,31 +226,25 @@ public class WorkspacesListTest {
// check "Add project" button
workspaces.waitPageLoading();
workspaces.moveCursorToWorkspaceRamSection(WORKSPACE_NAME2);
workspaces.clickOnWorkspaceAddProjectButton(WORKSPACE_NAME2);
workspaces.clickOnWorkspaceActionsButton(WORKSPACE_NAME2, WORKSPACE_ITEM_ADD_PROJECT_BUTTON);
workspaceProjects.waitProjectIsPresent(EXPECTED_JAVA_PROJECT_NAME);
seleniumWebDriver.navigate().back();
// check "Workspace configuration" button
workspaces.waitPageLoading();
workspaces.moveCursorToWorkspaceRamSection(WORKSPACE_NAME2);
workspaces.clickOnWorkspaceConfigureButton(WORKSPACE_NAME2);
workspaces.clickOnWorkspaceActionsButton(WORKSPACE_NAME2, WORKSPACE_ITEM_CONFIGURE_BUTTON);
workspaceConfig.waitConfigForm();
seleniumWebDriver.navigate().back();
// check stop/start button
workspaces.waitPageLoading();
workspaces.moveCursorToWorkspaceRamSection(WORKSPACE_NAME2);
workspaces.clickOnWorkspaceStopStartButton(WORKSPACE_NAME2);
workspaces.clickOnWorkspaceActionsButton(
WORKSPACE_NAME2, WORKSPACE_ITEM_STOP_START_WORKSPACE_BUTTON);
workspaces.waitWorkspaceStatus(WORKSPACE_NAME2, Status.RUNNING);
workspaces.clickOnWorkspaceStopStartButton(WORKSPACE_NAME2);
workspaces.clickOnWorkspaceActionsButton(
WORKSPACE_NAME2, WORKSPACE_ITEM_STOP_START_WORKSPACE_BUTTON);
workspaces.waitWorkspaceStatus(WORKSPACE_NAME2, Status.STOPPED);
// check adding the workspace to list