From 0c5686c8ac8286225c31c486007fde8e10047ca5 Mon Sep 17 00:00:00 2001 From: Sergey Skorik Date: Tue, 24 Sep 2019 12:08:34 +0300 Subject: [PATCH] [Selenium] Adapt selenium tests from ocpoauth package (#14619) --- .../keycloak/cli/OpenShiftKeycloakCliCommandExecutor.java | 5 ++--- .../selenium/pageobject/dashboard/workspaces/Workspaces.java | 2 +- .../che/selenium/pageobject/ocp/OpenShiftLoginPage.java | 2 +- .../selenium/pageobject/ocp/OpenShiftProjectCatalogPage.java | 2 +- .../ocpoauth/LoginExistedUserWithOpenShiftOAuthTest.java | 4 +--- .../site/ocpoauth/LoginNewUserWithOpenShiftOAuthTest.java | 4 +--- 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/OpenShiftKeycloakCliCommandExecutor.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/OpenShiftKeycloakCliCommandExecutor.java index 4fb56a60589f..add5358f95a9 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/OpenShiftKeycloakCliCommandExecutor.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/core/client/keycloak/cli/OpenShiftKeycloakCliCommandExecutor.java @@ -69,9 +69,8 @@ private void obtainKeycloakPodName() throws IOException { // obtain name of keycloak pod String getKeycloakPodNameCommand = format( - "get pod --namespace=%s -l app=%s --no-headers | awk '{print $1}'", - cheOpenshiftProject != null ? cheOpenshiftProject : DEFAULT_CHE_OPENSHIFT_PROJECT, - keycloakApp != null ? keycloakApp : DEFAULT_KEYCLOAK_APP); + "get pods --namespace=%s | grep keycloak | awk '{print $1}'", + cheOpenshiftProject != null ? cheOpenshiftProject : DEFAULT_CHE_OPENSHIFT_PROJECT); keycloakPodName = openShiftCliCommandExecutor.execute(getKeycloakPodNameCommand); diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/workspaces/Workspaces.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/workspaces/Workspaces.java index 984013d88bd8..06e0e83c2a05 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/workspaces/Workspaces.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/dashboard/workspaces/Workspaces.java @@ -70,7 +70,7 @@ public interface Locators { String DOCUMENTATION_LINK = "//div[@che-link-title='Learn more.']/a"; String ADD_WORKSPACE_BTN = "add-item-button"; String DELETE_WORKSPACE_BTN = "delete-item-button"; - String DELETE_DIALOG_BUTTON = "//md-dialog[@role='dialog']//button/span[text()='Delete']"; + String DELETE_DIALOG_BUTTON = "//md-dialog[@role='dialog']//button[text()='Delete']"; String BULK_CHECKBOX = "//md-checkbox[@aria-label='Workspace list']"; String SEARCH_WORKSPACE_FIELD = "//input[@ng-placeholder='Search']"; String NO_WORKSPACE_FOUND = "//span[text()='No workspaces found.']"; diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ocp/OpenShiftLoginPage.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ocp/OpenShiftLoginPage.java index 5435c88df8d2..32d7305e065c 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ocp/OpenShiftLoginPage.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ocp/OpenShiftLoginPage.java @@ -61,7 +61,7 @@ public void login(String username, String password) { waitOnClose(); } - private void waitOnOpen() { + public void waitOnOpen() { seleniumWebDriverHelper.waitAllVisibility(asList(usernameInput, passwordInput, loginButton)); } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ocp/OpenShiftProjectCatalogPage.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ocp/OpenShiftProjectCatalogPage.java index f471d3a2674a..8fb5862ec277 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ocp/OpenShiftProjectCatalogPage.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/ocp/OpenShiftProjectCatalogPage.java @@ -63,7 +63,7 @@ public void waitProjectAbsence(String projectNamePart) { } public void open() { - seleniumWebDriver.navigate().to(openShiftWebConsoleUrlProvider.get()); + seleniumWebDriver.navigate().to(openShiftWebConsoleUrlProvider.get() + "console"); } public void logout() { diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/site/ocpoauth/LoginExistedUserWithOpenShiftOAuthTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/site/ocpoauth/LoginExistedUserWithOpenShiftOAuthTest.java index 782ad1907bd5..c025fcf799e6 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/site/ocpoauth/LoginExistedUserWithOpenShiftOAuthTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/site/ocpoauth/LoginExistedUserWithOpenShiftOAuthTest.java @@ -104,10 +104,8 @@ public void checkExistedCheUserOcpProjectCreationAndRemoval() throws Exception { // (we can't use dashboard.open() here to login with OAuth) seleniumWebDriver.navigate().to(testDashboardUrlProvider.get()); - // click on button to login with OpenShift OAuth - cheLoginPage.loginWithOpenShiftOAuth(); - // login to OCP from login page with default test user credentials + openShiftLoginPage.waitOnOpen(); openShiftLoginPage.login(defaultTestUser.getName(), defaultTestUser.getPassword()); // authorize ocp-client to access OpenShift account diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/site/ocpoauth/LoginNewUserWithOpenShiftOAuthTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/site/ocpoauth/LoginNewUserWithOpenShiftOAuthTest.java index dba6592b2928..e5a7e652a5eb 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/site/ocpoauth/LoginNewUserWithOpenShiftOAuthTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/site/ocpoauth/LoginNewUserWithOpenShiftOAuthTest.java @@ -103,10 +103,8 @@ public void checkNewCheUserOcpProjectCreationAndRemoval() { // (we can't use dashboard.open() here to login with OAuth) seleniumWebDriver.navigate().to(testDashboardUrlProvider.get()); - // click on button to login with OpenShift OAuth - cheLoginPage.loginWithOpenShiftOAuth(); - // login to OCP from login page with new test user credentials + openShiftLoginPage.waitOnOpen(); openShiftLoginPage.login(NEW_TEST_USER.getName(), NEW_TEST_USER.getPassword()); // authorize ocp-client to access OpenShift account