From 216b6ee102c78a5eeb180468927129048e5db703 Mon Sep 17 00:00:00 2001 From: SkorikSergey Date: Thu, 12 Apr 2018 10:39:40 +0300 Subject: [PATCH 1/5] NotificationPopupPanel and ToastLoader page object changed to work with SeleniumWebDriverHelper --- .../pageobject/NotificationsPopupPanel.java | 77 ++++--------------- .../che/selenium/pageobject/ToastLoader.java | 46 ++++------- 2 files changed, 32 insertions(+), 91 deletions(-) diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NotificationsPopupPanel.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NotificationsPopupPanel.java index f8e6bddb288..229d1035c37 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NotificationsPopupPanel.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NotificationsPopupPanel.java @@ -10,24 +10,18 @@ */ package org.eclipse.che.selenium.pageobject; +import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.EXPECTED_MESS_IN_CONSOLE_SEC; -import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOADER_TIMEOUT_SEC; -import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.WIDGET_TIMEOUT_SEC; import com.google.inject.Inject; import com.google.inject.Singleton; -import java.util.concurrent.TimeUnit; import org.eclipse.che.selenium.core.SeleniumWebDriver; -import org.eclipse.che.selenium.core.utils.WaitUtils; +import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper; import org.openqa.selenium.By; -import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; -import org.openqa.selenium.support.ui.ExpectedCondition; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,11 +30,12 @@ public class NotificationsPopupPanel { private static final Logger LOG = LoggerFactory.getLogger(NotificationsPopupPanel.class); - private final SeleniumWebDriver seleniumWebDriver; + private final SeleniumWebDriverHelper seleniumWebDriverHelper; @Inject - public NotificationsPopupPanel(SeleniumWebDriver seleniumWebDriver) { - this.seleniumWebDriver = seleniumWebDriver; + public NotificationsPopupPanel( + SeleniumWebDriver seleniumWebDriver, SeleniumWebDriverHelper seleniumWebDriverHelper) { + this.seleniumWebDriverHelper = seleniumWebDriverHelper; PageFactory.initElements(seleniumWebDriver, this); } @@ -58,46 +53,22 @@ public NotificationsPopupPanel(SeleniumWebDriver seleniumWebDriver) { /** wait progress Popup panel appear */ public void waitProgressBarControl() { - new WebDriverWait(seleniumWebDriver, EXPECTED_MESS_IN_CONSOLE_SEC) - .until(ExpectedConditions.visibilityOf(progressPopupPanel)); + waitProgressBarControl(EXPECTED_MESS_IN_CONSOLE_SEC); } /** wait progress Popup panel appear after timeout defined by user */ public void waitProgressBarControl(int userTimeout) { - new WebDriverWait(seleniumWebDriver, userTimeout) - .until(ExpectedConditions.visibilityOf(progressPopupPanel)); + seleniumWebDriverHelper.waitVisibility(progressPopupPanel, userTimeout); } /** wait progress Popup panel disappear */ public void waitProgressPopupPanelClose() { - new WebDriverWait(seleniumWebDriver, EXPECTED_MESS_IN_CONSOLE_SEC) - .until(ExpectedConditions.invisibilityOfElementLocated(By.id(PROGRESS_POPUP_PANEL_ID))); + waitProgressPopupPanelClose(EXPECTED_MESS_IN_CONSOLE_SEC); } /** wait progress Popup panel disappear after timeout defined by user */ public void waitProgressPopupPanelClose(int userTimeout) { - new WebDriverWait(seleniumWebDriver, userTimeout) - .until(ExpectedConditions.invisibilityOfElementLocated(By.id(PROGRESS_POPUP_PANEL_ID))); - } - - /** - * get all text from progress popup panel - * - * @return text from popup panel - */ - public String getAllMessagesFromProgressPopupPanel() { - waitProgressBarControl(); - return progressPopupPanel.getText(); - } - - /** - * get all text from progress popup panel after appearance this with timeout defined by user - * - * @return text from popup panel - */ - public String getAllMessagesFromProgressPopupPanel(int userTimeout) { - waitProgressBarControl(userTimeout); - return progressPopupPanel.getText(); + seleniumWebDriverHelper.waitInvisibility(progressPopupPanel, userTimeout); } /** @@ -106,11 +77,7 @@ public String getAllMessagesFromProgressPopupPanel(int userTimeout) { * @param message expected text */ public void waitExpectedMessageOnProgressPanelAndClosed(final String message) { - new WebDriverWait(seleniumWebDriver, LOADER_TIMEOUT_SEC) - .until( - (ExpectedCondition) - input -> getAllMessagesFromProgressPopupPanel().contains(message)); - waitProgressPopupPanelClose(); + waitExpectedMessageOnProgressPanelAndClosed(message, ELEMENT_TIMEOUT_SEC); } /** @@ -120,35 +87,21 @@ public void waitExpectedMessageOnProgressPanelAndClosed(final String message) { * @param timeout timeout defined by user */ public void waitExpectedMessageOnProgressPanelAndClosed(final String message, final int timeout) { - try { - new WebDriverWait(seleniumWebDriver, timeout) - .until( - (ExpectedCondition) - input -> getAllMessagesFromProgressPopupPanel(timeout).contains(message)); - } catch (StaleElementReferenceException ex) { - LOG.debug(ex.getLocalizedMessage(), ex); - WaitUtils.sleepQuietly(500, TimeUnit.MILLISECONDS); - new WebDriverWait(seleniumWebDriver, timeout) - .until(ExpectedConditions.textToBePresentInElement(progressPopupPanel, message)); - } + seleniumWebDriverHelper.waitTextPresence(progressPopupPanel, message, timeout); waitProgressPopupPanelClose(timeout); } /** wait disappearance of notification popups */ public void waitPopupPanelsAreClosed() { - new WebDriverWait(seleniumWebDriver, WIDGET_TIMEOUT_SEC) - .until(ExpectedConditions.invisibilityOfElementLocated(By.id(PROGRESS_POPUP_PANEL_ID))); + seleniumWebDriverHelper.waitInvisibility(progressPopupPanel, WIDGET_TIMEOUT_SEC); } public void waitWorkspaceAgentIsNotRunning() { - new WebDriverWait(seleniumWebDriver, WIDGET_TIMEOUT_SEC) - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(RESTART_WORKSPACE_BUTTON))); + seleniumWebDriverHelper.waitVisibility(By.xpath(RESTART_WORKSPACE_BUTTON), WIDGET_TIMEOUT_SEC); } /** click on the Restart workspace button */ public void clickOnRestartWorkspaceButton() { - new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) - .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(RESTART_WORKSPACE_BUTTON))) - .click(); + seleniumWebDriverHelper.waitAndClick(By.xpath(RESTART_WORKSPACE_BUTTON)); } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java index 1ecd7982cac..ce74cd7f74e 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java @@ -15,14 +15,12 @@ import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.EXPECTED_MESS_IN_CONSOLE_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC; -import static org.openqa.selenium.support.ui.ExpectedConditions.invisibilityOfElementLocated; -import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf; -import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated; 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.core.webdriver.SeleniumWebDriverHelper; import org.openqa.selenium.By; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.TimeoutException; @@ -33,18 +31,17 @@ import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.WebDriverWait; -/** - * // - * - * @author Musienko Maxim - */ +/** @author Musienko Maxim */ @Singleton public class ToastLoader { private final SeleniumWebDriver seleniumWebDriver; + private final SeleniumWebDriverHelper seleniumWebDriverHelper; @Inject - public ToastLoader(SeleniumWebDriver seleniumWebDriver) { + public ToastLoader( + SeleniumWebDriver seleniumWebDriver, SeleniumWebDriverHelper seleniumWebDriverHelper) { this.seleniumWebDriver = seleniumWebDriver; + this.seleniumWebDriverHelper = seleniumWebDriverHelper; PageFactory.initElements(seleniumWebDriver, this); } @@ -63,7 +60,7 @@ private interface Locators { /** wait appearance toast loader widget */ public void waitToastLoaderIsOpen() { - new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC).until(visibilityOf(mainForm)); + seleniumWebDriverHelper.waitVisibility(mainForm, ELEMENT_TIMEOUT_SEC); } /** @@ -72,10 +69,9 @@ public void waitToastLoaderIsOpen() { * @param expText */ public void waitExpectedTextInToastLoader(String expText) { - new WebDriverWait(seleniumWebDriver, EXPECTED_MESS_IN_CONSOLE_SEC) - .until( - visibilityOfElementLocated( - By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER, expText)))); + seleniumWebDriverHelper.waitVisibility( + By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER, expText)), + EXPECTED_MESS_IN_CONSOLE_SEC); } /** @@ -85,16 +81,13 @@ public void waitExpectedTextInToastLoader(String expText) { * @param timeout timeout sets in seconds */ public void waitExpectedTextInToastLoader(String expText, int timeout) { - new WebDriverWait(seleniumWebDriver, timeout) - .until( - visibilityOfElementLocated( - By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER, expText)))); + seleniumWebDriverHelper.waitVisibility( + By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER, expText)), timeout); } /** wait for closing of widget */ public void waitToastLoaderIsClosed() { - new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) - .until(invisibilityOfElementLocated(By.id(Locators.MAIN_FORM))); + waitToastLoaderIsClosed(ELEMENT_TIMEOUT_SEC); } /** @@ -103,8 +96,7 @@ public void waitToastLoaderIsClosed() { * @param userTimeout timeout defined by user */ public void waitToastLoaderIsClosed(int userTimeout) { - new WebDriverWait(seleniumWebDriver, userTimeout) - .until(invisibilityOfElementLocated(By.id(Locators.MAIN_FORM))); + seleniumWebDriverHelper.waitInvisibility(mainForm, userTimeout); } /** wait appearance the 'Toast widget' with some text, and wait disappearance this one */ @@ -188,20 +180,16 @@ public Boolean apply(WebDriver driver) { } public String getTextFromToastLoader() { - return new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) - .until(visibilityOf(mainForm)) - .getText(); + return seleniumWebDriverHelper.waitVisibilityAndGetText(mainForm); } /** wait appearance of start button in the widget */ public void waitStartButtonInToastLoader() { - new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC) - .until(visibilityOf(startBtn)); + seleniumWebDriverHelper.waitVisibility(startBtn); } /** wait appearance of start button in the widget and click on this one */ public void clickOnStartButton() { - waitStartButtonInToastLoader(); - startBtn.click(); + seleniumWebDriverHelper.waitAndClick(startBtn); } } From 79c903e46c1a5bdb09e358a148be64d30ec70edb Mon Sep 17 00:00:00 2001 From: SkorikSergey Date: Thu, 12 Apr 2018 11:37:00 +0300 Subject: [PATCH 2/5] methods for starting ws from ToastLoader moved to ToastLoader page object --- .../pageobject/NotificationsPopupPanel.java | 12 ------ .../che/selenium/pageobject/ToastLoader.java | 42 ++++++++++--------- ...gWorkspaceAfterStoppingWsAgentProcess.java | 12 +++--- .../workspaces/CheckStopStartWsTest.java | 2 +- .../CheckStoppingWsByTimeoutTest.java | 2 +- ...ProjectStateAfterWorkspaceRestartTest.java | 2 +- 6 files changed, 32 insertions(+), 40 deletions(-) diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NotificationsPopupPanel.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NotificationsPopupPanel.java index 229d1035c37..19e6468e0d6 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NotificationsPopupPanel.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NotificationsPopupPanel.java @@ -18,7 +18,6 @@ import com.google.inject.Singleton; import org.eclipse.che.selenium.core.SeleniumWebDriver; import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper; -import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.PageFactory; @@ -42,8 +41,6 @@ public NotificationsPopupPanel( private static final String PROGRESS_POPUP_PANEL_ID = "gwt-debug-popup-container"; private static final String CLOSE_POPUP_IMG_XPATH = "//div[@id='gwt-debug-popup-container']/descendant::*[local-name()='svg'][2]"; - private static final String RESTART_WORKSPACE_BUTTON = - "//div[@id='gwt-debug-popupLoader']//button[text()='Restart']"; @FindBy(id = PROGRESS_POPUP_PANEL_ID) private WebElement progressPopupPanel; @@ -95,13 +92,4 @@ public void waitExpectedMessageOnProgressPanelAndClosed(final String message, fi public void waitPopupPanelsAreClosed() { seleniumWebDriverHelper.waitInvisibility(progressPopupPanel, WIDGET_TIMEOUT_SEC); } - - public void waitWorkspaceAgentIsNotRunning() { - seleniumWebDriverHelper.waitVisibility(By.xpath(RESTART_WORKSPACE_BUTTON), WIDGET_TIMEOUT_SEC); - } - - /** click on the Restart workspace button */ - public void clickOnRestartWorkspaceButton() { - seleniumWebDriverHelper.waitAndClick(By.xpath(RESTART_WORKSPACE_BUTTON)); - } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java index ce74cd7f74e..6fd859e99b3 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java @@ -15,6 +15,8 @@ import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.EXPECTED_MESS_IN_CONSOLE_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC; import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC; +import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.UPDATING_PROJECT_TIMEOUT_SEC; +import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.WIDGET_TIMEOUT_SEC; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -36,31 +38,32 @@ public class ToastLoader { private final SeleniumWebDriver seleniumWebDriver; private final SeleniumWebDriverHelper seleniumWebDriverHelper; + private final Loader loader; @Inject public ToastLoader( - SeleniumWebDriver seleniumWebDriver, SeleniumWebDriverHelper seleniumWebDriverHelper) { + SeleniumWebDriver seleniumWebDriver, + SeleniumWebDriverHelper seleniumWebDriverHelper, + Loader loader) { this.seleniumWebDriver = seleniumWebDriver; this.seleniumWebDriverHelper = seleniumWebDriverHelper; + this.loader = loader; PageFactory.initElements(seleniumWebDriver, this); } private interface Locators { - String MAIN_FORM = "gwt-debug-popupLoader"; - String START_BUTTON = "//button[text()='Start']"; - String MAINFORM_WITH_TEXT_CONTAINER = + String MAIN_FORM_ID = "gwt-debug-popupLoader"; + String TOAST_LOADER_BUTTON_XPATH = "//div[@id='gwt-debug-popupLoader']//button[text()='%s']"; + String MAINFORM_WITH_TEXT_CONTAINER_XPATH = "//div[@id='gwt-debug-popupLoader']/div[contains(text(),'%s')]"; } - @FindBy(id = Locators.MAIN_FORM) + @FindBy(id = Locators.MAIN_FORM_ID) WebElement mainForm; - @FindBy(xpath = Locators.START_BUTTON) - WebElement startBtn; - /** wait appearance toast loader widget */ public void waitToastLoaderIsOpen() { - seleniumWebDriverHelper.waitVisibility(mainForm, ELEMENT_TIMEOUT_SEC); + seleniumWebDriverHelper.waitVisibility(mainForm, UPDATING_PROJECT_TIMEOUT_SEC); } /** @@ -69,9 +72,7 @@ public void waitToastLoaderIsOpen() { * @param expText */ public void waitExpectedTextInToastLoader(String expText) { - seleniumWebDriverHelper.waitVisibility( - By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER, expText)), - EXPECTED_MESS_IN_CONSOLE_SEC); + waitExpectedTextInToastLoader(expText, EXPECTED_MESS_IN_CONSOLE_SEC); } /** @@ -82,7 +83,7 @@ public void waitExpectedTextInToastLoader(String expText) { */ public void waitExpectedTextInToastLoader(String expText, int timeout) { seleniumWebDriverHelper.waitVisibility( - By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER, expText)), timeout); + By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER_XPATH, expText)), timeout); } /** wait for closing of widget */ @@ -183,13 +184,16 @@ public String getTextFromToastLoader() { return seleniumWebDriverHelper.waitVisibilityAndGetText(mainForm); } - /** wait appearance of start button in the widget */ - public void waitStartButtonInToastLoader() { - seleniumWebDriverHelper.waitVisibility(startBtn); + /** wait appearance of button in the widget */ + public void waitToastLoaderButton(String buttonName) { + seleniumWebDriverHelper.waitVisibility( + By.xpath(format(Locators.TOAST_LOADER_BUTTON_XPATH, buttonName)), WIDGET_TIMEOUT_SEC); } - /** wait appearance of start button in the widget and click on this one */ - public void clickOnStartButton() { - seleniumWebDriverHelper.waitAndClick(startBtn); + /** wait appearance of button in the widget and click on this one */ + public void clickOnToastLoaderButton(String buttonName) { + loader.waitOnClosed(); + seleniumWebDriverHelper.waitAndClick( + By.xpath(format(Locators.TOAST_LOADER_BUTTON_XPATH, buttonName))); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java index 32c19d3b029..2d8e973114e 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java @@ -11,6 +11,7 @@ package org.eclipse.che.selenium.miscellaneous; import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.RUNNING; +import static org.eclipse.che.commons.lang.NameGenerator.generate; import static org.eclipse.che.selenium.core.constant.TestCommandsConstants.CUSTOM; import static org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.ContextMenuCommandGoals.COMMON; import static org.eclipse.che.selenium.core.project.ProjectTemplates.MAVEN_SPRING; @@ -18,15 +19,14 @@ import com.google.inject.Inject; import java.net.URL; import java.nio.file.Paths; -import org.eclipse.che.commons.lang.NameGenerator; import org.eclipse.che.selenium.core.client.TestCommandServiceClient; import org.eclipse.che.selenium.core.client.TestProjectServiceClient; import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; import org.eclipse.che.selenium.core.user.TestUser; import org.eclipse.che.selenium.core.workspace.TestWorkspace; import org.eclipse.che.selenium.pageobject.Ide; -import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel; import org.eclipse.che.selenium.pageobject.ProjectExplorer; +import org.eclipse.che.selenium.pageobject.ToastLoader; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -35,7 +35,7 @@ * @author Serhii Skoryk */ public class CheckRestoringWorkspaceAfterStoppingWsAgentProcess { - private static final String PROJECT_NAME = NameGenerator.generate("project", 4); + private static final String PROJECT_NAME = generate("project", 4); private static final String nameCommandForKillWsAgent = "killWsAgent"; private static final String killPIDWSAgentCommand = "kill -9 $(ps ax | grep java | grep ws-agent | grep conf | grep -v grep | awk '{print $1}')"; @@ -47,7 +47,7 @@ public class CheckRestoringWorkspaceAfterStoppingWsAgentProcess { @Inject private TestCommandServiceClient testCommandServiceClient; @Inject private TestProjectServiceClient testProjectServiceClient; @Inject private TestWorkspaceServiceClient testWorkspaceServiceClient; - @Inject private NotificationsPopupPanel notificationsPopupPanel; + @Inject private ToastLoader toastLoader; @BeforeClass public void setUp() throws Exception { @@ -66,8 +66,8 @@ public void checkRestoreWsAgentByApi() throws Exception { projectExplorer.invokeCommandWithContextMenu(COMMON, PROJECT_NAME, nameCommandForKillWsAgent); - notificationsPopupPanel.waitWorkspaceAgentIsNotRunning(); - notificationsPopupPanel.clickOnRestartWorkspaceButton(); + toastLoader.waitToastLoaderIsOpen(); + toastLoader.clickOnToastLoaderButton("Restart"); testWorkspaceServiceClient.waitStatus(workspace.getName(), defaultTestUser.getName(), RUNNING); } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStopStartWsTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStopStartWsTest.java index 69f7b254421..f865ed062a8 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStopStartWsTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStopStartWsTest.java @@ -40,7 +40,7 @@ public void checkStopStartWorkspaceTest() { menu.runCommand(WORKSPACE, STOP_WORKSPACE); toastLoader.waitExpectedTextInToastLoader("Workspace is not running"); - toastLoader.clickOnStartButton(); + toastLoader.clickOnToastLoaderButton("Start"); ide.waitOpenedWorkspaceIsReadyToUse(); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStoppingWsByTimeoutTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStoppingWsByTimeoutTest.java index 94da70b3101..7bef90ffc9a 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStoppingWsByTimeoutTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStoppingWsByTimeoutTest.java @@ -65,7 +65,7 @@ public void checkStoppingByApi() throws Exception { @Test public void checkLoadToasterAfterStopping() { - toastLoader.waitStartButtonInToastLoader(); + toastLoader.waitToastLoaderButton("Start"); } private int getCommonTimeoutInMilliSec() { diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterWorkspaceRestartTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterWorkspaceRestartTest.java index 8cf1e0af6e8..13cb13b20e9 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterWorkspaceRestartTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterWorkspaceRestartTest.java @@ -73,7 +73,7 @@ public void checkProjectAfterStopStartWs() { editor.waitTabIsNotPresent("index.jsp"); projectExplorer.waitDisappearItemByPath(PROJECT_NAME); - toastLoader.clickOnStartButton(); + toastLoader.clickOnToastLoaderButton("Start"); ide.waitOpenedWorkspaceIsReadyToUse(); try { From dfc9613c8962e415b5ffb1c8ded252e741cbf057 Mon Sep 17 00:00:00 2001 From: SkorikSergey Date: Thu, 12 Apr 2018 11:49:50 +0300 Subject: [PATCH 3/5] check ToastLoader messages in CheckRestoringWorkspaceAfterStoppingWsAgentProcess test --- .../CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java index 2d8e973114e..909afc5bbdc 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java @@ -67,7 +67,9 @@ public void checkRestoreWsAgentByApi() throws Exception { projectExplorer.invokeCommandWithContextMenu(COMMON, PROJECT_NAME, nameCommandForKillWsAgent); toastLoader.waitToastLoaderIsOpen(); + toastLoader.waitExpectedTextInToastLoader("Workspace agent is not running"); toastLoader.clickOnToastLoaderButton("Restart"); + toastLoader.waitExpectedTextInToastLoader("Starting workspace runtime..."); testWorkspaceServiceClient.waitStatus(workspace.getName(), defaultTestUser.getName(), RUNNING); } From e8f44c8344c0196c55ea978dc5199c2edd1ffe99 Mon Sep 17 00:00:00 2001 From: SkorikSergey Date: Thu, 12 Apr 2018 11:50:45 +0300 Subject: [PATCH 4/5] CheckRestoringWorkspaceAfterStoppingWsAgentProcess removed to CheckRestoringWorkspaceAfterStoppingWsAgentProcessTest --- ...CheckRestoringWorkspaceAfterStoppingWsAgentProcessTest.java} | 2 +- .../che-selenium-test/src/test/resources/suites/CheSuite.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/{CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java => CheckRestoringWorkspaceAfterStoppingWsAgentProcessTest.java} (98%) diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcessTest.java similarity index 98% rename from selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java rename to selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcessTest.java index 909afc5bbdc..14229be6f61 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcess.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/CheckRestoringWorkspaceAfterStoppingWsAgentProcessTest.java @@ -34,7 +34,7 @@ * @author Musienko Maxim * @author Serhii Skoryk */ -public class CheckRestoringWorkspaceAfterStoppingWsAgentProcess { +public class CheckRestoringWorkspaceAfterStoppingWsAgentProcessTest { private static final String PROJECT_NAME = generate("project", 4); private static final String nameCommandForKillWsAgent = "killWsAgent"; private static final String killPIDWSAgentCommand = diff --git a/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml b/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml index 0701258c32e..9d8e9a383f9 100644 --- a/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml +++ b/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml @@ -141,7 +141,7 @@ - + From 0e259967b6df0583256cae7c1f44a2386981dcb4 Mon Sep 17 00:00:00 2001 From: SkorikSergey Date: Fri, 13 Apr 2018 11:08:01 +0300 Subject: [PATCH 5/5] renamed locators names in ToastLoader page object --- .../eclipse/che/selenium/pageobject/ToastLoader.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java index 6fd859e99b3..bd69fbed87c 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ToastLoader.java @@ -53,8 +53,9 @@ public ToastLoader( private interface Locators { String MAIN_FORM_ID = "gwt-debug-popupLoader"; - String TOAST_LOADER_BUTTON_XPATH = "//div[@id='gwt-debug-popupLoader']//button[text()='%s']"; - String MAINFORM_WITH_TEXT_CONTAINER_XPATH = + String TOAST_LOADER_BUTTON_XPATH_PATTERN = + "//div[@id='gwt-debug-popupLoader']//button[text()='%s']"; + String MAINFORM_WITH_TEXT_CONTAINER_XPATH_PATTERN = "//div[@id='gwt-debug-popupLoader']/div[contains(text(),'%s')]"; } @@ -83,7 +84,7 @@ public void waitExpectedTextInToastLoader(String expText) { */ public void waitExpectedTextInToastLoader(String expText, int timeout) { seleniumWebDriverHelper.waitVisibility( - By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER_XPATH, expText)), timeout); + By.xpath(format(Locators.MAINFORM_WITH_TEXT_CONTAINER_XPATH_PATTERN, expText)), timeout); } /** wait for closing of widget */ @@ -187,13 +188,14 @@ public String getTextFromToastLoader() { /** wait appearance of button in the widget */ public void waitToastLoaderButton(String buttonName) { seleniumWebDriverHelper.waitVisibility( - By.xpath(format(Locators.TOAST_LOADER_BUTTON_XPATH, buttonName)), WIDGET_TIMEOUT_SEC); + By.xpath(format(Locators.TOAST_LOADER_BUTTON_XPATH_PATTERN, buttonName)), + WIDGET_TIMEOUT_SEC); } /** wait appearance of button in the widget and click on this one */ public void clickOnToastLoaderButton(String buttonName) { loader.waitOnClosed(); seleniumWebDriverHelper.waitAndClick( - By.xpath(format(Locators.TOAST_LOADER_BUTTON_XPATH, buttonName))); + By.xpath(format(Locators.TOAST_LOADER_BUTTON_XPATH_PATTERN, buttonName))); } }