2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.utilities;
23 import java.awt.AWTException;
24 import java.awt.Robot;
25 import java.awt.Toolkit;
26 import java.awt.datatransfer.Clipboard;
27 import java.awt.datatransfer.StringSelection;
28 import java.awt.event.KeyEvent;
30 import java.io.IOException;
31 import java.util.ArrayList;
32 import java.util.List;
33 import java.util.Random;
34 import java.util.UUID;
35 import java.util.concurrent.TimeUnit;
36 import java.util.function.Supplier;
38 import org.apache.commons.io.FileUtils;
39 import org.openecomp.sdc.ci.tests.datatypes.CatalogFilterTitlesEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
41 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.DashboardCardEnum;
42 import org.openecomp.sdc.ci.tests.execute.setup.DriverFactory;
43 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
44 import org.openqa.selenium.By;
45 import org.openqa.selenium.JavascriptExecutor;
46 import org.openqa.selenium.Keys;
47 import org.openqa.selenium.NoSuchElementException;
48 import org.openqa.selenium.OutputType;
49 import org.openqa.selenium.TakesScreenshot;
50 import org.openqa.selenium.WebDriver;
51 import org.openqa.selenium.WebElement;
52 import org.openqa.selenium.firefox.FirefoxDriver;
53 import org.openqa.selenium.interactions.Actions;
54 import org.openqa.selenium.support.ui.ExpectedCondition;
55 import org.openqa.selenium.support.ui.ExpectedConditions;
56 import org.openqa.selenium.support.ui.FluentWait;
57 import org.openqa.selenium.support.ui.Select;
58 import org.openqa.selenium.support.ui.WebDriverWait;
60 import com.aventstack.extentreports.Status;
63 public final class GeneralUIUtils {
65 public static final String FILE_NAME = "Valid_tosca_Mycompute.yml";
67 private static int timeOut=(int) (60*1.5);
69 // public static void setTimeOut(int time) {
78 /**************** DRIVER ****************/
80 public static WebDriver getDriver() {
82 return DriverFactory.getDriver();
89 /****************************************/
91 public static List<WebElement> getElemenetsFromTable(By by) {
92 return getDriver().findElements(by);
95 public static File takeScreenshot(String screenshotFilename, String dir, String testName) throws IOException {
96 if (screenshotFilename == null) {
97 if (testName != null){
98 screenshotFilename = testName;
102 screenshotFilename = UUID.randomUUID().toString();
106 File scrFile = ((TakesScreenshot) getDriver()).getScreenshotAs(OutputType.FILE);
107 File filePath = new File(String.format("%s/%s.png", dir, screenshotFilename));
108 new File(dir).mkdirs();
109 FileUtils.copyFile(scrFile, filePath);
111 } catch (IOException e1) {
112 e1.printStackTrace();
117 public static File takeScreenshot(String screenshotFilename, String dir) throws IOException{
118 return takeScreenshot(screenshotFilename, dir, null);
122 public static void scrollDown() {
124 Robot robot = new Robot();
125 robot.keyPress(KeyEvent.VK_DOWN);
126 robot.keyRelease(KeyEvent.VK_DOWN);
127 GeneralUIUtils.waitForLoader();
134 public static void minimizeCatalogFilterByTitle(CatalogFilterTitlesEnum titlesEnum) {
136 switch (titlesEnum) {
138 GeneralUIUtils.getWebElementByTestID(titlesEnum.getValue()).click();
141 GeneralUIUtils.getWebElementByTestID(titlesEnum.getValue()).click();
144 GeneralUIUtils.getWebElementByTestID(titlesEnum.getValue()).click();
152 public static WebElement getWebElementByTestID(String dataTestId) {
153 return getWebElementByTestID(dataTestId, timeOut);
156 public static WebElement getWebElementByTestID(String dataTestId, int timeout) {
157 WebDriverWait wait = new WebDriverWait(getDriver(), timeout);
158 return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + dataTestId + "']")));
161 public static boolean isWebElementExistByTestId(String dataTestId) {
162 if(getDriver().findElements(By.xpath("//*[@data-tests-id='" + dataTestId + "']")).size() == 0) {
168 public static WebElement getInputElement(String dataTestId) {
171 return getDriver().findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']"));
178 public static List<WebElement> getInputElements(String dataTestId) {
180 return getDriver().findElements(By.xpath("//*[@data-tests-id='" + dataTestId + "']"));
184 public static WebElement getWebElementBy(By by) {
185 return getWebElementBy(by, timeOut);
188 public static WebElement getWebElementBy(By by, int timeOut) {
189 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
190 return wait.until(ExpectedConditions.visibilityOfElementLocated(by));
193 public static List<String> getWebElementListText(List<WebElement>elements) {
194 List<String>Text=new ArrayList<>();
195 for (WebElement webElement : elements) {
196 Text.add(webElement.getText());
202 public static List<WebElement> getWebElementsListBy(By by) {
203 return getWebElementsListBy(by, timeOut);
206 public static List<WebElement> getWebElementsListBy(By by, int timeOut) {
207 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
208 return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(by));
211 public static List<WebElement> getWebElementsListByContainTestID(String dataTestId) {
213 WebDriverWait wait = new WebDriverWait(getDriver(), 10);
214 return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//*[contains(@data-tests-id, '"+dataTestId+"')]")));
217 return new ArrayList<WebElement>();
221 public static List<WebElement> getWebElementsListByContainsClassName(String containedText) {
222 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
223 return wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//*[contains(@class, '"+containedText+"')]")));
226 public static WebElement getWebElementByContainsClassName(String containedText) {
227 return getWebElementBy(By.xpath("//*[contains(@class, '"+containedText+"')]"));
230 public static WebElement getWebElementByClassName(String className) {
231 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
232 return wait.until(ExpectedConditions.visibilityOfElementLocated(By.className(className)));
235 public static WebElement getWebElementByLinkText(String linkText) {
236 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
237 return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@text='" + linkText + "']")));
241 public static List<WebElement> getWebElementsListByTestID(String dataTestId) {
242 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
243 return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[@data-tests-id='" + dataTestId + "']")));
246 public static List<WebElement> getWebElementsListByClassName(String className) {
247 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
248 return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className(className)));
254 public static Boolean isElementInvisibleByTestId(String dataTestId) {
255 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
257 ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + dataTestId + "']")));
260 public static Boolean isElementVisibleByTestId(String dataTestId) {
262 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
263 if(wait.until(ExpectedConditions.visibilityOfElementLocated((By.xpath("//*[@data-tests-id='" + dataTestId + "']")))).isDisplayed()){
274 public static void clickOnElementByTestId(String dataTestId) {
275 clickOnElementByTestIdWithoutWait(dataTestId);
279 public static void clickOnElementByTestIdWithoutWait(String dataTestId) {
280 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
281 wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))).click();
284 public static void clickOnElementByTestId(String dataTestId, int customTimeout) {
285 WebDriverWait wait = new WebDriverWait(getDriver(), customTimeout);
286 wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))).click();
289 public static WebElement waitForElementVisibilityByTestId(String dataTestId) {
290 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
291 return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + dataTestId + "']")));
294 public static Boolean waitForElementInVisibilityByTestId(String dataTestId) {
295 return waitForElementInVisibilityByTestId(dataTestId, timeOut);
298 public static Boolean waitForElementInVisibilityByTestId(String dataTestId, int timeOut) {
299 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
300 boolean displayed = getDriver().findElements(By.xpath("//*[@data-tests-id='" + dataTestId + "']")).isEmpty();
302 Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@data-tests-id='" + dataTestId + "'])")));
309 public static Boolean waitForElementInVisibilityByTestId(By by) {
310 return waitForElementInVisibilityBy(by, timeOut);
314 public static Boolean waitForElementInVisibilityBy(By by, int timeOut) {
315 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
316 boolean displayed = getDriver().findElements(by).isEmpty();
318 Boolean until = wait.until(ExpectedConditions.invisibilityOfElementLocated(by));
326 public static void setWebElementByTestId(String elemetID, String value) {
327 WebElement resourceDescriptionTextbox = GeneralUIUtils.getWebElementByTestID(elemetID);
328 resourceDescriptionTextbox.clear();
329 resourceDescriptionTextbox.sendKeys(value);
333 public static WebElement hoverOnAreaByTestId(String areaId) {
334 Actions actions = new Actions(getDriver());
335 WebElement area = getWebElementByTestID(areaId);
336 actions.moveToElement(area).perform();
341 public static WebElement hoverOnAreaByClassName(String className) {
342 Actions actions = new Actions(getDriver());
343 WebElement area = getWebElementByClassName(className);
344 actions.moveToElement(area).perform();
345 GeneralUIUtils.ultimateWait();
349 public static void clickElementUsingActions(WebElement element){
350 Actions actions = new Actions(getDriver());
352 actions.moveToElement(element);
361 public static void waitForLoader() {
362 waitForLoader(timeOut);
365 public static void waitForLoader(int timeOut) {
367 waitForElementInVisibilityBy(By.className("tlv-loader"), timeOut);
370 public static void findComponentAndClick(String resourceName) throws Exception {
371 SetupCDTest.getExtendTest().log(Status.INFO, "Searching for " + resourceName + " in homepage");
372 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue());
374 searchTextbox.clear();
375 searchTextbox.sendKeys(resourceName);
379 SetupCDTest.getExtendTest().log(Status.INFO, "Can't interact with search bar");
385 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Clicking on the %s component from home screen", resourceName));
386 clickOnElementByTestId(resourceName);
387 GeneralUIUtils.ultimateWait();
388 getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.LIFECYCLE_STATE.getValue());
391 SetupCDTest.getExtendTest().log(Status.INFO, "Can't click on component named " + resourceName);
397 public static String getComponentVersion(String componentName) {
398 return GeneralUIUtils.getWebElementByTestID(componentName + "Version").getText();
401 public static void windowZoomOut() {
402 final int zoomOutFactor = 3;
403 for (int i = 0; i < zoomOutFactor; i++) {
404 if(getDriver() instanceof FirefoxDriver) {
405 getDriver().findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT));
410 public static void resetZoom(){
411 getDriver().findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, "0"));
414 public static void windowZoomOutUltimate(){
417 // JavascriptExecutor js = (JavascriptExecutor) driver;
418 // js.executeScript("document.body.style.zoom='90%'");
421 public static void clickASDCLogo() {
422 WebDriverWait wait = new WebDriverWait(getDriver(), 15);
423 wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("ASDC")));
424 WebElement ClickASDCLogo = getDriver().findElement(By.linkText("ASDC"));
425 ClickASDCLogo.click();
426 GeneralUIUtils.waitForLoader();
429 public static void sleep(int duration) {
431 Thread.sleep(duration);
432 } catch (InterruptedException e) {
433 throw new RuntimeException(e);
437 public static void moveToStep(DataTestIdEnum.StepsEnum Stepname) {
438 moveToStep(Stepname.getValue());
439 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Going to %s page ", Stepname.toString()));
442 public static void moveToStep(String dataTestId) {
443 clickOnElementByTestId(dataTestId);
448 public static Select getSelectList(String item, String datatestsid) {
449 Select selectlist = new Select(getWebElementByTestID(datatestsid));
451 selectlist.selectByVisibleText(item);
456 public static List<WebElement> waitForElementsListVisibilityTestMethod(DashboardCardEnum dataTestId) {
457 GeneralUIUtils.waitForLoader();
458 return getDriver().findElements(By.xpath("//*[@data-tests-id='" + dataTestId.getValue() + "']"));
461 public static List<WebElement> getElementsByCSS(String cssString) throws InterruptedException {
462 GeneralUIUtils.waitForLoader();
463 List<WebElement> assets = getDriver().findElements(By.cssSelector(cssString));
467 public static WebElement getElementfromElementByCSS(WebElement parentElement, String cssString){
468 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
469 GeneralUIUtils.waitForLoader();
470 return parentElement.findElement(By.cssSelector(cssString));
473 public static WebElement getElementfromElementByXPATH(WebElement parentElement, DashboardCardEnum dataTestId){
474 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
475 GeneralUIUtils.waitForLoader();
476 return HighlightMyElement( parentElement.findElement(By.xpath("//*[@data-tests-id='" + dataTestId.getValue() + "']")));
479 public static WebElement HighlightMyElement(WebElement element) {
480 JavascriptExecutor javascript = (JavascriptExecutor) getDriver();
481 javascript.executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "color: yellow; border: 4px solid yellow;");
485 public static WebElement getSelectedElementFromDropDown(String dataTestId){
486 GeneralUIUtils.ultimateWait();;
487 WebElement selectedElement = new Select (getDriver().findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']"))).getFirstSelectedOption();
488 return selectedElement;
492 public static void waitForPageLoadByReadyState() {
493 new WebDriverWait(getDriver(), 30).until((ExpectedCondition<Boolean>) wd ->
494 ((JavascriptExecutor) wd).executeScript("return document.readyState").equals("complete"));
498 public static boolean checkElementsCountInTable(int expectedElementsCount, Supplier<List<WebElement>> func) {
499 int maxWaitingPeriodMS = 10 * 1000;
500 int napPeriodMS = 100;
501 int sumOfWaiting = 0;
502 List<WebElement> elements = null;
503 boolean isKeepWaiting = false;
504 while (!isKeepWaiting) {
505 elements = func.get();
506 isKeepWaiting = (expectedElementsCount == elements.size());
508 sumOfWaiting += napPeriodMS;
509 if (sumOfWaiting > maxWaitingPeriodMS)
515 public static String getActionDuration(Runnable func) throws Exception{
516 long startTime = System.nanoTime();
518 long estimateTime = System.nanoTime();
519 long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime);
520 String durationString = String.format("%02d:%02d", duration / 60, duration % 60);
521 return durationString;
524 public static WebElement clickOnAreaJS(String areaId) {
525 return clickOnAreaJS(areaId, timeOut);
529 public static WebElement clickOnAreaJS(String areaId, int timeout) {
532 WebElement area = getWebElementByTestID(areaId);
533 JavascriptExecutor javascript = (JavascriptExecutor) getDriver();
534 //HighlightMyElement(area);
535 Object executeScript = javascript.executeScript("arguments[0].click();", area, "color: yellow; border: 4px solid yellow;");
536 waitForLoader(timeout);
547 public static WebElement clickOnAreaJS(WebElement areaId) throws InterruptedException {
548 JavascriptExecutor javascript = (JavascriptExecutor) getDriver();
549 //HighlightMyElement(area);
550 javascript.executeScript("arguments[0].click();", areaId, "color: yellow; border: 4px solid yellow;");
556 public static void clickSomewhereOnPage() {
557 getDriver().findElement(By.cssSelector(".asdc-app-title")).click();
560 public static void findComponentAndClickInCatalog(String resourceName) throws Exception {
561 // This method will find element by element name, don't use data-tests-id argument
562 WebElement searchTextbox = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtons.SEARCH_BOX.getValue());
563 searchTextbox.clear();
564 searchTextbox.sendKeys(resourceName);
566 clickOnElementByText(resourceName);
570 public static void clickOnElementByText(String textInElement) {
571 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
572 HighlightMyElement(wait.until(
573 ExpectedConditions.elementToBeClickable(findByText(textInElement)))).click();
576 public static void clickOnElementByText(String textInElement, int customTimeout) {
577 WebDriverWait wait = new WebDriverWait(getDriver(), customTimeout);
578 HighlightMyElement(wait.until(
579 ExpectedConditions.elementToBeClickable(findByText(textInElement)))).click();
582 public static void clickJSOnElementByText(String textInElement) throws Exception {
583 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
584 clickOnAreaJS(wait.until(
585 ExpectedConditions.elementToBeClickable(findByText(textInElement))));
588 public static void fluentWaitTestID(String dataTestId, String text) {
589 FluentWait<WebDriver> fluentWait = new FluentWait<WebDriver>(getDriver())
590 .withTimeout(30, TimeUnit.SECONDS)
591 .pollingEvery(50, TimeUnit.MILLISECONDS)
592 .ignoring(NoSuchElementException.class);
594 fluentWait.until(ExpectedConditions.refreshed(
595 ExpectedConditions.textToBePresentInElementValue(By.xpath("//*[@data-tests-id='" + dataTestId + "']"), text)));
598 public static void regularWait(WebElement element, String text){
599 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
601 wait.until(ExpectedConditions.textToBePresentInElementValue(element, text));
604 public static void waitForAngular(){
605 WebDriverWait wait = new WebDriverWait(getDriver(), 90, 100);
606 wait.until(AdditionalConditions.pageLoadWait());
607 wait.until(AdditionalConditions.angularHasFinishedProcessing());
610 public static Object getAllElementAttributes(WebElement element) {
611 return ((JavascriptExecutor)getDriver()).executeScript("var s = []; var attrs = arguments[0].attributes; for (var l = 0; l < attrs.length; ++l) { var a = attrs[l]; s.push(a.name + ':' + a.value); } ; return s;", element);
614 public static boolean isElementReadOnly(WebElement element){
616 HighlightMyElement(element).clear();
618 } catch (Exception e) {
623 public static boolean isElementReadOnly(String dataTestId){
624 return isElementReadOnly(
625 waitForElementVisibilityByTestId(dataTestId));
628 public static boolean isElementDisabled(WebElement element){
629 return HighlightMyElement(element).getAttribute("class").contains("view-mode") ||
630 element.getAttribute("class").contains("disabled");
633 public static boolean isElementDisabled(String dataTestId){
634 return isElementDisabled(
635 waitForElementVisibilityByTestId(dataTestId));
638 public static void ultimateWait(){
639 long startTime = System.nanoTime();
641 GeneralUIUtils.waitForLoader();
642 GeneralUIUtils.waitForBackLoader();
643 GeneralUIUtils.waitForAngular();
645 long estimateTime = System.nanoTime();
646 long duration = TimeUnit.NANOSECONDS.toSeconds(estimateTime - startTime);
647 // System.out.println("UltimateWait took: "+ duration);
648 if(duration > timeOut){
649 SetupCDTest.getExtendTest().log(Status.WARNING, String.format("Delays on page, %d seconds", duration));
651 // waitForUINotification();
654 public static WebElement makeElementVisibleWithJS(WebElement element){
655 String js = "arguments[0].style.height='auto'; arguments[0].style.visibility='visible';";
656 ((JavascriptExecutor) getDriver()).executeScript(js, element);
660 public static WebElement unhideElement(WebElement element, String attributeValue){
661 String js = "arguments[0].setAttribute('class','" + attributeValue + "');";
662 ((JavascriptExecutor) getDriver()).executeScript(js, element);
666 public static WebElement findByText(String textInElement){
667 return getDriver().findElement(searchByTextContaining(textInElement));
669 public static By searchByTextContaining(String textInElement) {
670 return By.xpath("//*[contains(text(),'" + textInElement + "')]");
674 public static boolean findAndWaitByText(String textInElement, int timeout){
676 WebDriverWait wait = new WebDriverWait(getDriver(), timeout);
677 wait.until(ExpectedConditions.presenceOfElementLocated(searchByTextContaining(textInElement)));
685 public static WebElement getClickableButtonBy(By by, int timout){
687 WebDriverWait wait = new WebDriverWait(getDriver(), timout);
688 WebElement element = wait.until(ExpectedConditions.elementToBeClickable(by));
698 public static WebElement getButtonWithText(String textInButton){
700 return getDriver().findElement(By.xpath("//button[contains(text(),'" + textInButton + "')]"));
709 public static List<WebElement> getElementsByDataTestsIdStartWith(String startWithString){
711 return getDriver().findElements(By.xpath("//*[starts-with(@data-tests-id,'" + startWithString + "')]"));
714 public static void closeErrorMessage() {
715 WebElement okWebElement = getButtonWithText("OK");
716 if (okWebElement != null){
717 okWebElement.click();
722 public static WebElement getElementByCSS(String cssString) throws InterruptedException {
724 return getDriver().findElement(By.cssSelector(cssString));
727 public static String getDataTestIdAttributeValue(WebElement element) {
728 return element.getAttribute("data-tests-id");
731 public static String getTextContentAttributeValue(WebElement element) {
732 return element.getAttribute("textContent");
735 public static WebElement getElementInsideElementByDataTestsId(WebElement element, String dataTestId) {
737 return element.findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']"));
744 public static void clickOnElementByCSS(String cssString) throws Exception {
745 WebDriverWait wait = new WebDriverWait(getDriver(), timeOut);
746 wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(cssString))).click();
749 public static String getRandomComponentName(String prefix) {
750 return prefix + GeneralUIUtils.randomNumber();
752 public static int randomNumber() {
753 Random r = new Random();
754 return r.nextInt(10000);
757 public static void waitForUINotification() {
758 List<WebElement> notificationElements = getDriver().findElements(By.className("ui-notification"));
759 if (!notificationElements.isEmpty()){
760 notificationElements.forEach(WebElement::click);
764 public static boolean checkForDisabledAttribute(String dataTestId){
765 Object elementAttributes = getAllElementAttributes(waitForElementVisibilityByTestId(dataTestId));
766 return elementAttributes.toString().contains("disabled");
769 public static void dragAndDropElementByY(WebElement area, int yOffset) {
770 Actions actions = new Actions(getDriver());
771 actions.dragAndDropBy(area, 10, yOffset).perform();
775 public static void waitForBackLoader() {
776 waitForBackLoader(timeOut);
779 public static void waitForBackLoader(int timeOut) {
781 waitForElementInVisibilityBy(By.className("tlv-loader-back"), timeOut);
784 public static void addStringtoClipboard(String text){
785 StringSelection selection = new StringSelection(text);
786 Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
787 clipboard.setContents(selection, selection);