Skip to content

Commit

Permalink
Selenium: Correct some selenium tests to increase reliability (#12275)
Browse files Browse the repository at this point in the history
* Correct some selenium test to increase reliability when run on CI
  • Loading branch information
artaleks9 authored Dec 26, 2018
1 parent c578446 commit c6972d4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public void addFilesTest() {
loader.waitOnClosed();

// Check status and add to index all files
projectExplorer.waitAndSelectItem(PROJECT_NAME);
menu.runCommand(TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.STATUS);
git.waitGitStatusBarWithMess(STATUS_MESSAGE_AFTER_EDIT);
projectExplorer.waitAndSelectItem(PROJECT_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
@Test(groups = TestGroup.GITHUB)
public class AmendCommitTest {
private static final String PROJECT_NAME = NameGenerator.generate("AmendCommit_", 4);
private static final String PATH_TO_FILE =
PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java";
private static final String JAVA_FILE_TAB_NAME = "AppController";
private static final String CHANGE_CONTENT = "<!--change content-->";
private static final String COMMIT_MESSAGE = "first commit";
private static final String NOTHING_TO_COMMIT =
Expand Down Expand Up @@ -141,7 +140,7 @@ public void checkAmendPreviousCommit() {
git.closeGitHistoryForm();

// perform amend previous commit
projectExplorer.openItemByPath(PATH_TO_FILE);
editor.selectTabByName(JAVA_FILE_TAB_NAME);
editor.waitActive();
editor.setCursorToLine(12);
editor.selectLineAndDelete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void prepare() throws Exception {
}

@Test(priority = 1)
public void checkoutReferenceByHashCommit() throws Exception {
public void checkoutReferenceByHashCommit() {
// preconditions
String branchDetachedMess = String.format("(detached from %s)", sha1);
String hashCommit = sha1.substring(0, 8);
Expand All @@ -104,15 +104,14 @@ public void checkoutReferenceByHashCommit() throws Exception {
projectExplorer.waitProjectExplorer();
git.importJavaApp(testRepo.getHtmlUrl(), PROJECT_NAME, BLANK);

projectExplorer.quickExpandWithJavaScript();
projectExplorer.openItemByPath(String.format("%s/%s", PROJECT_NAME, JS_FILE));
// open test file
projectExplorer.expandPathInProjectExplorerAndOpenFile(PROJECT_NAME, JS_FILE);
editor.waitActive();
editor.waitTextIntoEditor(UPDATE_FILE);

// check current reference
menu.runCommand(GIT, STATUS);
git.waitGitStatusBarWithMess("On branch " + DEFAULT_BRANCH);

projectExplorer.waitReferenceName(DEFAULT_BRANCH);

// check the name of the default branch
Expand All @@ -125,43 +124,35 @@ public void checkoutReferenceByHashCommit() throws Exception {

// perform checkout reference to wrong hash commit
performCheckoutReference(wrongHashCommit);

git.waitGitStatusBarWithMess(failMessage);

// perform git checkout by not fully hash of specific commit
performCheckoutReference(hashCommit);

editor.selectTabByName(JS_FILE);
editor.waitTextIntoEditor(CHANGE_FILE);
editor.waitTextNotPresentIntoEditor(UPDATE_FILE);

// check current reference
menu.runCommand(GIT, STATUS);
git.waitGitStatusBarWithMess("HEAD detached at " + hashCommit);

projectExplorer.waitReferenceName(sha1);

// switch to default branch
projectExplorer.waitAndSelectItem(PROJECT_NAME);
menu.runCommand(GIT, BRANCHES);
git.waitBranchInTheListWithCoState(branchDetachedMess);
git.selectBranchAndClickCheckoutBtn(DEFAULT_BRANCH);

openBranchPanelAndWaitRefHeadName(DEFAULT_BRANCH);

editor.selectTabByName(JS_FILE);
editor.waitTextIntoEditor(UPDATE_FILE);

// perform git checkout by hash of specific commit
performCheckoutReference(sha1);

openBranchPanelAndWaitRefHeadName(branchDetachedMess);

// check the git history
openGitHistoryForm();

assertTrue(gitHistory.getTopCommitRevision().contains(hashCommit));

git.clickOnHistoryRowInСommitsList(0);
git.waitContentInHistoryEditor(COMMIT_MESSAGE);
git.closeGitHistoryForm();
Expand All @@ -171,26 +162,21 @@ public void checkoutReferenceByHashCommit() throws Exception {
public void checkoutReferenceByTagName() {
// git checkout to wrong tag name
performCheckoutReference("version1");

git.waitGitStatusBarWithMess(MESSAGE_TAG_WRONG);

// git checkout to tag 'version_1'
performCheckoutReference(TAG_NAME_1);

openBranchPanelAndWaitRefHeadName(BRANCH_DETACHED_TAG_1);

editor.selectTabByName(JS_FILE);
editor.waitTextIntoEditor(CHANGE_FILE_1);

// check current reference
menu.runCommand(GIT, STATUS);
git.waitGitStatusBarWithMess("HEAD detached at " + TAG_NAME_1);

projectExplorer.waitReferenceName(TAG_NAME_1);

// check the git history
openGitHistoryForm();

git.clickOnHistoryRowInСommitsList(0);
git.waitContentInHistoryEditor(COMMIT_MESSAGE_TAG_1);
git.closeGitHistoryForm();
Expand All @@ -204,9 +190,7 @@ public void checkoutReferenceByTagName() {

// switch to another tag
performCheckoutReference(TAG_NAME_2);

openBranchPanelAndWaitRefHeadName(BRANCH_DETACHED_TAG_2);

editor.selectTabByName(JS_FILE);
editor.waitTextIntoEditor(CHANGE_FILE_2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.CodenvyEditor;
import org.eclipse.che.selenium.pageobject.Events;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.Menu;
import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.git.Git;
import org.testng.annotations.BeforeClass;
Expand All @@ -52,6 +54,9 @@ public class CheckoutToRemoteBranchTest {
private static final String SECOND_BRANCH = "second_branch";
private static final String NAME_REMOTE_REPO = "origin";
private static final String PULL_MSG = "Already up-to-date";
private static final String MASTER_CHECKED_POPUP_MSG = "Branch 'master' is checked out";
private static final String SECOND_BRANCH_CHECKED_POPUP_MSG =
"Branch 'second_branch' is checked out";
private static String COMMIT_MESS = "commitchk_remote";
private static final String GIT_STATUS_MESS =
" On branch second_branch\n" + " nothing to commit, working directory clean";
Expand All @@ -67,9 +72,11 @@ public class CheckoutToRemoteBranchTest {

@Inject private TestProjectServiceClient testProjectServiceClient;
@Inject private ProjectExplorer projectExplorer;
@Inject private Menu menu;
@Inject private Git git;
@Inject private Menu menu;
@Inject private Events events;
@Inject private CodenvyEditor editor;
@Inject private NotificationsPopupPanel notificationsPopupPanel;
@Inject private TestUserPreferencesServiceClient testUserPreferencesServiceClient;
@Inject private TestGitHubKeyUploader testGitHubKeyUploader;

Expand Down Expand Up @@ -98,6 +105,9 @@ public void checkoutToRemoteBranch() throws Exception {

projectExplorer.waitProjectExplorer();
git.importJavaApp(testRepo.getSshUrl(), PROJECT_NAME, MAVEN);
notificationsPopupPanel.waitPopupPanelsAreClosed();
events.clickEventLogBtn();
events.waitExpectedMessage(MASTER_CHECKED_POPUP_MSG);
projectExplorer.waitAndSelectItem(PROJECT_NAME);

// git checkout to the 'second_branch'
Expand All @@ -116,7 +126,7 @@ public void checkoutToRemoteBranch() throws Exception {

performGitPush();

// import from github to the second project
// import from github the second project
git.importJavaApp(testRepo.getHtmlUrl(), PROJECT_NAME2, MAVEN);
projectExplorer.waitAndSelectItem(PROJECT_NAME2);

Expand All @@ -136,19 +146,21 @@ public void checkoutToRemoteBranch() throws Exception {
git.waitCommitInHistoryForm(COMMIT_MESS);
}

private void checkoutToSecondRemoteBranch() throws Exception {
private void checkoutToSecondRemoteBranch() {
menu.runCommand(GIT, BRANCHES);
git.waitBranchInTheList(MASTER_BRANCH);
git.waitBranchInTheList(ORIGIN_MASTER_BRANCH);
git.waitBranchInTheList(ORIGIN_SECOND_BRANCH);
git.selectBranchAndClickCheckoutBtn(ORIGIN_SECOND_BRANCH);
git.waitGitCompareBranchFormIsClosed();
notificationsPopupPanel.waitExpectedMessageOnProgressPanelAndClose(
SECOND_BRANCH_CHECKED_POPUP_MSG);
menu.runCommand(GIT, BRANCHES);
git.waitBranchInTheListWithCoState(SECOND_BRANCH);
git.closeBranchesForm();
}

private void performGitPull() throws InterruptedException {
private void performGitPull() {
menu.runCommand(GIT, REMOTES_TOP, PULL);
git.waitPullFormToOpen();
git.waitPullRemoteRepository(NAME_REMOTE_REPO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public class InitializeAndDeleteLocalRepositoryTest {
private static final String PROJECT_NAME = NameGenerator.generate("InitAndDelLocalRepo-", 4);
private static final String PATH_FOR_EXPAND =
PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/";
PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java";
private static final String ASK_DIALOG_TEXT =
"Do you want to initialize the local repository " + PROJECT_NAME + "?";
private static final String DELETE_REPO_TEXT =
Expand Down Expand Up @@ -97,7 +97,8 @@ public void initializeLocalRepository() {
git.waitGitStatusBarWithMess("On branch master");
projectExplorer.waitAndSelectItem(PROJECT_NAME);
projectExplorer.quickExpandWithJavaScript();
projectExplorer.openItemByPath(PATH_FOR_EXPAND + "AppController.java");
projectExplorer.quickRevealToItemWithJavaScript(PATH_FOR_EXPAND);
projectExplorer.waitItem(PATH_FOR_EXPAND);
loader.waitOnClosed();

// Check git log
Expand Down Expand Up @@ -129,6 +130,9 @@ public void deleteLocalRepository() {
menu.runCommand(TestMenuCommandsConstants.Git.GIT);
menu.waitCommandIsDisabledInMenu(TestMenuCommandsConstants.Git.DELETE_REPOSITORY);
seleniumWebDriver.navigate().refresh();
projectExplorer.waitItem(PATH_FOR_EXPAND + "AppController.java");
projectExplorer.waitProjectExplorer();
projectExplorer.waitItem(PROJECT_NAME);
projectExplorer.quickRevealToItemWithJavaScript(PATH_FOR_EXPAND);
projectExplorer.waitItem(PATH_FOR_EXPAND);
}
}

0 comments on commit c6972d4

Please sign in to comment.