Selenium error fix (#4485)

This commit is contained in:
kshinde2512 2022-04-25 22:56:19 +05:30 committed by GitHub
parent 882ea0f8e7
commit 5108e6aa35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 68 additions and 44 deletions

View File

@ -25,17 +25,17 @@ public final class Events {
private Events() {}
public static void click(WebDriver driver, By by) {
(new WebDriverWait(driver, 30)).until(ExpectedConditions.elementToBeClickable(by));
(new WebDriverWait(driver, 15)).until(ExpectedConditions.elementToBeClickable(by));
driver.findElement(by).click();
}
public static void sendKeys(WebDriver driver, By by, String sendKeys) {
(new WebDriverWait(driver, 30)).until(ExpectedConditions.elementToBeClickable(by));
(new WebDriverWait(driver, 15)).until(ExpectedConditions.elementToBeClickable(by));
driver.findElement(by).sendKeys(sendKeys);
}
public static void sendEnter(WebDriver driver, By by) {
(new WebDriverWait(driver, 30)).until(ExpectedConditions.elementToBeClickable(by));
(new WebDriverWait(driver, 15)).until(ExpectedConditions.elementToBeClickable(by));
driver.findElement(by).sendKeys(Keys.ENTER);
}
}

View File

@ -17,7 +17,7 @@ public class DatabaseServicePage {
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 clickDatabase = By.xpath("//tr[@data-testid='column']/td/a");
By deleteDatabase = By.cssSelector("[data-testid='delete-button']");
public By ingestionInterval(String interval) {

View File

@ -36,6 +36,7 @@ public class TagsPage {
By headerSettingsTags = By.cssSelector("[data-testid='menu-item-Tags']");
By sortBy = By.cssSelector("[data-testid='sortBy']");
By editTags = By.xpath("(//div[@data-testid=\"tag-container\"])[1]");
By editBreadcrumbTag = By.xpath("//div[@data-testid='tag-container']/div/button");
public By tagFilter(String tagCategoryDisplayName, String tagDisplayName) {
return By.cssSelector("[data-testid='checkbox'][id='" + tagCategoryDisplayName + "." + tagDisplayName + "']");

View File

@ -14,14 +14,18 @@ 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'][text()[contains(.,'101')]]");
By userFilterCount = By.xpath("//span[@data-testid='filter-count'][text()='101']");
By adminFilterCount = By.xpath("//span[@data-testid='filter-count'][text()='1']");
By adminFilterCountAfterDelete = By.xpath("//span[@data-testid='filter-count'][text()='0']");
By userListSearchBar = By.cssSelector("[data-testid='searchbar']");
By userListSearchResult =
By.xpath("//div[@data-testid='user-card-container']/div/div[@data-testid='user-card-container']");
By closeCheckBoxDropDown = By.cssSelector("[data-testid='close-dropdown']");
By admin = By.cssSelector("[title='Admins']");
By users = By.cssSelector("[title='Users']");
By editRole = By.cssSelector("[data-testid='edit-roles']");
By saveRole = By.cssSelector("[data-testid='save-roles']");
By removeRole = By.xpath("(//div[@class='css-xb97g8'])[2]");
public By selectRole(String role) {
return By.cssSelector("[data-testid='" + role + "']");

View File

@ -20,6 +20,9 @@ public class Webhooks {
By checkbox = By.xpath("//input[@data-testid='entity-created-checkbox']");
By entityCreatedMenu = By.xpath("(//button[@id='menu-button-select entities'])[1]");
By allEntities = By.xpath("(//input[@type='checkbox'])[2]");
By checkWebhook = By.xpath("//button[@data-testid='webhook-link']");
By toast = By.xpath("(//div[@class='Toastify__toast-body']/div)[2]");
public By checkWebhook(String webHookName) {
return By.xpath("//button[@data-testid='webhook-link'][text()='" + webHookName + "']");
}
}

View File

@ -69,17 +69,17 @@ class WebhooksPageTest {
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.focusedDescriptionBox(), faker.address().toString());
Events.sendKeys(webDriver, webhooks.endpoint(), "https://www.example.com");
Events.click(webDriver, webhooks.checkbox());
Thread.sleep(waitTime);
Events.click(webDriver, webhooks.entityCreatedMenu());
Events.click(webDriver, webhooks.allEntities());
actions.click();
actions.perform();
Events.click(webDriver, common.saveWebhook());
Thread.sleep(2000);
WebElement checkName = wait.until(ExpectedConditions.presenceOfElementLocated(webhooks.checkWebhook()));
Thread.sleep(waitTime);
WebElement checkName = wait.until(ExpectedConditions.presenceOfElementLocated(webhooks.checkWebhook(name)));
Thread.sleep(waitTime);
Assert.assertTrue(checkName.isDisplayed());
Assert.assertEquals(checkName.getText(), name);
}
@ -102,7 +102,7 @@ class WebhooksPageTest {
actions.click();
actions.perform();
Events.click(webDriver, common.saveWebhook());
Thread.sleep(2000);
Thread.sleep(waitTime);
}
WebElement errorMessage = webDriver.findElement(webhooks.toast());
Assert.assertTrue(errorMessage.isDisplayed());

View File

@ -345,7 +345,6 @@ class CommonTests {
Events.sendKeys(webDriver, common.searchBar(), tableName);
Events.click(webDriver, common.searchSuggestion());
Thread.sleep(waitTime);
// actions.moveToElement(webDriver.findElement(common.editAssociatedTagButton())).perform();
Events.click(webDriver, common.editAssociatedTagButton());
Events.click(webDriver, common.enterAssociatedTagName());
for (int i = 0; i <= 2; i++) {
@ -364,7 +363,6 @@ class CommonTests {
Events.click(webDriver, common.saveAssociatedTag());
Thread.sleep(waitTime);
Events.click(webDriver, common.editAssociatedTagButton());
Object tagsCount = webDriver.findElements(common.tagCount()).size();
Events.click(webDriver, common.explore());
Thread.sleep(waitTime);
try {

View File

@ -35,6 +35,7 @@ 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;
@ -188,8 +189,9 @@ class DatabaseServicePageTest {
void deleteDatabaseService() throws InterruptedException {
openDatabaseServicePage();
Events.click(webDriver, databaseServicePage.serviceName(serviceName));
Thread.sleep(waitTime);
Events.click(webDriver, databaseServicePage.clickDatabase());
Thread.sleep(waitTime);
wait.until(ExpectedConditions.urlContains("/database/" + serviceName + ".default"));
Events.click(webDriver, common.manage());
Events.click(webDriver, databaseServicePage.deleteDatabase());
Events.sendKeys(webDriver, databaseServicePage.confirmationDeleteText(), "DELETE");

View File

@ -187,11 +187,6 @@ class GlossaryPageTest {
Events.sendKeys(webDriver, common.urlLink(), faker.address().toString());
Events.sendKeys(webDriver, common.linkText(), faker.address().firstName());
Events.click(webDriver, common.okButton());
Events.click(webDriver, glossary.addReviewerButton());
for (int i = 1; i <= 2; i++) {
Events.click(webDriver, glossary.checkboxAddUser(i));
}
Events.click(webDriver, common.descriptionSaveButton());
Events.click(webDriver, glossary.saveGlossaryTerm());
}
@ -221,9 +216,15 @@ class GlossaryPageTest {
Events.click(webDriver, common.containsText(glossaryName));
Events.click(webDriver, common.containsText(glossaryName));
Events.click(webDriver, common.containsText(termName));
Events.click(webDriver, glossary.reviewers());
Events.click(webDriver, common.manage());
Events.click(webDriver, common.addGlossaryReviewer());
Thread.sleep(waitTime);
Events.click(webDriver, glossary.checkboxAddUser(1));
Thread.sleep(waitTime);
Events.click(webDriver, glossary.checkboxAddUser(2));
Thread.sleep(waitTime);
Events.click(webDriver, glossary.checkboxAddUser(3));
Thread.sleep(waitTime);
Events.click(webDriver, glossary.saveTermReviewer());
Thread.sleep(waitTime);
Object reviewerCount = webDriver.findElements(common.reviewCount()).size();
@ -237,7 +238,7 @@ class GlossaryPageTest {
Events.click(webDriver, common.containsText(glossaryName));
Events.click(webDriver, common.containsText(glossaryName));
Events.click(webDriver, common.containsText(termName));
Events.click(webDriver, glossary.reviewers());
Events.click(webDriver, common.manage());
Thread.sleep(waitTime);
actions.moveToElement(webDriver.findElement(common.removeAssociatedTag())).perform();
Events.click(webDriver, common.removeAssociatedTag());
@ -253,13 +254,12 @@ class GlossaryPageTest {
Events.click(webDriver, common.containsText(glossaryName));
Events.click(webDriver, common.containsText(glossaryName));
Events.click(webDriver, common.containsText(termName));
Events.click(webDriver, glossary.reviewers());
Events.click(webDriver, common.addGlossaryReviewer());
Events.click(webDriver, common.manage());
actions.moveToElement(webDriver.findElement(common.removeAssociatedTag())).perform();
for (int i = 1; i <= 2; i++) {
Events.click(webDriver, glossary.checkboxAddUser(i));
}
Events.click(webDriver, glossary.saveTermReviewer());
Events.click(webDriver, common.removeAssociatedTag());
Thread.sleep(waitTime);
}
Object reviewerCount = webDriver.findElements(common.reviewCount()).size();
Assert.assertEquals(reviewerCount.toString(), "0");
}

View File

@ -102,7 +102,7 @@ class RolesPageTest {
openRolesPage();
Events.click(webDriver, common.containsText(roleName));
Events.click(webDriver, common.editTagCategoryDescription());
Events.sendKeys(webDriver, common.focusedDescriptionBox(), Keys.COMMAND + "A");
Events.sendKeys(webDriver, common.focusedDescriptionBox(), Keys.CONTROL + "A");
Events.sendKeys(webDriver, common.focusedDescriptionBox(), description);
Events.click(webDriver, common.editDescriptionSaveButton());
webDriver.navigate().refresh();

View File

@ -187,7 +187,7 @@ class TagsPageTest {
} catch (TimeoutException e) {
Assert.fail("Table is not present for the selected tag filter");
}
Events.click(webDriver, common.editAssociatedTagButton());
Events.click(webDriver, tagsPage.editBreadcrumbTag());
Events.click(webDriver, tagsPage.removeAssociatedTag());
Events.click(webDriver, common.saveAssociatedTag());
}
@ -219,7 +219,17 @@ class TagsPageTest {
@Test
@Order(11)
void TagUsageCheck() throws InterruptedException {
openTagsPage();
Events.click(webDriver, common.closeWhatsNew());
Events.click(webDriver, common.headerItem("explore"));
Events.click(webDriver, tagsPage.lastTableLink());
Thread.sleep(waitTime);
Events.click(webDriver, tagsPage.editTags());
Events.click(webDriver, common.enterAssociatedTagName());
Events.sendKeys(webDriver, common.enterAssociatedTagName(), "P");
Events.click(webDriver, common.tagListItem());
Events.click(webDriver, common.saveAssociatedTag());
Events.click(webDriver, common.headerSettings());
Events.click(webDriver, tagsPage.headerSettingsTags());
Events.click(webDriver, common.containsText("PersonalData"));
Events.click(webDriver, tagsPage.usageCountElementIndex(1));
Thread.sleep(2000);

View File

@ -196,6 +196,7 @@ class TeamsPageTest {
// Select the created listed team
Events.click(webDriver, common.containsText(teamDisplayName));
// Events.click(webDriver,teamsPage.getAsset());
Events.click(webDriver, common.manage());
Events.click(webDriver, teamsPage.ownerDropdown());
String ownerName = webDriver.findElement(teamsPage.selectOwner()).getText();
Events.click(webDriver, teamsPage.selectOwner());

View File

@ -61,12 +61,15 @@ class UsersPageTest {
openUsersPage();
Events.click(webDriver, userPage.users());
Events.click(webDriver, userPage.selectUser());
Events.click(webDriver, userPage.rolesList());
Events.click(webDriver, userPage.selectRole("Admin"));
actions.moveToElement(userPage.closeCheckBoxDropDown(), 100, 200);
actions.click();
actions.perform();
Events.click(webDriver, common.descriptionSaveButton());
Events.click(webDriver, userPage.editRole());
Events.click(webDriver, common.containsText("Data Consumer"));
Events.click(webDriver, common.containsText("Admin"));
Events.click(webDriver, userPage.saveRole());
Thread.sleep(waitTime);
Events.click(webDriver, common.headerSettings());
Events.click(webDriver, common.headerSettingsTeams());
Events.click(webDriver, userPage.users());
webDriver.navigate().refresh();
Thread.sleep(waitTime);
Object afterUsersCount = webDriver.findElement(userPage.userFilterCount()).getAttribute("innerHTML");
Thread.sleep(waitTime);
@ -81,15 +84,17 @@ class UsersPageTest {
openUsersPage();
Events.click(webDriver, userPage.users());
Events.click(webDriver, userPage.selectUser());
Events.click(webDriver, userPage.rolesList());
Events.click(webDriver, userPage.selectRole("Admin"));
actions.moveToElement(userPage.closeCheckBoxDropDown(), 100, 200);
actions.click();
actions.perform();
Events.click(webDriver, common.descriptionSaveButton());
Thread.sleep(1000);
Object afterAdminCount = webDriver.findElement(userPage.adminFilterCount()).getAttribute("innerHTML");
Thread.sleep(1000);
Events.click(webDriver, userPage.editRole());
Events.click(webDriver, userPage.removeRole());
Events.click(webDriver, userPage.saveRole());
Thread.sleep(waitTime);
Events.click(webDriver, common.headerSettings());
Events.click(webDriver, common.headerSettingsTeams());
Events.click(webDriver, userPage.users());
webDriver.navigate().refresh();
Thread.sleep(waitTime);
Object afterAdminCount = webDriver.findElement(userPage.adminFilterCountAfterDelete()).getAttribute("innerHTML");
Thread.sleep(waitTime);
Assert.assertEquals(afterAdminCount, "0");
Object afterUsersCount = webDriver.findElement(userPage.userFilterCount()).getAttribute("innerHTML");
Assert.assertEquals(afterUsersCount, "101");