Skip to content

Commit

Permalink
Selenium: Add try/catch block for displaying "Known issue" with #8300
Browse files Browse the repository at this point in the history
…bug (#8454)
  • Loading branch information
Ohrimenko1988 authored Jan 25, 2018
1 parent d5e0649 commit fc3a7b9
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1454,14 +1454,23 @@ public void waitSpecifiedValueForLineAndChar(String lineAndChar) {
By.xpath(String.format(Locators.POSITION_CURSOR_NUMBER, lineAndChar))));
}

/** launch the 'Refactor' form by keyboard */
public void launchRefactorFormFromEditor() {
/** launch refactor for local variables by keyboard */
public void launchLocalRefactor() {
loader.waitOnClosed();
Actions action = actionsFactory.createAction(seleniumWebDriver);
action.keyDown(Keys.SHIFT).sendKeys(Keys.F6).keyUp(Keys.SHIFT).perform();
loader.waitOnClosed();
}

/**
* the first invocation of launchLocalRefactor() runs local refactoring, the second invocation
* opens "Refactor" form
*/
public void launchRefactorForm() {
launchLocalRefactor();
launchLocalRefactor();
}

/**
* click on the selected element in the editor
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
package org.eclipse.che.selenium.pageobject;

import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.UPDATING_PROJECT_TIMEOUT_SEC;
import static org.testng.Assert.fail;

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.openqa.selenium.By;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
Expand Down Expand Up @@ -51,7 +53,12 @@ private interface Locators {
public void waitOnClosed() {
// in this pace pause, because loader can appear not at once
WaitUtils.sleepQuietly(1);
new WebDriverWait(seleniumWebDriver, UPDATING_PROJECT_TIMEOUT_SEC)
.until(ExpectedConditions.invisibilityOfElementLocated(By.id(Locators.LOADER_ID)));
try {
new WebDriverWait(seleniumWebDriver, UPDATING_PROJECT_TIMEOUT_SEC)
.until(ExpectedConditions.invisibilityOfElementLocated(By.id(Locators.LOADER_ID)));
} catch (TimeoutException ex) {
// remove try-catch block after issue has been resolved
fail("Known issue https://github.com/eclipse/che/issues/8300", ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public void runCommand(final String idTopMenuCommand, final String idCommandName
}
redrawMenuItemsWait.until(
ExpectedConditions.invisibilityOfElementLocated(By.id(idCommandName)));
loader.waitOnClosed();
}

/**
Expand Down Expand Up @@ -172,6 +173,8 @@ public void runCommand(String idTopMenuCommand, String idCommandName, String idS
seleniumWebDriver.findElement(By.id(idSubCommandName)).click();
redrawMenuItemsWait.until(
ExpectedConditions.invisibilityOfElementLocated(By.id(idCommandName)));

loader.waitOnClosed();
}

/**
Expand Down Expand Up @@ -212,6 +215,8 @@ public void runCommandByXpath(
seleniumWebDriver.findElement(By.xpath(xpathSubCommandName)).click();
redrawMenuItemsWait.until(
ExpectedConditions.invisibilityOfElementLocated(By.id(idCommandName)));

loader.waitOnClosed();
}

/**
Expand Down Expand Up @@ -245,6 +250,8 @@ public void runCommandByXpath(String command) {
ExpectedConditions.visibilityOfElementLocated(
By.xpath(String.format(Locators.ENABLED_ITEM, command))))
.click();

loader.waitOnClosed();
}

/** wait a command is not present in the menu */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public void testFail0() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -104,8 +103,7 @@ public void testFail3() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -124,8 +122,7 @@ public void testFail7() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -145,8 +142,7 @@ public void testFail10() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -166,8 +162,7 @@ public void testFail14() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public void testFail0() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -105,8 +104,7 @@ public void testFail4() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -125,8 +123,7 @@ public void testFail6() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -147,8 +144,7 @@ public void testFail7() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void checkRenameNotPrivateField0() throws Exception {
editor.setCursorToLine(21);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -98,7 +98,7 @@ public void checkRenameNotPrivateField1() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -114,7 +114,7 @@ public void checkRenameNotPrivateField2() throws Exception {
editor.waitActive();
editor.waitTextIntoEditor(contentFromInA);
editor.goToCursorPositionVisible(13, 9);
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -132,7 +132,7 @@ public void checkRenameNotPrivateField3() throws Exception {
editor.setCursorToLine(19);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -153,7 +153,7 @@ public void checkRenameNotPrivateField4() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -174,7 +174,7 @@ public void checkRenameNotPrivateField5() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -195,7 +195,7 @@ public void checkRenameNotPrivateField6() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -217,8 +217,7 @@ public void checkRenameNotPrivateField7() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -242,8 +241,7 @@ public void checkRenameNotPrivateField8() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand All @@ -267,7 +265,7 @@ public void checkRenameNotPrivateField9() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -285,7 +283,7 @@ public void checkRenameNotPrivateField10() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -301,7 +299,7 @@ public void checkRenameAnnotation24() throws Exception {
editor.waitActive();
editor.waitTextIntoEditor(contentFromInA);
editor.goToCursorPositionVisible(14, 9);
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("ZORRO");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -318,7 +316,7 @@ public void checkRenameAnnotation25() throws Exception {
editor.waitActive();
editor.waitTextIntoEditor(contentFromInA);
editor.goToCursorPositionVisible(16, 14);
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("ZORRO");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -334,7 +332,7 @@ public void checkBugFiveEightTwoOne26() throws Exception {
editor.waitActive();
editor.waitTextIntoEditor(contentFromInA);
editor.goToCursorPositionVisible(13, 17);
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("test1");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -352,7 +350,7 @@ public void checkRenameDelegate28() throws Exception {
editor.setCursorToLine(15);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -373,7 +371,7 @@ public void checkRenameEnumField31() throws Exception {
editor.setCursorToLine(15);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("other");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -394,7 +392,7 @@ public void checkRenameGenerics32() throws Exception {
editor.setCursorToLine(14);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -415,7 +413,7 @@ public void checkRenameGenerics33() throws Exception {
editor.setCursorToLine(14);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand All @@ -436,7 +434,7 @@ public void checkRenameGenerics36() throws Exception {
editor.setCursorToLine(16);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchLocalRefactor();
editor.typeTextIntoEditor("g");
loader.waitOnClosed();
editor.typeTextIntoEditor(Keys.ENTER.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ public void checkRenamePrivateField0() throws Exception {
editor.setCursorToLine(13);
editor.typeTextIntoEditor(Keys.END.toString());
editor.typeTextIntoEditor(Keys.ARROW_LEFT.toString());
editor.launchRefactorFormFromEditor();
editor.launchRefactorFormFromEditor();
editor.launchRefactorForm();
refactor.waitRenameFieldFormIsOpen();
refactor.waitUpdateReferencesIsSelected();
refactor.typeAndWaitNewName("g");
Expand Down
Loading

0 comments on commit fc3a7b9

Please sign in to comment.