@Test
  public void renameAndDeleteRemoteBranchTest() throws Exception {
    IDE.GET_STARTED_WIZARD.waitAndCloseWizard();
    IDE.EXPLORER.waitOpened();

    // Clone test repository again with specific remote name.
    IDE.MENU.runCommand(MenuCommands.Git.GIT, MenuCommands.Git.CLONE_REPOSITORY);
    IDE.GIT.waitGitCloneForm();
    IDE.GIT.typeRemoteGitRepositoryURI(REPO_URL);
    IDE.GIT.clickCloneButtonOnCloneRemoteRepositoryForm();
    IDE.LOADER.waitClosed();
    IDE.OUTPUT.waitOpened();
    IDE.OUTPUT.waitForSubTextPresent(REPO_URL + " was successfully cloned.");
    IDE.OUTPUT.waitForSubTextPresent("[INFO] Project preparing successful.");
    IDE.LOADER.waitClosed();

    IDE.INVITE_FORM.waitInviteDevelopersOpened();
    IDE.INVITE_FORM.clickOnCancelButton();

    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer(PROJECT);

    // Open "Branches" window.
    IDE.MENU.runCommand(MenuCommands.Git.GIT, MenuCommands.Git.BRANCHES);
    IDE.GIT.waitBranhesOpened();
    IDE.GIT.waitFieldWithNewNameBranchForm("origin/master");
    IDE.GIT.waitFieldWithNewNameBranchForm("master");
    IDE.GIT.selectBranchInList("origin/master");

    // Checkout to the master remote branch.
    IDE.GIT.clickCheckOutBtn();
    IDE.LOADER.waitClosed();
    IDE.GIT.clickCloseBranchBtn();
    IDE.OUTPUT.waitOpened();
    IDE.OUTPUT.waitForSubTextPresent("fatal: A branch named 'master' already exists");
  }
  @Test
  public void checkFactoryURLWithWARProjectTypeTest() throws Exception {
    PROJECT = "war";

    IDE.GET_STARTED_WIZARD.waitAndCloseWizard();
    IDE.WELCOME_PAGE.clickCreateNewProjectFromScratch();
    IDE.CREATE_PROJECT_FROM_SCRATHC.waitCreateProjectFromScratch();
    IDE.CREATE_PROJECT_FROM_SCRATHC.typeProjectName(PROJECT);
    IDE.CREATE_PROJECT_FROM_SCRATHC.selectJavaWebApplicationTechnology();
    IDE.CREATE_PROJECT_FROM_SCRATHC.clickNextButton();
    IDE.CREATE_PROJECT_FROM_SCRATHC.waitProjectTemplateForm();
    IDE.CREATE_PROJECT_FROM_SCRATHC.selectProjectTemplate("Java Web project.");
    IDE.CREATE_PROJECT_FROM_SCRATHC.clickFinishButton();
    IDE.LOADER.waitClosed();
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer(PROJECT);

    IDE.MENU.runCommand(MenuCommands.Share.SHARE, MenuCommands.Share.FACTORY_URL);
    IDE.LOADER.waitClosed();
    IDE.FACTORY_URL.waitFactoryURLFormOpened();
    IDE.LOADER.waitClosed();
    IDE.FACTORY_URL.clickOnNextFactoryButton();
    IDE.FACTORY_URL.waitForFinishCreationPage();
    String factoryURL = IDE.FACTORY_URL.getDirectSharingURL();
    IDE.FACTORY_URL.clickOnFinishButtonInFactoryURLForm();
    IDE.LOGIN.logout();
    driver.get(factoryURL);
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer(PROJECT);

    IDE.MENU.runCommand(MenuCommands.Project.PROJECT, MenuCommands.Project.PROJECT_PROPERTIES);
    IDE.PROPERTIES.waitProjectPropertiesOpened();
    assertTrue(
        IDE.PROPERTIES
            .getAllTextFromProjectProperties()
            .contains("Project Type\n" + "Servlet/JSP"));
  }
  @Test
  public void checkFactoryURLWithPHPProjectTypeTest() throws Exception {
    PROJECT = "php";

    driver.get(LOGIN_URL);
    waitIdeLoginPage();
    IDE.LOGIN.waitTenantAllLoginPage();
    IDE.LOGIN.tenantLogin(USER_NAME, USER_PASSWORD);

    IDE.GET_STARTED_WIZARD.waitAndCloseWizard();
    IDE.WELCOME_PAGE.clickCreateNewProjectFromScratch();
    IDE.CREATE_PROJECT_FROM_SCRATHC.waitCreateProjectFromScratch();
    IDE.CREATE_PROJECT_FROM_SCRATHC.typeProjectName(PROJECT);
    IDE.CREATE_PROJECT_FROM_SCRATHC.selectPHPTechnology();
    IDE.CREATE_PROJECT_FROM_SCRATHC.clickNextButton();
    IDE.CREATE_PROJECT_FROM_SCRATHC.waitProjectTemplateForm();
    IDE.CREATE_PROJECT_FROM_SCRATHC.selectProjectTemplate("Simple PHP project.");
    IDE.CREATE_PROJECT_FROM_SCRATHC.clickFinishButton();
    IDE.LOADER.waitClosed();
    IDE.EXPLORER.waitForItem(PROJECT);

    IDE.MENU.runCommand(MenuCommands.Share.SHARE, MenuCommands.Share.FACTORY_URL);
    IDE.FACTORY_URL.waitFactoryURLFormOpened();
    IDE.FACTORY_URL.clickOnNextFactoryButton();
    IDE.FACTORY_URL.waitForFinishCreationPage();
    String factoryURL = IDE.FACTORY_URL.getDirectSharingURL();
    IDE.FACTORY_URL.clickOnFinishButtonInFactoryURLForm();
    IDE.LOGIN.logout();
    driver.get(factoryURL);
    IDE.FACTORY_URL.waitWelcomeIframe();
    IDE.selectMainFrame();
    IDE.EXPLORER.waitForItem(PROJECT);
    IDE.MENU.runCommand(MenuCommands.Project.PROJECT, MenuCommands.Project.PROJECT_PROPERTIES);
    IDE.PROPERTIES.waitProjectPropertiesOpened();
    assertTrue(IDE.PROPERTIES.getAllTextFromProjectProperties().contains("Project Type\n" + "PHP"));
  }
  @Test
  public void checkNewPackageInExplorers() throws Exception {
    // step one run two browsers. In first browser (owner tenant) wait package explorer and expand
    // main items
    initSecondBrowser();
    IDE.EXPLORER.waitOpened();
    IDE.OPEN.openProject(PROJECT);
    IDE.PACKAGE_EXPLORER.waitPackageExplorerOpened();
    IDE.MENU.runCommand(
        MenuCommands.Project.PROJECT, MenuCommands.Project.ENABLE_COLLABORATION_MODE);
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer("src/main/java");
    IDE.PACKAGE_EXPLORER.openItemWithDoubleClick("src");
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer("pom.xml");
    expandMainItemsInPackageExplorer();

    // step two In second (ivited user browser) wait project explorer and expand main nodes
    IDE2.EXPLORER.waitOpened();
    IDE2.OPEN.openProject(PROJECT);
    IDE2.PACKAGE_EXPLORER.waitPackageExplorerOpened();
    IDE2.MENU.waitForMenuItemPresent(
        MenuCommands.Project.PROJECT, MenuCommands.Project.DISABLE_COLLABORATION_MODE);
    IDE2.PACKAGE_EXPLORER.closePackageExplorer();
    IDE2.PACKAGE_EXPLORER.waitPackageExplorerClosed();
    IDE2.EXPLORER.waitForItem(PROJECT + "/src");
    IDE2.EXPLORER.waitForItem(PROJECT + "/pom.xml");
    expandProjectInInviteBrowser();

    // step three, create new package in owner browser and check creation in two browsers
    IDE.PACKAGE_EXPLORER.selectItemInPackageExplorer("src/main/java");
    IDE.MENU.runCommand(MenuCommands.File.FILE, MenuCommands.New.NEW, MenuCommands.New.PACKAGE);
    IDE.LOADER.waitClosed();
    IDE.PACKAGE_EXPLORER.waitCreateNewPackageForm();
    IDE.PACKAGE_EXPLORER.typeNewPackageName(PACKAGE_NAME);
    IDE.PACKAGE_EXPLORER.clickCreateNewPackageButton();
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer(PACKAGE_NAME);

    // checking creation in the browser by invited user
    IDE2.EXPLORER.waitForItem(PROJECT + "/src/main/java/org");
    IDE2.EXPLORER.openItem(PROJECT + "/src/main/java/org");
    IDE2.EXPLORER.waitForItem(PROJECT + "/src/main/java/org/ua");
    IDE2.EXPLORER.openItem(PROJECT + "/src/main/java/org/ua");

    IDE2.EXPLORER.waitForItem(PROJECT + "/src/main/java/org/ua/codenvy");
    IDE2.EXPLORER.selectItem(PROJECT + "/src/main/java/org/ua/codenvy");

    // step four create new class in the browser by invited use and check in the two browsers
    IDE2.TOOLBAR.runCommandFromNewPopupMenu(MenuCommands.New.JAVA_CLASS);
    IDE2.CREATE_NEW_CLASS.waitCreateFormIsPresent();
    IDE2.CREATE_NEW_CLASS.waitItemIsPresentInKindList("Class");
    IDE2.CREATE_NEW_CLASS.waitItemIsPresentInPackageList("sumcontroller");
    IDE2.CREATE_NEW_CLASS.waitItemIsPresentInSourceFolderList("src/main/java");
    IDE2.CREATE_NEW_CLASS.typeClassName(NEW_CLASS_NAME);
    IDE2.CREATE_NEW_CLASS.waitCreateButtonIsEnabled();
    IDE2.CREATE_NEW_CLASS.clickCreateBtn();
    IDE2.CREATE_NEW_CLASS.waitFormIsClosed();
    IDE2.EXPLORER.waitForItem(PROJECT + "/src/main/java/org/ua/codenvy/" + "CollabCheck.java");

    IDE.PACKAGE_EXPLORER.openItemWithDoubleClick("org.ua.codenvy");
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer(NEW_CLASS_NAME + ".java");

    // delete calc file by owner and check in two browsers
    IDE.PACKAGE_EXPLORER.selectItemInPackageExplorer("calc.jsp");
    IDE.TOOLBAR.runCommand(ToolbarCommands.File.DELETE);
    IDE.DELETE.waitOpened();
    IDE.DELETE.clickOkButton();
    IDE.DELETE.waitClosed();
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorerIsNotPresent("calc.jsp");
    IDE2.EXPLORER.waitItemNotPresent(PROJECT + "/src" + "/main" + "/webapp" + "/calc.jsp");
  }
  @Test
  public void сopyToMyWorkspaceWithChangesTest() throws Exception {
    IDE.EXPLORER.waitOpened();
    IDE.OPEN.openProject(PROJECT);
    IDE.PACKAGE_EXPLORER.waitPackageExplorerOpened();
    IDE.MENU.runCommand(MenuCommands.Share.SHARE, MenuCommands.Share.FACTORY_URL);
    IDE.FACTORY_URL.waitFactoryURLFormOpened();
    IDE.FACTORY_URL.clickOnNextFactoryButton();
    IDE.FACTORY_URL.waitForFinishCreationPage();
    String factoryURL = IDE.FACTORY_URL.getDirectSharingURL();
    IDE.FACTORY_URL.clickOnFinishButtonInFactoryURLForm();
    IDE.LOGIN.logout();

    driver.get(LOGIN_URL);
    Thread.sleep(1000);
    waitIdeLoginPage();
    IDE.LOGIN.waitTenantAllLoginPage();
    IDE.LOGIN.tenantLogin(NOT_ROOT_USER_NAME, USER_PASSWORD);

    if (IDE.SELECT_WORKSPACE.isSelectWorkspacePageOpened() == true) {
      IDE.SELECT_WORKSPACE.waitWorkspaceInSelectWorkspacePage(TENANT_NAME);
      IDE.SELECT_WORKSPACE.clickOnWorkspaceName(TENANT_NAME);
    }

    driver.get(factoryURL);
    IDE.LOADER.waitClosed();
    IDE.FACTORY_URL.waitWelcomeIframe();
    IDE.selectMainFrame();
    // do some changes
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer(PROJECT);
    IDE.PACKAGE_EXPLORER.waitPackageExplorerOpened();
    IDE.PACKAGE_EXPLORER.selectItemInPackageExplorer(PROJECT);

    IDE.RENAME.rename(NEW_PRJ_NAME);
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer(NEW_PRJ_NAME);
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer("pom.xml");
    IDE.PACKAGE_EXPLORER.openItemWithDoubleClick("pom.xml");
    IDE.EDITOR.waitActiveFile();
    IDE.EDITOR.typeTextIntoEditor(Keys.CONTROL.toString() + Keys.END.toString());
    IDE.EDITOR.typeTextIntoEditor("<!-- thisIsChange -->");
    IDE.EDITOR.waitFileContentModificationMark("pom.xml");
    // check copy to my WS with not saved files
    IDE.FACTORY_URL.waitCopyToMyWorkspaceButton();
    IDE.FACTORY_URL.clickOnCopyToMyWorkspaceButton();
    IDE.INFORMATION_DIALOG.waitOpened();
    IDE.INFORMATION_DIALOG.waitMessage("Please, save all changes before copying projects.");
    IDE.INFORMATION_DIALOG.clickOk();
    IDE.TOOLBAR.runCommand(ToolbarCommands.File.SAVE);
    IDE.LOADER.waitClosed();
    IDE.EDITOR.waitNoContentModificationMark("pom.xml");
    // deleting project on regular WS
    VirtualFileSystemUtils.delete(PROJECT);
    // check that project was deleted
    assertTrue(
        VirtualFileSystemUtils.get(REST_URL + "itembypath/" + PROJECT).getStatusCode() == 404);

    IDE.FACTORY_URL.waitCopyToMyWorkspaceButton();
    IDE.FACTORY_URL.clickOnCopyToMyWorkspaceButton();
    if (IDE.SELECT_WORKSPACE.isSelectWorkspacePageOpened() == true) {
      IDE.SELECT_WORKSPACE.waitWorkspaceInSelectWorkspacePage(TENANT_NAME);
      IDE.SELECT_WORKSPACE.clickOnWorkspaceName(TENANT_NAME);
    }

    IDE.PACKAGE_EXPLORER.waitPackageExplorerOpened();
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer(NEW_PRJ_NAME);
    Assert.assertTrue(driver.getCurrentUrl().equals(WORKSPACE_URL));
    IDE.PACKAGE_EXPLORER.waitItemInPackageExplorer("pom.xml");
    IDE.PACKAGE_EXPLORER.openItemWithDoubleClick("pom.xml");
    IDE.EDITOR.waitActiveFile();
    IDE.EDITOR.waitContentIsPresent("<!-- thisIsChange -->");
  }