Selenium error fix for Users and Service page (#4467)

This commit is contained in:
kshinde2512 2022-04-25 19:20:45 +05:30 committed by GitHub
parent 355e6dc6b0
commit b75fa0fe6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 38 additions and 27 deletions

View File

@ -54,7 +54,7 @@ public class Common {
By tagCount = By.xpath("//div[@data-testid='tag-container']/div/div");
By errorMessage = By.cssSelector("[data-testid='error-message']");
By matchesInDescription = By.xpath("(//div[@data-testid='matches-stats'][1])/span[3]");
By tagCountSearch = By.xpath("(//div[@data-testid='description-text'][1])/div/span/span[@class='text-highlighter']");
By tagCountSearch = By.xpath("(//div[@data-testid='viewer-container'])[1]//span[@class='text-highlighter']");
By tagFilterCount = By.xpath("//div[@data-testid='filter-containers-2']/label");
By noSearchResult = By.cssSelector("[data-testid='no-search-results']");
By resultsCount = By.xpath("//div[@data-testid='search-container']/div");

View File

@ -13,11 +13,11 @@ public class DashboardDetails {
By dashboard = By.xpath("(//button[@data-testid='tab'])[3]");
By editChartDescription = By.xpath("//div[@data-testid='description']/span/span");
By dashboardDescriptionBox = By.xpath("(//div[@data-testid='description']/div/span)[1]");
By dashboardDescriptionBox = By.xpath("//div[@data-testid='viewer-container']/p");
By descriptionBox = By.xpath("(//div[@data-testid='description'])[2]");
By addChartTag = By.xpath("(//span[@data-testid='tags'])[2]");
By selectedTag = By.xpath("//span[@class='tw-no-underline hover:tw-no-underline tw-py-0.5 tw-px-2 tw-pl-2 tw-pr-1']");
By chartTags = By.xpath("//div[@data-testid='tag-container']/div/div");
By breadCrumbTags = By.xpath("//div[@data-testid='breadcrumb-tags']/div");
By breadCrumbTags = By.xpath("//div[@data-testid='entity-tags']/div");
By selectTier = By.cssSelector("[data-testid='select-tier-buuton']");
}

View File

@ -16,8 +16,15 @@ public class DatabaseServicePage {
By deleteIngestion = By.cssSelector("[data-testid='delete']");
By selectInterval = By.xpath("//select[@id='ingestionType']");
By confirmationDeleteText = By.cssSelector("[data-testid='confirmation-text-input']");
By viewService = By.cssSelector("[data-testid='view-service-button']");
By clickDatabase = By.xpath("//tr[@data-testid='column']/td");
By deleteDatabase = By.cssSelector("[data-testid='delete-button']");
public By ingestionInterval(String interval) {
return By.xpath("//select[@id='ingestionType']/option[@value='" + interval + "']");
}
public By serviceName(String serviceName) {
return By.cssSelector("[data-testid='service-name-" + serviceName + "']");
}
}

View File

@ -23,8 +23,8 @@ public class MyDataPage {
By pipelines = By.xpath("//a[@data-testid=\"pipelines\"]");
By services = By.xpath("//a[@data-testid=\"service\"]");
// By ingestion = By.linkText("Ingestion");
By users = By.xpath("//a[@data-testid=\"user\"]");
By teams = By.xpath("//a[@data-testid=\"terms\"]");
By users = By.cssSelector("[data-testid='user']");
By teams = By.cssSelector("[data-testid='terms']");
By searchBox = By.xpath("//input[@data-testid=\"searchBox\"]");
By tableName = By.linkText("dim_address");
By explore = By.xpath("//a[@data-testid=\"appbar-item\"]");

View File

@ -40,7 +40,7 @@ public class TableDetails {
By version = By.xpath("//button[@data-testid=\"version-button\"]");
By versionDetailsGrid = By.xpath("//div[@class=\"tw-grid tw-gap-0.5\"]");
By versionRadioButton = By.xpath("//span[@data-testid=\"select-version\"]");
By descriptionBox = By.xpath("(//div[@data-testid='description']/div/span)[1]");
By descriptionBox = By.xpath("(//div[@data-testid='viewer-container']/p)[1]");
By breadCrumb = By.xpath("//li[@data-testid=\"breadcrumb-link\"]");
By sideDrawerLineage = By.xpath("//header[@class=\"tw-flex tw-justify-between\"]");
By breadCrumbTier = By.xpath("//div[@class=\"tw-flex tw-gap-1 tw-mb-2 tw-mt-1 tw-ml-7 tw-flex-wrap\"]");

View File

@ -14,8 +14,8 @@ public class UserPage {
By rolesList = By.cssSelector("[data-testid='menu-button'][id='menu-button-User']");
By selectUser = By.xpath("//div[@data-testid='data-container']//p");
By userFilterCount = By.xpath("(//span[@data-testid=\"filter-count\"])[9]");
By adminFilterCount = By.xpath("(//span[@data-testid='filter-count'])[10]");
By userFilterCount = By.xpath("//span[@data-testid='filter-count'][text()[contains(.,'101')]]");
By adminFilterCount = By.xpath("//span[@data-testid='filter-count'][text()='1']");
By userListSearchBar = By.cssSelector("[data-testid='searchbar']");
By userListSearchResult =
By.xpath("//div[@data-testid='user-card-container']/div/div[@data-testid='user-card-container']");

View File

@ -306,9 +306,9 @@ class CommonTests {
openHomePage();
Events.sendKeys(webDriver, common.searchBar(), "address"); // Search bar/dim
Events.sendEnter(webDriver, common.searchBar());
Thread.sleep(2000);
Object tagCount = webDriver.findElements(common.tagCountSearch()).size() - 1;
Thread.sleep(2000);
Thread.sleep(waitTime);
Object tagCount = webDriver.findElements(common.tagCountSearch()).size();
Thread.sleep(waitTime);
String matchesInDescription = webDriver.findElement(common.matchesInDescription()).getAttribute("innerHTML");
Assert.assertEquals((tagCount + " in Description,"), matchesInDescription);
}

View File

@ -84,7 +84,7 @@ class UiExceptionHandling {
Events.click(webDriver, common.closeWhatsNew());
Events.click(webDriver, common.headerSettings());
interceptor("/api/v1/teams", "/api/v1/testing");
Events.click(webDriver, common.headerSettingsMenu("Users"));
Events.click(webDriver, common.headerSettingsMenu("Teams & Users"));
Events.click(webDriver, common.closeErrorMessage());
// Assert.assertEquals(400, 400);
}
@ -118,7 +118,7 @@ class UiExceptionHandling {
Events.sendKeys(webDriver, common.servicePort(), "3306");
Events.sendKeys(webDriver, common.databaseName(), "openmetadata_db");
interceptor("services/databaseServices", "services/testing");
Events.click(webDriver, common.saveManage());
Events.click(webDriver, common.saveServiceButton());
// Assert.assertEquals(500, 500);
}

View File

@ -124,7 +124,7 @@ class DashboardDetailsPageTest {
webDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
openExplorePage();
Events.click(webDriver, dashboardDetails.dashboard());
Events.click(webDriver, common.selectTable());
Events.click(webDriver, common.selectTableLink(1));
Events.click(webDriver, common.addTag());
for (int i = 0; i < 3; i++) {
Events.sendKeys(webDriver, common.enterAssociatedTagName(), "P");

View File

@ -35,7 +35,6 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
@ -137,7 +136,7 @@ class DatabaseServicePageTest {
void checkDatabaseServiceDetails() throws InterruptedException {
openDatabaseServicePage();
Thread.sleep(2000);
Events.click(webDriver, common.containsText(serviceName));
Events.click(webDriver, databaseServicePage.serviceName(serviceName));
Events.click(webDriver, common.editTagCategoryDescription());
Events.sendKeys(webDriver, common.focusedDescriptionBox(), faker.address().toString());
Events.click(webDriver, common.editDescriptionSaveButton());
@ -147,22 +146,17 @@ class DatabaseServicePageTest {
@Order(4)
void checkIngestionTab() throws InterruptedException {
openDatabaseServicePage();
Events.click(webDriver, common.containsText(serviceName));
Events.click(webDriver, databaseServicePage.serviceName(serviceName));
Events.click(webDriver, common.ingestion());
try {
WebElement runIngestion =
wait.until(ExpectedConditions.presenceOfElementLocated(databaseServicePage.runIngestion()));
if (runIngestion.isDisplayed()) {
Events.click(webDriver, databaseServicePage.runIngestion()); // run ingestion
}
Events.click(webDriver, databaseServicePage.runIngestion()); // run ingestion
} catch (NoSuchElementException | TimeoutException e) {
Assert.fail("Ingestion is not created");
}
webDriver.navigate().refresh();
Events.click(webDriver, databaseServicePage.editIngestion()); // edit ingestion
Events.click(webDriver, common.nextButton());
Events.click(webDriver, common.deployButton());
Thread.sleep(waitTime);
Events.click(webDriver, databaseServicePage.viewService());
Events.click(webDriver, databaseServicePage.deleteIngestion()); // delete ingestion
Events.sendKeys(webDriver, databaseServicePage.confirmationDeleteText(), "DELETE");
Events.click(webDriver, common.confirmButton());
@ -172,7 +166,7 @@ class DatabaseServicePageTest {
@Order(5)
void checkConnectionConfigTab() throws InterruptedException {
openDatabaseServicePage();
Events.click(webDriver, common.containsText(serviceName));
Events.click(webDriver, databaseServicePage.serviceName(serviceName));
Events.click(webDriver, common.connectionConfig());
Events.sendKeys(webDriver, common.serviceUsername(), "test");
Events.sendKeys(webDriver, common.servicePassword(), "test");
@ -193,6 +187,16 @@ class DatabaseServicePageTest {
@Order(6)
void deleteDatabaseService() throws InterruptedException {
openDatabaseServicePage();
Events.click(webDriver, databaseServicePage.serviceName(serviceName));
Thread.sleep(waitTime);
Events.click(webDriver, databaseServicePage.clickDatabase());
Events.click(webDriver, common.manage());
Events.click(webDriver, databaseServicePage.deleteDatabase());
Events.sendKeys(webDriver, databaseServicePage.confirmationDeleteText(), "DELETE");
Events.click(webDriver, common.confirmButton());
Thread.sleep(waitTime);
Events.click(webDriver, common.headerSettings());
Events.click(webDriver, common.headerSettingsServices());
Events.click(webDriver, common.deleteServiceButton(serviceName));
Events.click(webDriver, common.saveEditedService());
Thread.sleep(waitTime);

View File

@ -128,11 +128,11 @@ class MyDataPageTest {
webDriver.navigate().back();
Events.click(webDriver, myDataPage.users());
url = webDriver.getCurrentUrl();
Assert.assertEquals(url, "http://localhost:8585/user-list");
Assert.assertEquals(url, "http://localhost:8585/teams-and-users/users");
webDriver.navigate().back();
Events.click(webDriver, myDataPage.teams());
url = webDriver.getCurrentUrl();
Assert.assertEquals(url, "http://localhost:8585/teams");
Assert.assertEquals(url, "http://localhost:8585/teams-and-users");
}
@Test