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: apply changes for selenium tests from Che6 branch to master #7870

Merged
merged 11 commits into from
Dec 14, 2017
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,14 @@ public void waitTabIsPresent(String nameOfFile) {
loader.waitOnClosed();
}

public String getAssociatedPathFromTheTab(String nameOfOpenedFile) {
return redrawDriverWait
.until(
ExpectedConditions.visibilityOfElementLocated(
By.xpath(String.format(Locators.TAB_FILE_NAME_XPATH, nameOfOpenedFile))))
.getAttribute("path");
}

/**
* wait tab with expected name is present
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public void selectFileByFullName(String pathName) {
By.xpath(format(Locators.FILE_NAME_LIST_SELECT_WITH_PATH, pathName))))
.click();
actionsFactory.createAction(seleniumWebDriver).doubleClick().perform();
waitFormToClose();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
*/
package org.eclipse.che.selenium.pageobject;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.MINIMUM_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC;

import com.google.inject.Inject;
Expand All @@ -27,17 +30,25 @@
import org.eclipse.che.selenium.core.utils.WaitUtils;
import org.everrest.core.impl.provider.json.JsonValue;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
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.FluentWait;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** @author Andrey Chizhikov */
@Singleton
public class Swagger {

private final SeleniumWebDriver seleniumWebDriver;
private static final Logger LOG = LoggerFactory.getLogger(SeleniumWebDriver.class);

@Inject
public Swagger(SeleniumWebDriver seleniumWebDriver) {
Expand Down Expand Up @@ -67,9 +78,13 @@ private interface Locators {

/** expand 'workspace' item */
private void expandWorkSpaceItem() {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(ExpectedConditions.elementToBeClickable(workSpaceLink))
.click();
Wait fluentWait =
new FluentWait(seleniumWebDriver)
.withTimeout(LOAD_PAGE_TIMEOUT_SEC, SECONDS)
.pollingEvery(MINIMUM_SEC, SECONDS)
.ignoring(StaleElementReferenceException.class, NoSuchElementException.class);
fluentWait.until((ExpectedCondition<Boolean>) input -> workSpaceLink.isEnabled());
workSpaceLink.click();
}

/** collapse 'workspace' item */
Expand Down Expand Up @@ -112,12 +127,27 @@ public List<String> getWsNamesFromWorkspacePage() {
expandWorkSpaceItem();
clickElementByXpath(Locators.GET_WORKSPACES);
clickTryItOutByXpath(Locators.TRY_IT_OUT);
String json =
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(Locators.RESPONSE_BODY)))
.getText();
List<WorkspaceDto> workspaces =
DtoFactory.getInstance().createListDtoFromJson(json, WorkspaceDto.class);
List<WorkspaceDto> workspaces = new ArrayList<WorkspaceDto>();
// Sometimes when we get text from swagger page the JSON may be in rendering state. In this case
// we get invalid data.
// In this loop we perform 2 attempts with 500 msec. delay for getting correct data after full
// rendering page.
for (int i = 0; i < 2; i++) {
try {
workspaces =
DtoFactory.getInstance()
.createListDtoFromJson(
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(
ExpectedConditions.visibilityOfElementLocated(
By.xpath(Locators.RESPONSE_BODY)))
.getText(),
WorkspaceDto.class);
break;
} catch (RuntimeException ex) {
WaitUtils.sleepQuietly(500, MILLISECONDS);
}
}
return workspaces
.stream()
.map(workspaceDto -> workspaceDto.getConfig().getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,31 @@

/** @author Musienko Maxim */
public class CheckFindActionFeatureInCheTest {
private static final String FIRST_ACTION_NAME = "con";
private static final String SECOND_ACTION_NAME = "comm";
private static final String FIRST_ACTION_NAME = "configu";
private static final String SECOND_ACTION_NAME = "commands";
private static final String THIRD_ACTION_NAME = "che";

private static final String FIRST_ACTION_NAME_EXPECTED_ARRAY_LOCAL_MODE =
"Configuration... Project\n"
private static final String FIRST_EXPECTED_ITEMS_WITH_DISABLED_NONE_MENU_ACTIONS_CHECKBOX =
"Update Project Configuration... Project\n"
+ "Configure Classpath Project\n"
+ "Content Assist Assistant\n"
+ "Convert To Project Project\n"
+ "Edit Debug Configurations... [Alt+Shift+F9] Run";

private static final String SECOND_ACTION_NAME_EXPECTED_ARRAY_LOCAL_MODE =
"Commands Palette [Shift+F10] Run\n"
+ "Commit ... [Alt+C] GitCommandGroup\n"
+ "Commit... SvnFileCommandGroup\n"
+ "Community Help\n"
+ "Revert commit... GitCommandGroup\n"
+ "SvnCredentialsCommandGroup Subversion";
private static final String SECOND_EXPECTED_ITEMS_WITH_DISABLED_NONE_MENU_ACTIONS_CHECKBOX =
"Commands Palette [Shift+F10] Run";

private static final String THIRD_ACTION_NAME_EXPECTED_ARRAY_LOCAL_MODE =
private static final String THIRD_EXPECTED_ITEMS_WITH_DISABLED_NONE_MENU_ACTIONS_CHECKBOX =
"Branches... [Ctrl+B] GitCommandGroup\n" + "Checkout Reference... GitCommandGroup";

private static final String FIRST_ACTION_NAME_EXPECTED_ARRAY_WITH_FLAG_LOCAL_MODE =
"Update Project Configuration... Project\n"
private static final String FIRST_EXPECTED_ITEMS_WITH_ENABLED_NONE_MENU_ACTIONS_CHECKBOX =
"Configuration \n"
+ "Update Project Configuration... Project\n"
+ "Configure Classpath Project\n"
+ "Content Assist Assistant\n"
+ "Convert To Project Project\n"
+ "Edit Debug Configurations... [Alt+Shift+F9] Run\n"
+ "Import From Codenvy Config... Project\n"
+ "consolesTreeContextMenu \n"
+ "debugGroupContextMenu \n"
+ "editorTabContextMenu \n"
+ "mainContextMenu \n"
+ "projectExplorerContextMenu \n"
+ "runGroupContextMenu ";

private static final String SECOND_ACTION_NAME_EXPECTED_ARRAY_WITH_FLAG_LOCAL_MODE =
"Commands \n"
+ "Commands Palette [Shift+F10] Run\n"
+ "Commit ... [Alt+C] GitCommandGroup\n"
+ "Commit... SvnFileCommandGroup\n"
+ "Community Help\n"
+ "Execute default command of Debug goal [Alt+D] \n"
+ "Execute default command of Run goal [Alt+R] \n"
+ "GitCommandGroup \n"
+ "Revert commit... GitCommandGroup\n"
+ "SvnAddCommandGroup \n"
+ "SvnCredentialsCommandGroup Subversion\n"
+ "SvnFileCommandGroup \n"
+ "SvnMiscellaneousCommandGroup \n"
+ "SvnRemoteCommandGroup \n"
+ "SvnRepositoryCommandGroup ";

private static final String THIRD_ACTION_NAME_EXPECTED_ARRAY_WITH_FLAG_LOCAL_MODE =
+ "breakpointConfiguration ";

private static final String SECOND_EXPECTED_ITEMS_WITH_ENABLED_NONE_MENU_ACTIONS_CHECKBOX =
"Commands \n" + "Commands Palette [Shift+F10] Run";
private static final String THIRD_EXPECTED_ITEMS_WITH_ENABLED_NONE_MENU_ACTIONS_CHECKBOX =
"Branches... [Ctrl+B] GitCommandGroup\n" + "Checkout Reference... GitCommandGroup";

private static final String PROJECT_NAME =
Expand All @@ -96,10 +67,7 @@ public class CheckFindActionFeatureInCheTest {

@BeforeClass
public void setUp() throws Exception {
URL resource =
CheckFindActionFeatureInCheTest.this
.getClass()
.getResource("/projects/default-spring-project");
URL resource = this.getClass().getResource("/projects/default-spring-project");
testProjectServiceClient.importProject(
testWorkspace.getId(),
Paths.get(resource.toURI()),
Expand All @@ -118,6 +86,7 @@ public void setUp() throws Exception {

@Test(dataProvider = "checkingDataAllActionsData")
public void checkSearchActionsForAllItemsTest(String actionName, String result) {
findAction.setCheckBoxInSelectedPosition();
checkAction(actionName, result);
}

Expand All @@ -130,18 +99,18 @@ public void checkSearchActionsForMenuItemsTest(String actionName, String result)
@DataProvider
private Object[][] checkingDataWithMenuActionsOnly() {
return new Object[][] {
{FIRST_ACTION_NAME, FIRST_ACTION_NAME_EXPECTED_ARRAY_LOCAL_MODE},
{SECOND_ACTION_NAME, SECOND_ACTION_NAME_EXPECTED_ARRAY_LOCAL_MODE},
{THIRD_ACTION_NAME, THIRD_ACTION_NAME_EXPECTED_ARRAY_LOCAL_MODE}
{FIRST_ACTION_NAME, FIRST_EXPECTED_ITEMS_WITH_DISABLED_NONE_MENU_ACTIONS_CHECKBOX},
{SECOND_ACTION_NAME, SECOND_EXPECTED_ITEMS_WITH_DISABLED_NONE_MENU_ACTIONS_CHECKBOX},
{THIRD_ACTION_NAME, THIRD_EXPECTED_ITEMS_WITH_DISABLED_NONE_MENU_ACTIONS_CHECKBOX}
};
}

@DataProvider
private Object[][] checkingDataAllActionsData() {
return new Object[][] {
{FIRST_ACTION_NAME, FIRST_ACTION_NAME_EXPECTED_ARRAY_WITH_FLAG_LOCAL_MODE},
{SECOND_ACTION_NAME, SECOND_ACTION_NAME_EXPECTED_ARRAY_WITH_FLAG_LOCAL_MODE},
{THIRD_ACTION_NAME, THIRD_ACTION_NAME_EXPECTED_ARRAY_WITH_FLAG_LOCAL_MODE}
{FIRST_ACTION_NAME, FIRST_EXPECTED_ITEMS_WITH_ENABLED_NONE_MENU_ACTIONS_CHECKBOX},
{SECOND_ACTION_NAME, SECOND_EXPECTED_ITEMS_WITH_ENABLED_NONE_MENU_ACTIONS_CHECKBOX},
{THIRD_ACTION_NAME, THIRD_EXPECTED_ITEMS_WITH_ENABLED_NONE_MENU_ACTIONS_CHECKBOX}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
import org.eclipse.che.selenium.core.constant.TestStacksConstants;
import org.eclipse.che.selenium.core.user.TestUser;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.MavenPluginStatusBar;
import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.dashboard.CreateWorkspace;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.NavigationBar;
import org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceProjects;
Expand All @@ -45,7 +43,6 @@ public class CreateAndDeleteProjectsTest {
@Inject private Dashboard dashboard;
@Inject private WorkspaceProjects workspaceProjects;
@Inject private WorkspaceDetails workspaceDetails;
@Inject private NavigationBar navigationBar;
@Inject private CreateWorkspace createWorkspace;
@Inject private ProjectSourcePage projectSourcePage;
@Inject private Loader loader;
Expand All @@ -54,7 +51,6 @@ public class CreateAndDeleteProjectsTest {
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestUser defaultTestUser;
@Inject private NotificationsPopupPanel notificationsPopupPanel;
@Inject private MavenPluginStatusBar mavenPluginStatusBar;
@Inject private Workspaces workspaces;

@BeforeClass
Expand Down Expand Up @@ -88,7 +84,6 @@ public void createAndDeleteProjectTest() throws ExecutionException, InterruptedE
explorer.waitProjectExplorer();
explorer.waitItem(CONSOLE_JAVA_SIMPLE);
notificationsPopupPanel.waitPopUpPanelsIsClosed();
mavenPluginStatusBar.waitClosingInfoPanel();
explorer.waitFolderDefinedTypeOfFolderByPath(CONSOLE_JAVA_SIMPLE, PROJECT_FOLDER);
explorer.waitFolderDefinedTypeOfFolderByPath(WEB_JAVA_SPRING, PROJECT_FOLDER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,35 +121,6 @@ public void stopDebug() {
}

@Test
public void shouldDebugJreClass() {
// when
editor.setInactiveBreakpoint(19);
menu.runCommandByXpath(
TestMenuCommandsConstants.Run.RUN_MENU,
TestMenuCommandsConstants.Run.DEBUG,
debugConfig.getXpathToІRunDebugCommand(PROJECT));

notifications.waitExpectedMessageOnProgressPanelAndClosed("Remote debugger connected");
editor.waitActiveBreakpoint(19);
debugPanel.clickOnButton(DebugPanel.DebuggerActionButtons.STEP_INTO);

// then
editor.waitActiveTabFileName("Logger"); // there should be class "Logger" opened
debugPanel.waitDebugHighlightedText(
" "); // we can't rely on concrete code of external library which can be changed in
// future
debugPanel.waitTextInVariablesPanel(
"=\"Info from java logger\""); // there should be at least parameter with value "Info from
// java logger"

// when
debugPanel.clickOnButton(DebugPanel.DebuggerActionButtons.RESUME_BTN_ID);

// then
editor.waitActiveTabFileName("SimpleLogger");
}

@Test(priority = 1)
public void shouldDebugMavenArtifactClassWithSources() {
// when
editor.setInactiveBreakpoint(23);
Expand Down Expand Up @@ -189,7 +160,7 @@ public void shouldDebugMavenArtifactClassWithSources() {
" org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(SimpleLogger.class);");
}

@Test(priority = 2)
@Test(priority = 1)
public void shouldHandleDebugOfMavenArtifactWithoutSources() {
// when
editor.setInactiveBreakpoint(27);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public void shouldDebugMethodLocalInnerClass() {

// then
editor.waitActiveBreakpoint(53);
debugPanel.waitTextInVariablesPanel("methodValue=\"App method local inner test\"");
}

@Test(priority = 2)
Expand Down
Loading