From 15d25096f43293fbe0f7089d09ec9656578c6380 Mon Sep 17 00:00:00 2001 From: CHEYNE Date: Wed, 20 Mar 2024 12:21:49 +0800 Subject: [PATCH] add url assertion --- .../integration/test/web/ui/MetalakePageTest.java | 3 ++- .../integration/test/web/ui/pages/MetalakePage.java | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/MetalakePageTest.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/MetalakePageTest.java index ebe09bbe8b3..9992feac209 100644 --- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/MetalakePageTest.java +++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/MetalakePageTest.java @@ -111,6 +111,7 @@ public void testLinkToCatalogsPage() { String name = "a_test_link"; createMetalakeAction(name); metalakePage.clickMetalakeLink(name); - Assertions.assertTrue(metalakePage.verifyLinkToCatalogsPage()); + Assertions.assertTrue(metalakePage.verifyLinkToCatalogsPage(name)); + Assertions.assertEquals(driver.getCurrentUrl(), metalakePage.nameLink.getAttribute("href")); } } diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/MetalakePage.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/MetalakePage.java index 182e640a9af..35593eeeb96 100644 --- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/MetalakePage.java +++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/web/ui/pages/MetalakePage.java @@ -65,6 +65,9 @@ public class MetalakePage extends AbstractWebIT { xpath = "//div[@data-refer='metalake-table-grid']//button[@aria-label='Go to previous page']") public WebElement prevPageBtn; + @FindBy(xpath = "//*[@data-refer='metalake-name-link']") + public WebElement nameLink; + public MetalakePage() { PageFactory.initElements(driver, this); } @@ -278,13 +281,19 @@ public boolean verifyQueryMetalake(String name) { } } - public boolean verifyLinkToCatalogsPage() { + public boolean verifyLinkToCatalogsPage(String name) { try { Thread.sleep(ACTION_SLEEP_MILLIS); String xpath = "//*[@data-refer='metalake-name-link']"; WebElement nameLink = driver.findElement(By.xpath(xpath)); WebDriverWait wait = new WebDriverWait(driver, MAX_TIMEOUT); - wait.until(ExpectedConditions.elementToBeClickable(nameLink)); + wait.until(ExpectedConditions.urlToBe(nameLink.getAttribute("href"))); + Thread.sleep(ACTION_SLEEP_MILLIS); + + if (!nameLink.getText().equals(name)) { + LOG.error("name link is not match"); + return false; + } return true; } catch (Exception e) {