fix locators, fix flaky tests with ElementClickInterceptedException

This commit is contained in:
Seraphym-Tuhai 2023-03-09 18:37:13 +02:00
parent 3f28eca3b8
commit e99024d7eb
8 changed files with 12 additions and 15 deletions

View File

@ -18,7 +18,6 @@ package org.thingsboard.server.msa.ui.base;
import io.github.bonigarcia.wdm.WebDriverManager;
import io.qameta.allure.Allure;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
@ -48,7 +47,6 @@ import java.io.ByteArrayInputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static org.thingsboard.server.msa.TestProperties.getBaseUiUrl;
@ -87,7 +85,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
@BeforeMethod
public void open() {
openHomePage();
openLocalhost();
}
@AfterMethod
@ -101,12 +99,13 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
driver.quit();
}
public void openLocalhost() {
driver.get(getBaseUiUrl());
public String getJwtTokenFromLocalStorage() {
js = (JavascriptExecutor) driver;
return (String) js.executeScript("return window.localStorage.getItem('jwt_token');");
}
public void openHomePage() {
driver.get(getBaseUiUrl() + "/home");
public void openLocalhost() {
driver.get(getBaseUiUrl());
}
public String getUrl() {

View File

@ -114,9 +114,7 @@ public class CustomerPageHelper extends CustomerPageElements {
public void chooseDashboard() {
editMenuDashboardField().click();
sleep(0.5);
editMenuDashboard().click();
sleep(0.5);
}
public void createCustomersUser() {

View File

@ -35,7 +35,7 @@ public class RuleChainsPageElements extends OtherPageElementsHelper {
private static final String DELETE_RULE_CHAIN_FROM_VIEW_BTN = "//span[contains(text(),' Delete')]";
private static final String IMPORT_RULE_CHAIN_BTN = "//span[contains(text(),'Import rule chain')]";
private static final String OPEN_RULE_CHAIN_FROM_VIEW = "//span[contains(text(),'Open rule chain')]";
private static final String MAKE_ROOT_FROM_VIEW = "(//span[contains(text(),' Make rule chain root ')]/..)[1]";
private static final String MAKE_ROOT_FROM_VIEW = "//span[contains(text(),' Make rule chain root ')]/parent::button";
private static final String ROOT_ACTIVE_CHECKBOXES = "//mat-icon[text() = 'check_box']";
private static final String ALL_NAMES = "//mat-icon[contains(text(),'check')]/../../../mat-cell[contains(@class,'name')]/span";

View File

@ -63,7 +63,7 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest {
@BeforeMethod
public void reLogin() {
if (getUrl().contains("/login")) {
if (getJwtTokenFromLocalStorage() == null) {
loginPage.authorizationTenant();
}
}

View File

@ -55,7 +55,7 @@ public class ManageCustomersDevicesTest extends AbstractDriverBaseTest {
sideBarMenuView.customerBtn().click();
customerPage.setCustomerName();
customerPage.entity(customerPage.getCustomerName()).click();
customerPage.manageCustomersDeviceBtnView().click();
jsClick(customerPage.manageCustomersDeviceBtnView());
Assert.assertTrue(urlContains(manage.toLowerCase()));
Assert.assertNotNull(customerPage.customerDevicesIconHeader());

View File

@ -56,7 +56,7 @@ public class ManageCustomersEdgesTest extends AbstractDriverBaseTest {
sideBarMenuView.customerBtn().click();
customerPage.setCustomerName();
customerPage.entity(customerPage.getCustomerName()).click();
customerPage.manageCustomersEdgeBtnView().click();
jsClick(customerPage.manageCustomersEdgeBtnView());
Assert.assertTrue(urlContains("edgeInstances"));
Assert.assertNotNull(customerPage.customerEdgeIconHeader());

View File

@ -56,7 +56,7 @@ public class ManageCustomersUsersTest extends AbstractDriverBaseTest {
sideBarMenuView.customerBtn().click();
customerPage.setCustomerName();
customerPage.entity(customerPage.getCustomerName()).click();
customerPage.manageCustomersUserBtnView().click();
jsClick(customerPage.manageCustomersUserBtnView());
Assert.assertTrue(urlContains("user"));
Assert.assertNotNull(customerPage.customerUserIconHeader());

View File

@ -75,7 +75,7 @@ public class MakeRuleChainRootTest extends AbstractDriverBaseTest {
ruleChainsPage.setRuleChainNameWithoutRoot(0);
String ruleChain = ruleChainsPage.getRuleChainName();
ruleChainsPage.detailsBtn(ruleChain).click();
ruleChainsPage.makeRootFromViewBtn().click();
jsClick(ruleChainsPage.makeRootFromViewBtn());
ruleChainsPage.warningPopUpYesBtn().click();
ruleChainsPage.closeEntityViewBtn().click();