Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium: Rework static classes "CommandsEditorType" and "CommandsMacrosLinkType" to enumerations #9256

Merged
merged 6 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ACTIVE_EDITOR_ENTRY_POINT;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ACTIVE_TAB_UNSAVED_FILE_NAME;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators.ORION_ACTIVE_EDITOR_CONTAINER_XPATH;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsLocators.COMMAND_MACROS_FORM;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsLocators.COMMAND_MACROS_INPUT_FIELD;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsLocators.DESCRIPTION_MACROS;
Expand All @@ -29,7 +30,6 @@
import org.eclipse.che.selenium.core.action.ActionsFactory;
import org.eclipse.che.selenium.pageobject.AskForValueDialog;
import org.eclipse.che.selenium.pageobject.CodenvyEditor;
import org.eclipse.che.selenium.pageobject.CodenvyEditor.Locators;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.SeleniumWebDriverHelper;
import org.eclipse.che.selenium.pageobject.TestWebElementRenderChecker;
Expand Down Expand Up @@ -76,22 +76,36 @@ public CommandsEditor(
PageFactory.initElements(seleniumWebDriver, this);
}

public static final class CommandsEditorType {
public static final String COMMAND_LINE_EDITOR =
"(" + Locators.ORION_ACTIVE_EDITOR_CONTAINER_XPATH + ")[1]";
public static final String PREVIEW_URL_EDITOR =
"(" + Locators.ORION_ACTIVE_EDITOR_CONTAINER_XPATH + ")[2]";
public enum CommandsEditorLocator {
COMMAND_LINE_EDITOR("(" + ORION_ACTIVE_EDITOR_CONTAINER_XPATH + ")[1]"),
PREVIEW_URL_EDITOR("(" + ORION_ACTIVE_EDITOR_CONTAINER_XPATH + ")[2]");

private CommandsEditorType() {}
private final String locator;

CommandsEditorLocator(String locator) {
this.locator = locator;
}

public String get() {
return this.locator;
}
}

public static final class CommandsMacrosLinkType {
public static final String EDITOR_MACROS_LINK =
"(" + ACTIVE_EDITOR_ENTRY_POINT + "//a[@id='gwt-debug-link-explore_macros'])[1]";
public static final String PREVIEW_MACROS_LINK =
"(" + ACTIVE_EDITOR_ENTRY_POINT + "//a[@id='gwt-debug-link-explore_macros'])[2]";
public enum CommandsMacrosLinkLocator {
EDITOR_MACROS_LINK(
"(" + ACTIVE_EDITOR_ENTRY_POINT + "//a[@id='gwt-debug-link-explore_macros'])[1]"),
PREVIEW_MACROS_LINK(
"(" + ACTIVE_EDITOR_ENTRY_POINT + "//a[@id='gwt-debug-link-explore_macros'])[2]");

private final String locator;

private CommandsMacrosLinkType() {}
CommandsMacrosLinkLocator(String locator) {
this.locator = locator;
}

public String get() {
return this.locator;
}
}

/** Class introduce Xpath locators for DOM navigation inside Commands Editor widget */
Expand Down Expand Up @@ -390,13 +404,14 @@ public void selectGoalNameIntoCommandEditor(String goalName) {
}

/**
* Clicks on specified {commandsEditorType} in the "Commands Editor".
* Clicks on specified {commandsEditorLocator} in the "Commands Editor".
*
* @param commandsEditorType command editor's type which defined in {@link CommandsEditorType}
* @param commandsEditorLocator command editor's type which defined in {@link
* CommandsEditorLocator}
*/
public void setFocusIntoTypeCommandsEditor(String commandsEditorType) {
public void setFocusIntoTypeCommandsEditor(CommandsEditorLocator commandsEditorLocator) {
seleniumWebDriverHelper.waitAndClick(
By.xpath(commandsEditorType), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
By.xpath(commandsEditorLocator.get()), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
editor.waitActive();
}

Expand All @@ -411,13 +426,14 @@ public void waitTextIntoDescriptionMacrosForm(String expectedText) {
}

/**
* Waits visibility and clicks on "Macros" link with specified {@code macroLinkType} in the
* Waits visibility and clicks on "Macros" link with specified {@code macroLinkLocator} in the
* commands editor.
*
* @param macroLinkType type of the "Macros" link, defined in {@link CommandsMacrosLinkType}
* @param macroLinkLocator type of the "Macros" link, defined in {@link CommandsMacrosLinkLocator}
*/
public void selectMacroLinkInCommandsEditor(String macroLinkType) {
seleniumWebDriverHelper.waitAndClick(By.xpath(macroLinkType), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
public void selectMacroLinkInCommandsEditor(CommandsMacrosLinkLocator macroLinkLocator) {
seleniumWebDriverHelper.waitAndClick(
By.xpath(macroLinkLocator.get()), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
waitCommandMacrosIsOpen();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsDefaultNames.MAVEN_NAME;
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsGoals.BUILD_GOAL;
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsTypes.MAVEN_TYPE;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorType.COMMAND_LINE_EDITOR;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorType.PREVIEW_URL_EDITOR;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorLocator.COMMAND_LINE_EDITOR;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorLocator.PREVIEW_URL_EDITOR;

import com.google.inject.Inject;
import java.net.URL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsDefaultNames.JAVA_NAME;
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsGoals.RUN_GOAL;
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsTypes.JAVA_TYPE;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorType.COMMAND_LINE_EDITOR;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorType.PREVIEW_URL_EDITOR;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsMacrosLinkType.EDITOR_MACROS_LINK;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsMacrosLinkType.PREVIEW_MACROS_LINK;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorLocator.COMMAND_LINE_EDITOR;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorLocator.PREVIEW_URL_EDITOR;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsMacrosLinkLocator.EDITOR_MACROS_LINK;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsMacrosLinkLocator.PREVIEW_MACROS_LINK;

import com.google.inject.Inject;
import java.net.URL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsDefaultNames.MAVEN_NAME;
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsGoals.COMMON_GOAL;
import static org.eclipse.che.selenium.core.constant.TestIntelligentCommandsConstants.CommandsTypes.MAVEN_TYPE;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorType.PREVIEW_URL_EDITOR;
import static org.eclipse.che.selenium.pageobject.intelligent.CommandsEditor.CommandsEditorLocator.PREVIEW_URL_EDITOR;

import com.google.inject.Inject;
import java.net.URL;
Expand Down