rework the tests according to latest changes in the UI of the IDE (#7000)

6.19.x
Maxim Musienko 2017-10-26 17:52:36 +03:00 committed by GitHub
parent e9627eba3d
commit 299059c1f8
5 changed files with 41 additions and 39 deletions

View File

@ -10,8 +10,10 @@
*/
package org.eclipse.che.selenium.pageobject;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ATTACHING_ELEM_TO_DOM_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_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 com.google.inject.Inject;
import com.google.inject.Singleton;
@ -92,8 +94,9 @@ public class AskDialog {
* @param expectedText expected text in widget
*/
public void containsText(final String expectedText) {
new WebDriverWait(seleniumWebDriver, 3).until(ExpectedConditions.visibilityOf(warning_Text));
new WebDriverWait(seleniumWebDriver, 7)
new WebDriverWait(seleniumWebDriver, ATTACHING_ELEM_TO_DOM_SEC)
.until(ExpectedConditions.visibilityOf(warning_Text));
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
(ExpectedCondition<Boolean>)
webDriver -> warning_Text.getText().contains(expectedText));

View File

@ -10,10 +10,14 @@
*/
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.LOAD_PAGE_TIMEOUT_SEC;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
@ -43,20 +47,29 @@ public class WarningDialog {
/** wait closing a warning dialog */
public void waitWaitClosingWarnDialogWindow() {
new WebDriverWait(seleniumWebDriver, 10)
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(ExpectedConditions.invisibilityOfElementLocated(By.id(Locators.WARNING_DIALOG_ID)));
}
/** wait ok btn, click it and wait closing of the form */
public void clickOkBtn() {
new WebDriverWait(seleniumWebDriver, 10).until(ExpectedConditions.visibilityOf(okBtn));
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(ExpectedConditions.visibilityOf(okBtn));
okBtn.click();
waitWaitClosingWarnDialogWindow();
}
/** wait appearance a warning dialog */
public void waitWaitWarnDialogWindowWithSpecifiedTextMess(String mess) {
new WebDriverWait(seleniumWebDriver, 15)
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(ExpectedConditions.textToBePresentInElement(warningDialog, mess));
}
public boolean isPresent() {
try {
return warningDialog.isDisplayed();
} catch (NoSuchElementException e) {
return false;
}
}
}

View File

@ -11,8 +11,6 @@
package org.eclipse.che.selenium.factory;
import static org.eclipse.che.dto.server.DtoFactory.newDto;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.PREPARING_WS_TIMEOUT_SEC;
import static org.testng.Assert.assertTrue;
import com.google.inject.Inject;
import org.eclipse.che.api.factory.shared.dto.PoliciesDto;
@ -25,9 +23,8 @@ import org.eclipse.che.selenium.core.utils.WaitUtils;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.PopupDialogsBrowser;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.WarningDialog;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -35,8 +32,8 @@ import org.testng.annotations.Test;
/** @author Mihail Kuznyetsov */
public class CheckFactoryWithSincePolicyTest {
private static final String FACTORY_NAME = NameGenerator.generate("sincePolicy", 3);
private static final String ALERT_EXPIRE_MESSAGE =
"Error: This Factory is not yet valid due to time restrictions applied"
private static final String EXPIRE_MESSAGE =
"Unable to load Factory: This Factory is not yet valid due to time restrictions applied"
+ " by its owner. Please, contact owner for more information.";
private static final long INIT_TIME = System.currentTimeMillis();
private static final int ADDITIONAL_TIME = 60000;
@ -47,7 +44,7 @@ public class CheckFactoryWithSincePolicyTest {
@Inject private PopupDialogsBrowser popupDialogsBrowser;
@Inject private Dashboard dashboard;
@Inject private SeleniumWebDriver seleniumWebDriver;
@Inject private WarningDialog warningDialog;
private TestFactory testFactory;
@BeforeClass
@ -69,15 +66,9 @@ public class CheckFactoryWithSincePolicyTest {
public void checkFactoryAcceptingWithSincePolicy() throws Exception {
// check factory now, make sure its restricted
dashboard.open();
testFactory.open(ide.driver());
// driver.get(factoryUrl);
new WebDriverWait(ide.driver(), PREPARING_WS_TIMEOUT_SEC)
.until(ExpectedConditions.alertIsPresent());
assertTrue(
ide.driver().switchTo().alert().getText().contains(ALERT_EXPIRE_MESSAGE),
"actual message: " + ide.driver().switchTo().alert().getText());
popupDialogsBrowser.acceptAlert();
testFactory.open(seleniumWebDriver);
seleniumWebDriver.switchFromDashboardIframeToIde();
warningDialog.waitWaitWarnDialogWindowWithSpecifiedTextMess(EXPIRE_MESSAGE);
// wait until factory becomes avaialble
while (System.currentTimeMillis() <= INIT_TIME + ADDITIONAL_TIME) {
@ -85,8 +76,9 @@ public class CheckFactoryWithSincePolicyTest {
}
// check again
testFactory.open(ide.driver());
testFactory.open(seleniumWebDriver);
seleniumWebDriver.switchFromDashboardIframeToIde();
projectExplorer.waitProjectExplorer();
warningDialog.waitWaitClosingWarnDialogWindow();
}
}

View File

@ -11,8 +11,6 @@
package org.eclipse.che.selenium.factory;
import static org.eclipse.che.dto.server.DtoFactory.newDto;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.PREPARING_WS_TIMEOUT_SEC;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import com.google.inject.Inject;
@ -25,9 +23,8 @@ import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
import org.eclipse.che.selenium.core.utils.WaitUtils;
import org.eclipse.che.selenium.pageobject.PopupDialogsBrowser;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.WarningDialog;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -35,8 +32,8 @@ import org.testng.annotations.Test;
/** @author Mihail Kuznyetsov */
public class CheckFactoryWithUntilPolicyTest {
private static final String FACTORY_NAME = NameGenerator.generate("untilPolicy", 3);
private static final String ALERT_EXPIRE_MESSAGE =
"Error: This Factory has expired due to time restrictions applied by its owner. Please, contact owner for more information.";
private static final String EXPIRE_MESSAGE =
"Unable to load Factory: This Factory has expired due to time restrictions applied by its owner. Please, contact owner for more information.";
private static final long INIT_TIME = System.currentTimeMillis();
private static final int ADDITIONAL_TIME = 60000;
@ -45,7 +42,7 @@ public class CheckFactoryWithUntilPolicyTest {
@Inject private PopupDialogsBrowser popupDialogsBrowser;
@Inject private Dashboard dashboard;
@Inject private SeleniumWebDriver seleniumWebDriver;
@Inject private WarningDialog warningDialog;
private TestFactory testFactory;
@BeforeClass
@ -65,13 +62,16 @@ public class CheckFactoryWithUntilPolicyTest {
@Test
public void checkFactoryAcceptingWithUntilPolicy() throws Exception {
testFactory.open(seleniumWebDriver);
seleniumWebDriver.switchFromDashboardIframeToIde();
// first
dashboard.open();
testFactory.open(seleniumWebDriver);
seleniumWebDriver.switchFromDashboardIframeToIde();
projectExplorer.waitProjectExplorer();
while (System.currentTimeMillis() <= INIT_TIME + ADDITIONAL_TIME) {
if (popupDialogsBrowser.isAlertPresent()) {
if (warningDialog.isPresent()) {
popupDialogsBrowser.acceptAlert();
fail("Factory expired before the until period");
}
@ -80,11 +80,7 @@ public class CheckFactoryWithUntilPolicyTest {
// second
testFactory.open(seleniumWebDriver);
new WebDriverWait(seleniumWebDriver, PREPARING_WS_TIMEOUT_SEC)
.until(ExpectedConditions.alertIsPresent());
assertTrue(
seleniumWebDriver.switchTo().alert().getText().contains(ALERT_EXPIRE_MESSAGE),
"actual message: " + seleniumWebDriver.switchTo().alert().getText());
popupDialogsBrowser.acceptAlert();
seleniumWebDriver.switchFromDashboardIframeToIde();
warningDialog.waitWaitWarnDialogWindowWithSpecifiedTextMess(EXPIRE_MESSAGE);
}
}

View File

@ -81,10 +81,8 @@ public class CheckOpenFileFeatureTest {
dashboardFactory.selectAction(OPEN_FILE);
dashboardFactory.enterParamValue(OPEN_FILE_URL);
dashboardFactory.clickAddOnAddAction();
dashboard.waitNotificationIsOpen();
dashboard.waitNotificationIsClosed();
dashboardFactory.clickOnOpenFactory();
String currentWin = ide.driver().getWindowHandle();
String currentWin = seleniumWebDriver.getWindowHandle();
seleniumWebDriver.switchToNoneCurrentWindow(currentWin);
loadingBehaviorPage.waitWhileLoadPageIsClosed();
seleniumWebDriver.switchFromDashboardIframeToIde();