ParkGyeongTae commented on code in PR #4941: URL: https://github.com/apache/zeppelin/pull/4941#discussion_r2251202984
########## zeppelin-integration/src/test/java/org/apache/zeppelin/WebDriverManager.java: ########## @@ -80,83 +80,44 @@ public WebDriver getWebDriver() { } private WebDriver constructWebDriver(int port) { - Supplier<WebDriver> chromeDriverSupplier = () -> { - try { - ChromeOptions options = new ChromeOptions(); - return new ChromeDriver(options); - } catch (Exception e) { - LOG.error("Exception in WebDriverManager while ChromeDriver ", e); - return null; - } - }; - Supplier<WebDriver> firefoxDriverSupplier = () -> { - try { - return getFirefoxDriver(); - } catch (Exception e) { - LOG.error("Exception in WebDriverManager while FireFox Driver ", e); - return null; - } - }; - Supplier<WebDriver> safariDriverSupplier = () -> { - try { - return new SafariDriver(); - } catch (Exception e) { - LOG.error("Exception in WebDriverManager while SafariDriver ", e); - return null; - } - }; + WebDriver driver = getFirefoxDriver(); - WebDriver driver; - switch (SystemUtils.getEnvironmentVariable("ZEPPELIN_SELENIUM_BROWSER", "").toLowerCase(Locale.ROOT)) { - case "chrome": - driver = chromeDriverSupplier.get(); - break; - case "firefox": - driver = firefoxDriverSupplier.get(); - break; - case "safari": - driver = safariDriverSupplier.get(); - break; - default: - driver = Stream.of(chromeDriverSupplier, firefoxDriverSupplier, safariDriverSupplier) - .map(Supplier::get) - .filter(Objects::nonNull) - .findFirst() - .orElse(null); - } if (driver == null) { - throw new RuntimeException("No available WebDriver"); + throw new RuntimeException("Failed to initialize Firefox WebDriver"); } String url = "http://localhost:" + port + "/classic"; long start = System.currentTimeMillis(); boolean loaded = false; driver.manage().timeouts() - .implicitlyWait(Duration.ofSeconds(AbstractZeppelinIT.MAX_IMPLICIT_WAIT)); + .implicitlyWait(Duration.ofSeconds(AbstractZeppelinIT.MAX_IMPLICIT_WAIT)); driver.get(url); while (System.currentTimeMillis() - start < 60 * 1000) { - // wait for page load try { (new WebDriverWait(driver, Duration.ofSeconds(30))).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { - return d.findElement(By.xpath("//i[@uib-tooltip='WebSocket Connected']")) - .isDisplayed(); + return d.findElement(By.xpath("//i[@uib-tooltip='WebSocket Connected']")).isDisplayed(); } }); loaded = true; break; } catch (TimeoutException e) { - LOG.info("Exception in WebDriverManager while WebDriverWait ", e); + LOG.info("Retry loading the page due to timeout.", e); driver.navigate().to(url); } } assertTrue(loaded); - driver.manage().window().maximize(); + try { + driver.manage().window().maximize(); + } catch (Exception e) { + LOG.warn("Failed to maximize Firefox window. Consider using setSize instead.", e); Review Comment: Thanks for the suggestion! I updated the message from "Failed to maximize Firefox window. Consider using setSize instead." to "Failed to maximize browser window. Consider using setSize() instead." to make it more generic. -- 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: reviews-unsubscr...@zeppelin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org