Skip to content

Commit

Permalink
Restore some code that git automerge lost
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder committed Aug 29, 2018
1 parent 8c3078d commit 9d7bee0
Showing 1 changed file with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import com.google.inject.Singleton;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
import org.eclipse.che.commons.lang.Pair;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.action.ActionsFactory;
Expand Down Expand Up @@ -376,25 +377,35 @@ public String getTextFromSplitEditor(int indexOfEditor) {
return getTextFromOrionLines(inner);
}

/**
* Waits during {@code timeout} until specified {@code expectedText} is present in editor.
*
* @param expectedText text which should be present in the editor
* @param timeout waiting time in seconds
*/
public void waitTextIntoEditor(final String expectedText, final int timeout) {
private void waitForText(String expectedText, int timeout, Supplier<String> textProvider) {
String[] result = new String[1];
webDriverWaitFactory
.get(timeout)
.withMessage(() -> "Timeout waiting for txt, actual='" + result[0] + "'")
.withMessage(
() ->
"Timeout waiting for txt, expected= '"
+ expectedText
+ "', actual='"
+ result[0]
+ "'")
.until(
(ExpectedCondition<Boolean>)
driver -> {
result[0] = getVisibleTextFromEditor();
result[0] = textProvider.get();
return result[0].contains(expectedText);
});
}

/**
* Waits during {@code timeout} until specified {@code expectedText} is present in editor.
*
* @param expectedText text which should be present in the editor
* @param timeout waiting time in seconds
*/
public void waitTextIntoEditor(final String expectedText, final int timeout) {
waitForText(expectedText, timeout, () -> getVisibleTextFromEditor());
}

/**
* Waits until specified {@code expectedText} is present in editor.
*
Expand All @@ -414,11 +425,7 @@ public void waitTextIntoEditor(final String expectedText) {
*/
public void waitTextInDefinedSplitEditor(
int indexOfEditor, final int timeout, String expectedText) {
webDriverWaitFactory
.get(timeout)
.until(
(ExpectedCondition<Boolean>)
driver -> getTextFromSplitEditor(indexOfEditor).contains(expectedText));
waitForText(expectedText, timeout, () -> getTextFromSplitEditor(indexOfEditor));
}

/**
Expand Down Expand Up @@ -580,9 +587,7 @@ public void runActionForTabFromContextMenu(TabActionLocator tabAction) {
* @param text text which should be typed
*/
public void typeTextIntoEditor(String text) {
loader.waitOnClosed();
seleniumWebDriverHelper.sendKeys(text);
loader.waitOnClosed();
}

/**
Expand Down Expand Up @@ -676,7 +681,6 @@ public void launchAutocompleteAndWaitContainer() {

/** Launches code assistant by "ctrl" + "space" keys pressing. */
public void launchAutocomplete() {
loader.waitOnClosed();
Actions action = actionsFactory.createAction(seleniumWebDriver);
action.keyDown(CONTROL).perform();
typeTextIntoEditor(SPACE.toString());
Expand Down Expand Up @@ -923,7 +927,7 @@ public void selectItemIntoAutocompleteAndPerformDoubleClick(String item) {
*/
public void selectAutocompleteProposal(String item) {
seleniumWebDriverHelper.waitAndClick(
By.xpath(format(AUTOCOMPLETE_CONTAINER + "/li/span[text()='%s']", item)));
By.xpath(format(AUTOCOMPLETE_CONTAINER + "/li/span[.='%s']", item)));
}

/**
Expand Down Expand Up @@ -2093,8 +2097,19 @@ public void moveCursorToText(String text) {
By.xpath(format(Locators.TEXT_TO_MOVE_CURSOR_XPATH, text)));
}

public void checkProposalDocumentation(String expectedText) {
seleniumWebDriverHelper.waitTextContains(proposalDoc, expectedText);
public void waitProposalDocumentationHTML(String expectedText, int timeout) {
waitForText(expectedText, timeout, () -> getProposalDocumentationHTML());
}

public void waitProposalDocumentationHTML(String expectedText) {
waitProposalDocumentationHTML(expectedText, LOAD_PAGE_TIMEOUT_SEC);
}

public String getProposalDocumentationHTML() {
return seleniumWebDriverHelper
.waitVisibility(proposalDoc)
.findElement(By.tagName("div"))
.getAttribute("innerHTML");
}

public void launchCommentCodeFeature() {
Expand Down

0 comments on commit 9d7bee0

Please sign in to comment.