|
|
|
@ -18,6 +18,7 @@ package org.thingsboard.server.msa.ui.base; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import org.openqa.selenium.By; |
|
|
|
import org.openqa.selenium.JavascriptExecutor; |
|
|
|
import org.openqa.selenium.Keys; |
|
|
|
import org.openqa.selenium.WebDriver; |
|
|
|
import org.openqa.selenium.WebDriverException; |
|
|
|
import org.openqa.selenium.WebElement; |
|
|
|
@ -42,7 +43,6 @@ abstract public class AbstractBasePage { |
|
|
|
protected Actions actions; |
|
|
|
protected JavascriptExecutor js; |
|
|
|
|
|
|
|
|
|
|
|
public AbstractBasePage(WebDriver driver) { |
|
|
|
this.driver = driver; |
|
|
|
this.wait = new WebDriverWait(driver, Duration.ofMillis(WAIT_TIMEOUT)); |
|
|
|
@ -154,7 +154,11 @@ abstract public class AbstractBasePage { |
|
|
|
} |
|
|
|
|
|
|
|
public void waitUntilAttributeContains(WebElement element, String attribute, String value) { |
|
|
|
wait.until(ExpectedConditions.attributeContains(element, attribute, value)); |
|
|
|
try { |
|
|
|
wait.until(ExpectedConditions.attributeContains(element, attribute, value)); |
|
|
|
} catch (WebDriverException e) { |
|
|
|
fail("Failed to wait until attribute '" + attribute + "' of element '" + element + "' contains value '" + value + "'"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void goToNextTab(int tabNumber) { |
|
|
|
@ -189,4 +193,25 @@ abstract public class AbstractBasePage { |
|
|
|
public void pull(WebElement element, int xOffset, int yOffset) { |
|
|
|
actions.clickAndHold(element).moveByOffset(xOffset, yOffset).release().perform(); |
|
|
|
} |
|
|
|
|
|
|
|
public void waitUntilAttributeToBe(String locator, String attribute, String value) { |
|
|
|
try { |
|
|
|
wait.until(ExpectedConditions.attributeToBe(By.xpath(locator), attribute, value)); |
|
|
|
} catch (WebDriverException e) { |
|
|
|
fail("Failed to wait until attribute '" + attribute + "' of element located by '" + locator + "' is '" + value + "'"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void clearInputField(WebElement element) { |
|
|
|
element.click(); |
|
|
|
element.sendKeys(Keys.CONTROL + "A" + Keys.BACK_SPACE); |
|
|
|
} |
|
|
|
|
|
|
|
public void waitUntilAttributeToBeNotEmpty(WebElement element, String attribute) { |
|
|
|
try { |
|
|
|
wait.until(ExpectedConditions.attributeToBeNotEmpty(element, attribute)); |
|
|
|
} catch (WebDriverException e) { |
|
|
|
fail("Failed to wait until attribute '" + attribute + "' of element '" + element + "' is not empty"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|