This is an automated email from the ASF dual-hosted git repository.

kaihsun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new ca58ac9  SUBMARINE-878. Modify E2E LoginIT with page object
ca58ac9 is described below

commit ca58ac9a86b15f9f7ecd88f458974b1541a7747d
Author: noidname01 <[email protected]>
AuthorDate: Fri Jul 2 14:46:18 2021 +0800

    SUBMARINE-878. Modify E2E LoginIT with page object
    
    ### What is this PR for?
    Modify E2E LoginIT with page object
    
    ### What type of PR is it?
    [Improvement]
    
    ### Todos
    
    ### What is the Jira issue?
    
    https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-878
    
    ### How should this be tested?
    
    ```bash
    # Step1: Run Submarine workbench on 127.0.0.1:8080 by operator
    # Step2: Run testcase
    cd submarine-cloud-v2
    
    # Usage: ./hack/run_frontend_e2e.sh ${testcase}
    # Example:
    ./hack/run_frontend_e2e.sh notebookIT
    ```
    ### Screenshots (if appropriate)
    
    
![](https://user-images.githubusercontent.com/20109646/121817982-10ed4a00-ccb7-11eb-842f-61edb7c73c27.png)
    
    ### Questions:
    * Do the license files need updating? No
    * Are there breaking changes for older versions? No
    * Does this need new documentation? No
    
    Author: noidname01 <[email protected]>
    
    Signed-off-by: Kai-Hsun Chen <[email protected]>
    
    Closes #624 from noidname01/SUBMARINE-878 and squashes the following 
commits:
    
    b82915ff [noidname01] fix coding style
    311e9251 [noidname01] merge with 881
    3efe5445 [noidname01] remove the function and add the readability
    9a13688f [noidname01] bug fix
    9d6d3edb [noidname01] remove empty function
    94b01fa8 [noidname01] fix indent and remove comment
    f12a39fe [noidname01] login in the current non-used page
    f3b008b9 [noidname01] recover sh
    926b57fe [noidname01] remove blankspace
    ba235852 [noidname01] login
    3f1544cc [noidname01] loginIT
---
 submarine-cloud-v2/hack/run_frontend_e2e.sh        |  2 +-
 .../org/apache/submarine/AbstractSubmarineIT.java  | 15 ++-----
 .../org/apache/submarine/integration/dataIT.java   |  9 ++--
 .../apache/submarine/integration/datadictIT.java   | 10 ++---
 .../apache/submarine/integration/departmentIT.java |  4 +-
 .../submarine/integration/environmentIT.java       |  4 +-
 .../apache/submarine/integration/experimentIT.java |  5 ++-
 .../org/apache/submarine/integration/homeIT.java   |  8 ++--
 .../submarine/integration/interpreterIT.java       |  8 ++--
 .../org/apache/submarine/integration/loginIT.java  | 39 ++++++++++-------
 .../apache/submarine/integration/notebookIT.java   |  6 ++-
 .../submarine/integration/pages/LoginPage.java     | 51 ++++++++++++++++++++++
 .../org/apache/submarine/integration/teamIT.java   |  8 ++--
 .../apache/submarine/integration/workspaceIT.java  |  7 ++-
 14 files changed, 118 insertions(+), 58 deletions(-)

diff --git a/submarine-cloud-v2/hack/run_frontend_e2e.sh 
b/submarine-cloud-v2/hack/run_frontend_e2e.sh
index 95b2d29..09b78fe 100755
--- a/submarine-cloud-v2/hack/run_frontend_e2e.sh
+++ b/submarine-cloud-v2/hack/run_frontend_e2e.sh
@@ -42,4 +42,4 @@ fi
 
 set -e
 TESTCASE=$1
-mvn -f submarine-test/test-e2e/ -DSUBMARINE_WORKBENCH_URL=$URL 
-DSUBMARINE_WORKBENCH_PORT=$WORKBENCH_PORT -Dtest=$TESTCASE 
-DSUBMARINE_E2E_LOCAL=true test
\ No newline at end of file
+mvn -f submarine-test/test-e2e/ -DSUBMARINE_WORKBENCH_URL=$URL 
-DSUBMARINE_WORKBENCH_PORT=$WORKBENCH_PORT -Dtest=$TESTCASE 
-DSUBMARINE_E2E_LOCAL=true test
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/AbstractSubmarineIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/AbstractSubmarineIT.java
index 034fe1a..a64042c 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/AbstractSubmarineIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/AbstractSubmarineIT.java
@@ -73,13 +73,13 @@ abstract public class AbstractSubmarineIT {
     if (System.getProperty("SUBMARINE_WORKBENCH_URL") == null) {
       URL = defaultURL;
     } else {
-      URL = System.getProperty("SUBMARINE_WORKBENCH_URL"); 
+      URL = System.getProperty("SUBMARINE_WORKBENCH_URL");
     }
 
     URL = URL.concat(":");
 
     if (System.getProperty("SUBMARINE_WORKBENCH_PORT") == null) {
-      URL = URL.concat(String.valueOf(defaultPort));      
+      URL = URL.concat(String.valueOf(defaultPort));
     } else {
       String port = System.getProperty("SUBMARINE_WORKBENCH_PORT");
       URL = URL.concat(String.valueOf(port));
@@ -87,15 +87,6 @@ abstract public class AbstractSubmarineIT {
     return URL;
   }
 
-  protected void Login() {
-    String username = "admin";
-    String password = "admin";
-    waitToPresent(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys(username);
-    waitToPresent(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys(password);
-    Click(By.cssSelector("button[class='login-form-button ant-btn 
ant-btn-primary']"), MAX_BROWSER_TIMEOUT_SEC);
-    waitToPresent(By.cssSelector("a[routerlink='/workbench/experiment']"), 
MAX_BROWSER_TIMEOUT_SEC);
-  }
-
   protected WebElement buttonCheck(final By locator, final long timeWait) {
     return new WebDriverWait(driver, timeWait)
             .until(ExpectedConditions.elementToBeClickable(locator));
@@ -107,7 +98,7 @@ abstract public class AbstractSubmarineIT {
   }
 
   protected void waitURL(String URL, final long timeWait) {
-    new WebDriverWait(driver, 
timeWait).until(ExpectedConditions.urlToBe​(URL)); 
+    new WebDriverWait(driver, 
timeWait).until(ExpectedConditions.urlToBe​(URL));
   }
 
   protected void waitVisibility(WebElement element, final long timeWait) {
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/dataIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/dataIT.java
index 9a0b9b8..ba5482f 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/dataIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/dataIT.java
@@ -18,6 +18,7 @@
 package org.apache.submarine.integration;
 
 import org.apache.submarine.AbstractSubmarineIT;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.integration.components.Sidebars;
 import org.apache.submarine.WebDriverManager;
 import org.junit.AfterClass;
@@ -50,14 +51,14 @@ public class dataIT extends AbstractSubmarineIT {
   @Test
   public void dataNavigation() throws Exception {
     String URL = getURL("http://127.0.0.1";, 8080);
+
     Sidebars sidebars = new Sidebars(URL);
 
     // Login
+    LoginPage loginPage = new LoginPage();
+
     LOG.info("Login");
-    pollingWait(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    pollingWait(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    clickAndWait(By.cssSelector("button[class='login-form-button ant-btn 
ant-btn-primary']"));
-    pollingWait(By.cssSelector("a[routerlink='/workbench/experiment']"), 
MAX_BROWSER_TIMEOUT_SEC);
+    loginPage.Login();
 
     // Routing to data page
     sidebars.gotoData();
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/datadictIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/datadictIT.java
index 080d2db..638a97c 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/datadictIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/datadictIT.java
@@ -18,6 +18,7 @@
 package org.apache.submarine.integration;
 
 import org.apache.submarine.AbstractSubmarineIT;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.integration.components.Sidebars;
 import org.apache.submarine.WebDriverManager;
 import org.openqa.selenium.By;
@@ -47,15 +48,14 @@ public class datadictIT extends AbstractSubmarineIT {
   // @Test TODO(kevin85421): Due to the undeterministic behavior of travis, I 
decide to comment it.
   public void dataDictTest() throws Exception {
     String URL = getURL("http://127.0.0.1";, 8080);
+
     Sidebars sidebars = new Sidebars(URL);
+    LoginPage loginPage = new LoginPage();
 
     // Login
     LOG.info("Login");
-    pollingWait(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    pollingWait(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    clickAndWait(By.cssSelector("button[class='login-form-button ant-btn 
ant-btn-primary']"));
-    pollingWait(By.cssSelector("a[routerlink='/workbench/experiment']"), 
MAX_BROWSER_TIMEOUT_SEC);
-
+    loginPage.Login();
+    
     // Start Routing & Navigation in data-dict
     LOG.info("Start Routing & Navigation in data-dict");
     sidebars.gotoDataDict();
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/departmentIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/departmentIT.java
index 11a144c..40f963b 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/departmentIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/departmentIT.java
@@ -19,6 +19,7 @@ package org.apache.submarine.integration;
 
 import org.apache.submarine.AbstractSubmarineIT;
 import org.apache.submarine.integration.components.Sidebars;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.WebDriverManager;
 import org.openqa.selenium.support.ui.ExpectedConditions;
 import org.openqa.selenium.support.ui.WebDriverWait;
@@ -51,7 +52,8 @@ public class departmentIT extends AbstractSubmarineIT{
     Sidebars sidebars = new Sidebars(URL);
 
     // Login
-    Login();
+    LoginPage loginPage = new LoginPage();
+    loginPage.Login();
 
     // Routing to department page
     sidebars.gotoDepartment();
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/environmentIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/environmentIT.java
index 2e26d7f..0b34905 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/environmentIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/environmentIT.java
@@ -20,6 +20,7 @@ package org.apache.submarine.integration;
 import org.apache.commons.io.FileUtils;
 import org.apache.submarine.AbstractSubmarineIT;
 import org.apache.submarine.integration.components.Sidebars;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.WebDriverManager;
 import org.openqa.selenium.By;
 import org.openqa.selenium.support.ui.FluentWait;
@@ -61,7 +62,8 @@ public class environmentIT extends AbstractSubmarineIT {
     Sidebars sidebars = new Sidebars(URL);
 
     // Login
-    Login();
+    LoginPage loginPage = new LoginPage();
+    loginPage.Login();
 
     // Routing to workspace
     sidebars.gotoEnvironment();
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/experimentIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/experimentIT.java
index 76499e0..5a5f87d 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/experimentIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/experimentIT.java
@@ -21,6 +21,7 @@ import org.apache.submarine.AbstractSubmarineIT;
 import org.apache.submarine.WebDriverManager;
 import org.apache.submarine.integration.components.Sidebars;
 import org.apache.submarine.integration.pages.ExperimentPage;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.openqa.selenium.By;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,9 +53,11 @@ public class experimentIT extends AbstractSubmarineIT {
     // Init the page object
     ExperimentPage experimentPage = new ExperimentPage(driver);
     Sidebars sidebars = new Sidebars(URL);
+    LoginPage loginPage = new LoginPage();
+
     // Login
     LOG.info("Login");
-    Login();
+    loginPage.Login();
 
     // Routing to workspace
     LOG.info("url");
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/homeIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/homeIT.java
index 32ea9be..2212391 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/homeIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/homeIT.java
@@ -18,6 +18,7 @@
 package org.apache.submarine.integration;
 
 import org.apache.submarine.AbstractSubmarineIT;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.WebDriverManager;
 import org.junit.Ignore;
 import org.openqa.selenium.WebElement;
@@ -48,12 +49,11 @@ public class homeIT extends AbstractSubmarineIT {
 
   @Test
   public void homePagination() throws Exception {
+    LoginPage loginPage = new LoginPage();
     // Login
     LOG.info("Login");
-    pollingWait(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    pollingWait(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    clickAndWait(By.cssSelector("button[class='login-form-button ant-btn 
ant-btn-primary']"));
-    pollingWait(By.cssSelector("a[routerlink='/workbench/experiment']"), 
MAX_BROWSER_TIMEOUT_SEC);
+    loginPage.Login();
+
 
     LOG.info("Pagination");
     List<WebElement> changePageIndexButtons = 
driver.findElements(By.cssSelector("a[class='ant-pagination-item-link 
ng-star-inserted']"));
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/interpreterIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/interpreterIT.java
index 6c8bd3c..d81b6e7 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/interpreterIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/interpreterIT.java
@@ -18,6 +18,7 @@
 package org.apache.submarine.integration;
 
 import org.apache.submarine.AbstractSubmarineIT;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.WebDriverManager;
 import org.apache.submarine.integration.components.Sidebars;
 import org.junit.Ignore;
@@ -49,12 +50,11 @@ public class interpreterIT extends AbstractSubmarineIT {
   public void workspaceNavigation() throws Exception {
     String URL = getURL("http://127.0.0.1";, 8080);
     Sidebars sidebars = new Sidebars(URL);
+    LoginPage loginPage = new LoginPage();
+
     // Login
     LOG.info("Login");
-    pollingWait(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    pollingWait(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    clickAndWait(By.cssSelector("button[class='login-form-button ant-btn 
ant-btn-primary']"));
-    pollingWait(By.cssSelector("a[routerlink='/workbench/experiment']"), 
MAX_BROWSER_TIMEOUT_SEC);
+    loginPage.Login();
 
     // Routing to Interpreter
     sidebars.gotoInterpreter();
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/loginIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/loginIT.java
index e251c3b..bc4f0b1 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/loginIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/loginIT.java
@@ -19,10 +19,7 @@ package org.apache.submarine.integration;
 
 import org.apache.submarine.AbstractSubmarineIT;
 import org.apache.submarine.WebDriverManager;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.By;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterClass;
@@ -49,22 +46,34 @@ public class loginIT extends AbstractSubmarineIT {
     // Testcase1
     LOG.info("[Sub-Testcase-1] Invalid User");
     LOG.info("Enter blank username and password");
-    WebElement signin_button = buttonCheck(By.xpath("//span[text()='Sign 
In']/parent::button"), MAX_BROWSER_TIMEOUT_SEC);
-    signin_button.click();
-    Assert.assertEquals( driver.findElements(By.xpath("//div[contains(text(), 
\"Please input your username!\")]")).size(), 1);
-    Assert.assertEquals( driver.findElements(By.xpath("//div[contains(text(), 
\"Please input your Password!\")]")).size(), 1);
+
+    // Init the page object
+    LoginPage loginPage = new LoginPage();
+
+    // Click sign in without input
+    buttonCheck(loginPage.signInButton, MAX_BROWSER_TIMEOUT_SEC).click();
+
+    // Assert the warning texts
+    
Assert.assertEquals(driver.findElements(loginPage.userNameSignInWarning).size(),
 1);
+    
Assert.assertEquals(driver.findElements(loginPage.passwordSignInWarning).size(),
 1);
+
     LOG.info("Enter invalid username and password");
-    SendKeys(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC, "123");
-    SendKeys(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC, "123");
-    signin_button.click();
 
-    waitToPresent(By.xpath("//div[contains(text(), \"Username and password are 
incorrect,\")]"), MAX_BROWSER_TIMEOUT_SEC);
+    // fill the form
+    SendKeys(loginPage.userNameInput, MAX_BROWSER_TIMEOUT_SEC, "123");
+    SendKeys(loginPage.passwordInput, MAX_BROWSER_TIMEOUT_SEC, "123");
+
+    // click submit
+    buttonCheck(loginPage.signInButton, MAX_BROWSER_TIMEOUT_SEC).click();
+
+    waitToPresent(loginPage.warningText, MAX_BROWSER_TIMEOUT_SEC);
 
-    SendKeys(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC, "\b\b\b");
-    SendKeys(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC, "\b\b\b");
+    // delete current input
+    SendKeys(loginPage.userNameInput, MAX_BROWSER_TIMEOUT_SEC, "\b\b\b");
+    SendKeys(loginPage.passwordInput, MAX_BROWSER_TIMEOUT_SEC, "\b\b\b");
 
     // Testcase2
     LOG.info("[Sub-Testcase-2] Valid User");
-    Login();
+    loginPage.Login();
   }
 }
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/notebookIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/notebookIT.java
index df168da..69ded30 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/notebookIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/notebookIT.java
@@ -20,6 +20,7 @@ package org.apache.submarine.integration;
 import org.apache.submarine.AbstractSubmarineIT;
 import org.apache.submarine.integration.components.Sidebars;
 import org.apache.submarine.WebDriverManager;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.SubmarineITUtils;
 import org.openqa.selenium.By;
 import org.slf4j.Logger;
@@ -48,8 +49,9 @@ public class notebookIT extends AbstractSubmarineIT {
   public void notebookNavigation() throws Exception {
     String URL = getURL("http://127.0.0.1";, 8080);
     Sidebars sidebars = new Sidebars(URL);
-      // Login
-    Login();
+    // Login
+    LoginPage loginPage = new LoginPage();
+    loginPage.Login();
 
     // Routing to Notebook
     sidebars.gotoNoteBook();
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/pages/LoginPage.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/pages/LoginPage.java
new file mode 100644
index 0000000..0cde746
--- /dev/null
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/pages/LoginPage.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.submarine.integration.pages;
+
+import org.openqa.selenium.By;
+import org.apache.submarine.AbstractSubmarineIT;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.pagefactory.AjaxElementLocatorFactory;
+
+
+public class LoginPage extends AbstractSubmarineIT{
+
+    public By userNameInput = 
By.cssSelector("input[ng-reflect-name='userName']");
+
+    public By passwordInput = 
By.cssSelector("input[ng-reflect-name='password']");
+
+    public By signInButton = By.xpath("//span[text()='Sign 
In']/parent::button");
+
+    public By userNameSignInWarning = By.xpath("//div[contains(text(), 
\"Please input your username!\")]");
+
+    public By passwordSignInWarning = By.xpath("//div[contains(text(), 
\"Please input your Password!\")]");
+
+    public By warningText = By.xpath("//div[contains(text(), \"Username and 
password are incorrect,\")]");
+
+
+    public void Login() {
+        String username = "admin";
+        String password = "admin";
+        waitToPresent(userNameInput, 
MAX_BROWSER_TIMEOUT_SEC).sendKeys(username);
+        waitToPresent(passwordInput, 
MAX_BROWSER_TIMEOUT_SEC).sendKeys(password);
+        Click(signInButton, MAX_BROWSER_TIMEOUT_SEC);
+        waitToPresent(By.cssSelector("a[routerlink='/workbench/experiment']"), 
MAX_BROWSER_TIMEOUT_SEC);
+    }
+}
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/teamIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/teamIT.java
index 36a7f6d..34e6077 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/teamIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/teamIT.java
@@ -18,6 +18,7 @@
 package org.apache.submarine.integration;
 
 import org.apache.submarine.AbstractSubmarineIT;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.WebDriverManager;
 import org.junit.Ignore;
 import org.openqa.selenium.By;
@@ -47,12 +48,11 @@ public class teamIT extends AbstractSubmarineIT {
   @Test
   public void teamTest() throws Exception {
     String URL = getURL("http://127.0.0.1";, 8080);
+    LoginPage loginPage = new LoginPage();
+
     // Login
     LOG.info("Login");
-    pollingWait(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    pollingWait(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    clickAndWait(By.cssSelector("button[class='login-form-button ant-btn 
ant-btn-primary']"));
-    pollingWait(By.cssSelector("a[routerlink='/workbench/experiment']"), 
MAX_BROWSER_TIMEOUT_SEC);
+    loginPage.Login();
 
     // Routing to workspace
     pollingWait(By.xpath("//span[contains(text(), \"Workspace\")]"), 
MAX_BROWSER_TIMEOUT_SEC).click();
diff --git 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/workspaceIT.java
 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/workspaceIT.java
index 479e101..4bc01b1 100644
--- 
a/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/workspaceIT.java
+++ 
b/submarine-test/test-e2e/src/test/java/org/apache/submarine/integration/workspaceIT.java
@@ -19,6 +19,7 @@ package org.apache.submarine.integration;
 
 import org.apache.submarine.AbstractSubmarineIT;
 import org.apache.submarine.integration.components.Sidebars;
+import org.apache.submarine.integration.pages.LoginPage;
 import org.apache.submarine.WebDriverManager;
 import org.junit.Ignore;
 import org.openqa.selenium.support.ui.ExpectedConditions;
@@ -51,13 +52,11 @@ public class workspaceIT extends AbstractSubmarineIT {
   public void workspaceNavigation() throws Exception {
     String URL = getURL("http://127.0.0.1";, 8080);
     Sidebars sidebars = new Sidebars(URL);
+    LoginPage loginPage = new LoginPage();
 
     // Login
     LOG.info("Login");
-    pollingWait(By.cssSelector("input[ng-reflect-name='userName']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    pollingWait(By.cssSelector("input[ng-reflect-name='password']"), 
MAX_BROWSER_TIMEOUT_SEC).sendKeys("admin");
-    clickAndWait(By.cssSelector("button[class='login-form-button ant-btn 
ant-btn-primary']"));
-    pollingWait(By.cssSelector("a[routerlink='/workbench/experiment']"), 
MAX_BROWSER_TIMEOUT_SEC);
+    loginPage.Login();
 
     // Routing to workspace
     sidebars.gotoWorkSpace();

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to