Reamer commented on code in PR #4734:
URL: https://github.com/apache/zeppelin/pull/4734#discussion_r1527261854


##########
zeppelin-integration/src/test/java/org/apache/zeppelin/ZeppelinITUtils.java:
##########
@@ -58,4 +69,58 @@ public static void turnOnImplicitWaits(WebDriver driver) {
     driver.manage().timeouts()
       
.implicitlyWait(Duration.ofSeconds(AbstractZeppelinIT.MAX_IMPLICIT_WAIT));
   }
+
+  public static WebElement pollingWait(final WebDriver driver, final By 
locator, final long timeWait) {
+    Wait<WebDriver> wait = new FluentWait<>(driver)
+        .withTimeout(Duration.of(timeWait, ChronoUnit.SECONDS))
+        .pollingEvery(Duration.of(1, ChronoUnit.SECONDS))
+        .ignoring(NoSuchElementException.class);
+
+    return wait.until(new Function<WebDriver, WebElement>() {
+      @Override
+      public WebElement apply(WebDriver driver) {
+        return driver.findElement(locator);
+      }
+    });
+  }
+
+  public static void authenticationUser(WebDriver driver, String userName, 
String password) {

Review Comment:
   You could also move this function to `AbstractZeppelinIT`.



##########
zeppelin-integration/src/test/java/org/apache/zeppelin/integration/InterpreterModeActionsIT.java:
##########
@@ -203,12 +202,12 @@ void testGloballyAction() throws Exception {
       clickAndWait(By.xpath(
           
"//div[@class='modal-dialog']//div[@class='bootstrap-dialog-footer-buttons']//button[contains(.,
 'OK')]"));
       clickAndWait(By.xpath("//a[@class='navbar-brand 
navbar-title'][contains(@href, '#/')]"));
-      interpreterModeActionsIT.logoutUser("admin");
+      logoutUser("admin");

Review Comment:
   This class also contains the method `logoutUser`, we should only have the 
function once. My suggestion: not static in `AbstractZeppelinIT`.



##########
zeppelin-integration/src/test/java/org/apache/zeppelin/integration/InterpreterModeActionsIT.java:
##########
@@ -184,8 +184,7 @@ private void setPythonParagraph(int num, String text) {
   void testGloballyAction() throws Exception {
     try {
       //step 1: (admin) login, set 'globally in shared' mode of python 
interpreter, logout
-      InterpreterModeActionsIT interpreterModeActionsIT = new 
InterpreterModeActionsIT();
-      interpreterModeActionsIT.authenticationUser("admin", "password1");
+      authenticationUser("admin", "password1");

Review Comment:
   This class also contains the method `authenticationUser`, we should only 
have the function once. My suggestion: not static in `AbstractZeppelinIT`.



##########
zeppelin-integration/src/test/java/org/apache/zeppelin/AbstractZeppelinIT.java:
##########
@@ -118,17 +118,7 @@ protected boolean waitForText(final String txt, final By 
locator) {
   }
 
   protected WebElement pollingWait(final By locator, final long timeWait) {
-    Wait<WebDriver> wait = new FluentWait<>(manager.getWebDriver())
-        .withTimeout(Duration.of(timeWait, ChronoUnit.SECONDS))
-        .pollingEvery(Duration.of(1, ChronoUnit.SECONDS))
-        .ignoring(NoSuchElementException.class);
-
-    return wait.until(new Function<WebDriver, WebElement>() {
-      @Override
-      public WebElement apply(WebDriver driver) {
-        return driver.findElement(locator);
-      }
-    });
+    return ZeppelinITUtils.pollingWait(manager.getWebDriver(), locator, 
timeWait);

Review Comment:
   Why did you outsource this function?



##########
zeppelin-integration/src/test/java/org/apache/zeppelin/ZeppelinITUtils.java:
##########
@@ -58,4 +69,58 @@ public static void turnOnImplicitWaits(WebDriver driver) {
     driver.manage().timeouts()
       
.implicitlyWait(Duration.ofSeconds(AbstractZeppelinIT.MAX_IMPLICIT_WAIT));
   }
+
+  public static WebElement pollingWait(final WebDriver driver, final By 
locator, final long timeWait) {
+    Wait<WebDriver> wait = new FluentWait<>(driver)
+        .withTimeout(Duration.of(timeWait, ChronoUnit.SECONDS))
+        .pollingEvery(Duration.of(1, ChronoUnit.SECONDS))
+        .ignoring(NoSuchElementException.class);
+
+    return wait.until(new Function<WebDriver, WebElement>() {
+      @Override
+      public WebElement apply(WebDriver driver) {
+        return driver.findElement(locator);
+      }
+    });
+  }
+
+  public static void authenticationUser(WebDriver driver, String userName, 
String password) {
+    ZeppelinITUtils.pollingWait(
+        driver,
+        By.xpath("//div[contains(@class, 
'navbar-collapse')]//li//button[contains(.,'Login')]"),
+        MAX_BROWSER_TIMEOUT_SEC).click();
+
+    ZeppelinITUtils.sleep(1000, false);
+
+    ZeppelinITUtils.pollingWait(
+        driver,
+        By.xpath("//*[@id='userName']"),
+        MAX_BROWSER_TIMEOUT_SEC).sendKeys(userName);
+    ZeppelinITUtils.pollingWait(
+        driver,
+        By.xpath("//*[@id='password']"),
+        MAX_BROWSER_TIMEOUT_SEC).sendKeys(password);
+    ZeppelinITUtils.pollingWait(
+        driver,
+        By.xpath("//*[@id='loginModalContent']//button[contains(.,'Login')]"),
+        MAX_BROWSER_TIMEOUT_SEC).click();
+
+    ZeppelinITUtils.sleep(1000, false);
+  }
+
+  public static void logoutUser(WebDriver driver, String userName) throws 
URISyntaxException {

Review Comment:
   You could also move this function to `AbstractZeppelinIT`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to