diff --git a/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/objectRepository/Common.java b/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/objectRepository/Common.java index 816713155c2..cb5080a807f 100644 --- a/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/objectRepository/Common.java +++ b/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/objectRepository/Common.java @@ -112,6 +112,10 @@ public class Common { return By.xpath("//*[text()[contains(.,'" + matchingText + "')]] "); } + public By textEquals(String matchingText) { + return By.xpath("//*[text()='" + matchingText + "']"); + } + public By serviceType(String serviceType) { return By.cssSelector("[data-testid='" + serviceType + "']"); } diff --git a/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/pages/Webhooks/WebhooksPageTest.java b/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/pages/Webhooks/WebhooksPageTest.java index e7aad424948..35346d3c348 100644 --- a/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/pages/Webhooks/WebhooksPageTest.java +++ b/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/pages/Webhooks/WebhooksPageTest.java @@ -13,6 +13,7 @@ import org.openmetadata.catalog.selenium.events.Events; import org.openmetadata.catalog.selenium.objectRepository.Common; import org.openmetadata.catalog.selenium.objectRepository.Webhooks; import org.openmetadata.catalog.selenium.properties.Property; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; @@ -31,6 +32,7 @@ class WebhooksPageTest { static Webhooks webhooks; static String url = Property.getInstance().getURL(); static Faker faker = new Faker(); + static String name = faker.name().firstName(); static Actions actions; static WebDriverWait wait; Integer waitTime = Property.getInstance().getSleepTime(); @@ -64,7 +66,6 @@ class WebhooksPageTest { @Test @Order(2) void addWebHook() throws InterruptedException { - String name = faker.name().name(); openWebHookPage(); Thread.sleep(waitTime); Events.click(webDriver, webhooks.addWebhook()); @@ -72,6 +73,8 @@ class WebhooksPageTest { Events.click(webDriver, webhooks.descriptionBox()); Events.sendKeys(webDriver, webhooks.focusedDescriptionBox(), faker.address().toString()); Events.sendKeys(webDriver, webhooks.endpoint(), "https://www.example.com"); + ((JavascriptExecutor) webDriver) + .executeScript("arguments[0].scrollIntoView(true);", webDriver.findElement(common.saveWebhook())); Events.click(webDriver, webhooks.checkbox()); Events.click(webDriver, webhooks.entityCreatedMenu()); Events.click(webDriver, webhooks.allEntities()); @@ -87,22 +90,20 @@ class WebhooksPageTest { @Test @Order(3) void checkDuplicateWebhookName() throws InterruptedException { - String name = faker.name().name(); - webDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); openWebHookPage(); - for (int i = 0; i < 2; i++) { - Events.click(webDriver, webhooks.addWebhook()); - Events.sendKeys(webDriver, webhooks.name(), name); - Events.click(webDriver, webhooks.descriptionBox()); - Events.sendKeys(webDriver, webhooks.focusedDescriptionBox(), "test"); - Events.sendKeys(webDriver, webhooks.endpoint(), "https://www.example.com"); - Events.click(webDriver, webhooks.checkbox()); - Events.click(webDriver, webhooks.entityCreatedMenu()); - Events.click(webDriver, webhooks.allEntities()); - Events.click(webDriver, webhooks.clickToCloseDropdown()); - Events.click(webDriver, common.saveWebhook()); - Thread.sleep(waitTime); - } + Events.click(webDriver, webhooks.addWebhook()); + Events.sendKeys(webDriver, webhooks.name(), name); + Events.click(webDriver, webhooks.descriptionBox()); + Events.sendKeys(webDriver, webhooks.focusedDescriptionBox(), "test"); + Events.sendKeys(webDriver, webhooks.endpoint(), "https://www.example.com"); + ((JavascriptExecutor) webDriver) + .executeScript("arguments[0].scrollIntoView(true);", webDriver.findElement(common.saveWebhook())); + Events.click(webDriver, webhooks.checkbox()); + Events.click(webDriver, webhooks.entityCreatedMenu()); + Events.click(webDriver, webhooks.allEntities()); + Events.click(webDriver, webhooks.clickToCloseDropdown()); + Events.click(webDriver, common.saveWebhook()); + Thread.sleep(waitTime); WebElement errorMessage = webDriver.findElement(webhooks.toast()); Assert.assertTrue(errorMessage.isDisplayed()); Assert.assertEquals(errorMessage.getText(), "Entity already exists"); @@ -117,7 +118,9 @@ class WebhooksPageTest { Events.sendKeys(webDriver, webhooks.name(), ""); Events.click(webDriver, webhooks.descriptionBox()); Events.sendKeys(webDriver, webhooks.focusedDescriptionBox(), "test"); - Events.sendKeys(webDriver, webhooks.endpoint(), "test.com"); + Events.sendKeys(webDriver, webhooks.endpoint(), "http://www.test.com"); + ((JavascriptExecutor) webDriver) + .executeScript("arguments[0].scrollIntoView(true);", webDriver.findElement(common.saveWebhook())); Events.click(webDriver, webhooks.checkbox()); Thread.sleep(waitTime); Events.click(webDriver, webhooks.entityCreatedMenu()); @@ -139,6 +142,8 @@ class WebhooksPageTest { Events.click(webDriver, webhooks.descriptionBox()); Events.sendKeys(webDriver, webhooks.focusedDescriptionBox(), "test"); Events.sendKeys(webDriver, webhooks.endpoint(), ""); + ((JavascriptExecutor) webDriver) + .executeScript("arguments[0].scrollIntoView(true);", webDriver.findElement(common.saveWebhook())); Events.click(webDriver, webhooks.checkbox()); Events.click(webDriver, webhooks.entityCreatedMenu()); Events.click(webDriver, webhooks.allEntities()); @@ -159,6 +164,8 @@ class WebhooksPageTest { Events.click(webDriver, webhooks.descriptionBox()); Events.sendKeys(webDriver, webhooks.focusedDescriptionBox(), "test"); Events.sendKeys(webDriver, webhooks.endpoint(), "https://www.test.com"); + ((JavascriptExecutor) webDriver) + .executeScript("arguments[0].scrollIntoView(true);", webDriver.findElement(common.saveWebhook())); Events.click(webDriver, common.saveWebhook()); WebElement errorMessage = webDriver.findElement(common.errorMessage()); Assert.assertTrue(errorMessage.isDisplayed()); diff --git a/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/pages/tags/TagsPageTest.java b/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/pages/tags/TagsPageTest.java index 2b9f71c3f29..25104f6f662 100644 --- a/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/pages/tags/TagsPageTest.java +++ b/openmetadata-ui/src/test/java/org/openmetadata/catalog/selenium/pages/tags/TagsPageTest.java @@ -27,10 +27,7 @@ import org.openmetadata.catalog.selenium.events.Events; import org.openmetadata.catalog.selenium.objectRepository.Common; import org.openmetadata.catalog.selenium.objectRepository.TagsPage; import org.openmetadata.catalog.selenium.properties.Property; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.TimeoutException; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; +import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.interactions.Actions; @@ -99,7 +96,7 @@ class TagsPageTest { @Order(3) void editTagCategoryDescription() throws InterruptedException { openTagsPage(); - Events.click(webDriver, common.containsText(tagCategoryDisplayName)); + Events.click(webDriver, common.textEquals(tagCategoryDisplayName)); Events.click(webDriver, common.editTagCategoryDescription()); Events.click(webDriver, common.focusedDescriptionBox()); Events.click(webDriver, common.editDescriptionSaveButton()); @@ -109,7 +106,7 @@ class TagsPageTest { @Order(4) void addTag() throws InterruptedException { openTagsPage(); - Events.click(webDriver, common.containsText(tagCategoryDisplayName)); + Events.click(webDriver, common.textEquals(tagCategoryDisplayName)); Events.click(webDriver, common.addTagButton()); Events.sendKeys(webDriver, common.displayName(), tagDisplayName); Events.click(webDriver, common.descriptionBoldButton()); @@ -126,7 +123,7 @@ class TagsPageTest { @Order(5) void changeTagDescription() throws InterruptedException { openTagsPage(); - Events.click(webDriver, common.containsText(tagCategoryDisplayName)); + Events.click(webDriver, common.textEquals(tagCategoryDisplayName)); Thread.sleep(waitTime); actions.moveToElement(webDriver.findElement(tagsPage.editTagDescription())).perform(); Events.click(webDriver, tagsPage.editTagDescription()); @@ -180,7 +177,7 @@ class TagsPageTest { @Order(10) void removeTagFromTableColumn() throws InterruptedException { openTagsPage(); - Events.click(webDriver, common.containsText(tagCategoryDisplayName)); + Events.click(webDriver, common.textEquals(tagCategoryDisplayName)); Events.click(webDriver, tagsPage.tagUsageCount()); try { Events.click(webDriver, tagsPage.tableLink()); @@ -230,7 +227,7 @@ class TagsPageTest { Events.click(webDriver, common.saveAssociatedTag()); Events.click(webDriver, common.headerSettings()); Events.click(webDriver, tagsPage.headerSettingsTags()); - Events.click(webDriver, common.containsText("PersonalData")); + Events.click(webDriver, common.textEquals("PersonalData")); Events.click(webDriver, tagsPage.usageCountElementIndex(1)); Thread.sleep(2000); String beforeFilterCount = webDriver.findElement(tagsPage.tagFilterCount(1)).getAttribute("innerHTML");