How to use doAction method of com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement class

Best Carina code snippet using com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.doAction

Source:ExtendedWebElement.java Github

copy

Full Screen

...407 *408 * @return String text409 */410 public String getText() {411 return (String) doAction(ACTION_NAME.GET_TEXT, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()));412 }413 /**414 * Get element location.415 *416 * @return Point location417 */418 public Point getLocation() {419 return (Point) doAction(ACTION_NAME.GET_LOCATION, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()));420 }421 /**422 * Get element size.423 *424 * @return Dimension size425 */426 public Dimension getSize() {427 return (Dimension) doAction(ACTION_NAME.GET_SIZE, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()));428 }429 /**430 * Get element attribute.431 *432 * @param name of attribute433 * @return String attribute value434 */435 public String getAttribute(String name) {436 return (String) doAction(ACTION_NAME.GET_ATTRIBUTE, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()), name);437 }438 /**439 * Click on element.440 */441 public void click() {442 click(EXPLICIT_TIMEOUT);443 }444 /**445 * Click on element.446 *447 * @param timeout to wait448 */449 public void click(long timeout) {450 click(timeout, getDefaultCondition(getBy()));451 }452 453 /**454 * Click on element.455 *456 * @param timeout to wait457 * @param waitCondition458 * to check element conditions before action459 */460 public void click(long timeout, ExpectedCondition<?> waitCondition) {461 doAction(ACTION_NAME.CLICK, timeout, waitCondition);462 }463 464 /**465 * Click on element by javascript.466 */467 public void clickByJs() {468 clickByJs(EXPLICIT_TIMEOUT);469 }470 /**471 * Click on element by javascript.472 *473 * @param timeout to wait474 */475 public void clickByJs(long timeout) {476 clickByJs(timeout, getDefaultCondition(getBy()));477 }478 479 /**480 * Click on element by javascript.481 *482 * @param timeout to wait483 * @param waitCondition484 * to check element conditions before action485 */486 public void clickByJs(long timeout, ExpectedCondition<?> waitCondition) {487 doAction(ACTION_NAME.CLICK_BY_JS, timeout, waitCondition);488 }489 490 /**491 * Click on element by Actions.492 */493 public void clickByActions() {494 clickByActions(EXPLICIT_TIMEOUT);495 }496 /**497 * Click on element by Actions.498 *499 * @param timeout to wait500 */501 public void clickByActions(long timeout) {502 clickByActions(timeout, getDefaultCondition(getBy()));503 }504 505 /**506 * Click on element by Actions.507 *508 * @param timeout to wait509 * @param waitCondition510 * to check element conditions before action511 */512 public void clickByActions(long timeout, ExpectedCondition<?> waitCondition) {513 doAction(ACTION_NAME.CLICK_BY_ACTIONS, timeout, waitCondition);514 }515 516 /**517 * Double Click on element.518 */519 public void doubleClick() {520 doubleClick(EXPLICIT_TIMEOUT);521 }522 523 /**524 * Double Click on element.525 *526 * @param timeout to wait527 */528 public void doubleClick(long timeout) {529 doubleClick(timeout, getDefaultCondition(getBy()));530 }531 /**532 * Double Click on element.533 *534 * @param timeout to wait535 * @param waitCondition536 * to check element conditions before action537 */538 public void doubleClick(long timeout, ExpectedCondition<?> waitCondition) {539 doAction(ACTION_NAME.DOUBLE_CLICK, timeout, waitCondition);540 }541 542 /**543 * Mouse RightClick on element.544 */545 public void rightClick() {546 rightClick(EXPLICIT_TIMEOUT);547 }548 549 /**550 * Mouse RightClick on element.551 *552 * @param timeout to wait553 */554 public void rightClick(long timeout) {555 rightClick(timeout, getDefaultCondition(getBy()));556 }557 558 /**559 * Mouse RightClick on element.560 *561 * @param timeout to wait562 * @param waitCondition563 * to check element conditions before action564 */565 public void rightClick(long timeout, ExpectedCondition<?> waitCondition) {566 doAction(ACTION_NAME.RIGHT_CLICK, timeout, waitCondition);567 }568 569 /**570 * MouseOver (Hover) an element.571 */572 public void hover() {573 hover(null, null);574 }575 /**576 * MouseOver (Hover) an element.577 * @param xOffset x offset for moving578 * @param yOffset y offset for moving579 */580 public void hover(Integer xOffset, Integer yOffset) {581 doAction(ACTION_NAME.HOVER, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()), xOffset, yOffset);582 }583 584 /**585 * Click onto element if it present.586 *587 * @return boolean return true if clicked588 */589 public boolean clickIfPresent() {590 return clickIfPresent(EXPLICIT_TIMEOUT);591 }592 /**593 * Click onto element if present.594 *595 * @param timeout - timeout596 * @return boolean return true if clicked597 */598 public boolean clickIfPresent(long timeout) {599 boolean present = isElementPresent(timeout);600 if (present) {601 click();602 }603 return present;604 }605 606 /**607 * Send Keys to element.608 * 609 * @param keys Keys610 */611 public void sendKeys(Keys keys) {612 sendKeys(keys, EXPLICIT_TIMEOUT);613 }614 /**615 * Send Keys to element.616 *617 * @param keys Keys618 * @param timeout to wait619 */620 public void sendKeys(Keys keys, long timeout) {621 sendKeys(keys, timeout, getDefaultCondition(getBy()));622 }623 624 /**625 * Send Keys to element.626 *627 * @param keys Keys628 * @param timeout to wait629 * @param waitCondition630 * to check element conditions before action631 */632 public void sendKeys(Keys keys, long timeout, ExpectedCondition<?> waitCondition) {633 doAction(ACTION_NAME.SEND_KEYS, timeout, waitCondition, keys);634 }635 636 637 /**638 * Type text to element.639 * 640 * @param text String641 */642 public void type(String text) {643 type(text, EXPLICIT_TIMEOUT);644 }645 /**646 * Type text to element.647 *648 * @param text String649 * @param timeout to wait650 */651 public void type(String text, long timeout) {652 type(text, timeout, getDefaultCondition(getBy()));653 }654 655 /**656 * Type text to element.657 *658 * @param text String659 * @param timeout to wait660 * @param waitCondition661 * to check element conditions before action662 */663 public void type(String text, long timeout, ExpectedCondition<?> waitCondition) {664 doAction(ACTION_NAME.TYPE, timeout, waitCondition, text);665 }666 667 /**668 /**669 * Scroll to element (applied only for desktop).670 * Useful for desktop with React 671 */672 public void scrollTo() {673 if (Configuration.getDriverType().equals(SpecialKeywords.MOBILE)) {674 LOGGER.debug("scrollTo javascript is unsupported for mobile devices!");675 return;676 }677 try {678 Locatable locatableElement = (Locatable) this.findElement();679 // [VD] onScreen should be updated onto onPage as only 2nd one680 // returns real coordinates without scrolling... read below material681 // for details682 // https://groups.google.com/d/msg/selenium-developers/nJR5VnL-3Qs/uqUkXFw4FSwJ683 // [CB] onPage -> inViewPort684 // https://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/remote/RemoteWebElement.java?r=abc64b1df10d5f5d72d11fba37fabf5e85644081685 int y = locatableElement.getCoordinates().inViewPort().getY();686 int offset = R.CONFIG.getInt("scroll_to_element_y_offset");687 ((JavascriptExecutor) getDriver()).executeScript("window.scrollBy(0," + (y - offset) + ");");688 } catch (Exception e) {689 //do nothing690 }691 }692 693 /* Inputs file path to specified element.694 *695 * @param filePath path696 */697 public void attachFile(String filePath) {698 doAction(ACTION_NAME.ATTACH_FILE, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()), filePath);699 }700 /**701 * Check checkbox702 * <p>703 * for checkbox Element704 */705 public void check() {706 doAction(ACTION_NAME.CHECK, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()));707 }708 /**709 * Uncheck checkbox710 * <p>711 * for checkbox Element712 */713 public void uncheck() {714 doAction(ACTION_NAME.UNCHECK, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()));715 }716 /**717 * Get checkbox state.718 *719 * @return - current state720 */721 public boolean isChecked() {722 return (boolean) doAction(ACTION_NAME.IS_CHECKED, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()));723 }724 /**725 * Get selected elements from one-value select.726 *727 * @return selected value728 */729 public String getSelectedValue() {730 return (String) doAction(ACTION_NAME.GET_SELECTED_VALUE, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()));731 }732 /**733 * Get selected elements from multi-value select.734 *735 * @return selected values736 */737 @SuppressWarnings("unchecked")738 public List<String> getSelectedValues() {739 return (List<String>) doAction(ACTION_NAME.GET_SELECTED_VALUES, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()));740 }741 /**742 * Selects text in specified select element.743 *744 * @param selectText select text745 * @return true if item selected, otherwise false.746 */747 public boolean select(final String selectText) {748 return (boolean) doAction(ACTION_NAME.SELECT, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()), selectText);749 }750 /**751 * Select multiple text values in specified select element.752 *753 * @param values final String[]754 * @return boolean.755 */756 public boolean select(final String[] values) {757 return (boolean) doAction(ACTION_NAME.SELECT_VALUES, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()), values);758 }759 /**760 * Selects value according to text value matcher.761 *762 * @param matcher {@link} BaseMatcher763 * @return true if item selected, otherwise false.764 * <p>765 * Usage example: BaseMatcher&lt;String&gt; match=new766 * BaseMatcher&lt;String&gt;() { {@literal @}Override public boolean767 * matches(Object actual) { return actual.toString().contains(RequiredText);768 * } {@literal @}Override public void describeTo(Description description) {769 * } };770 */771 public boolean selectByMatcher(final BaseMatcher<String> matcher) {772 return (boolean) doAction(ACTION_NAME.SELECT_BY_MATCHER, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()), matcher);773 }774 /**775 * Selects first value according to partial text value.776 *777 * @param partialSelectText select by partial text778 * @return true if item selected, otherwise false.779 */780 public boolean selectByPartialText(final String partialSelectText) {781 return (boolean) doAction(ACTION_NAME.SELECT_BY_PARTIAL_TEXT, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()),782 partialSelectText);783 }784 /**785 * Selects item by index in specified select element.786 *787 * @param index to select by788 * @return true if item selected, otherwise false.789 */790 public boolean select(final int index) {791 return (boolean) doAction(ACTION_NAME.SELECT_BY_INDEX, EXPLICIT_TIMEOUT, getDefaultCondition(getBy()), index);792 }793 // --------------------------------------------------------------------------794 // Base UI validations795 // --------------------------------------------------------------------------796 /**797 * Check that element present and visible.798 *799 * @return element existence status.800 */801 public boolean isElementPresent() {802 return isElementPresent(EXPLICIT_TIMEOUT);803 }804 /**805 * Check that element present and visible within specified timeout.806 *807 * @param timeout - timeout.808 * @return element existence status.809 */810 public boolean isElementPresent(long timeout) {811 // perform at once super-fast single selenium call and only if nothing found move to waitAction812 if (element != null) {813 try {814 if (element.isDisplayed()) {815 return true;816 }817 } catch (Exception e) {818 //do nothing as element is not found as expected here819 }820 }821 ExpectedCondition<?> waitCondition;822 823 // [VD] replace presenceOfElementLocated and visibilityOf conditions by single "visibilityOfElementLocated"824 // visibilityOf: Does not check for presence of the element as the error explains it.825 // visibilityOfElementLocated: Checks to see if the element is present and also visible. To check visibility, it makes sure that the element826 // has a height and width greater than 0.827 828 waitCondition = ExpectedConditions.visibilityOfElementLocated(getBy());829 return waitUntil(waitCondition, timeout);830 }831 /**832 * Check that element not present and not visible within specified timeout.833 *834 * @param timeout - timeout.835 * @return element existence status.836 */837 public boolean isElementNotPresent(long timeout) {838 return !isElementPresent(timeout);839 }840 /**841 * Checks that element clickable.842 *843 * @return element clickability status.844 */845 public boolean isClickable() {846 return isClickable(EXPLICIT_TIMEOUT);847 }848 /**849 * Check that element clickable within specified timeout.850 *851 * @param timeout - timeout.852 * @return element clickability status.853 */854 public boolean isClickable(long timeout) {855 ExpectedCondition<?> waitCondition;856 857 if (element != null) {858 waitCondition = ExpectedConditions.elementToBeClickable(element);859 } else {860 waitCondition = ExpectedConditions.elementToBeClickable(getBy());861 }862 863 return waitUntil(waitCondition, timeout);864 }865 /**866 * Checks that element visible.867 *868 * @return element visibility status.869 */870 public boolean isVisible() {871 return isVisible(EXPLICIT_TIMEOUT);872 }873 /**874 * Check that element visible within specified timeout.875 *876 * @param timeout - timeout.877 * @return element visibility status.878 */879 public boolean isVisible(long timeout) {880 ExpectedCondition<?> waitCondition;881 if (element != null) {882 waitCondition = ExpectedConditions.or(ExpectedConditions.visibilityOfElementLocated(getBy()),883 ExpectedConditions.visibilityOf(element));884 } else {885 waitCondition = ExpectedConditions.visibilityOfElementLocated(getBy());886 }887 boolean res = false;888 try {889 res = waitUntil(waitCondition, timeout);890 } catch (StaleElementReferenceException e) {891 // there is no sense to continue as StaleElementReferenceException captured892 LOGGER.debug("waitUntil: StaleElementReferenceException", e);893 }894 895 return res;896 }897 898 /**899 * Check that element with text present.900 *901 * @param text of element to check.902 * @return element with text existence status.903 */904 public boolean isElementWithTextPresent(final String text) {905 return isElementWithTextPresent(text, EXPLICIT_TIMEOUT);906 }907 /**908 * Check that element with text present.909 *910 * @param text of element to check.911 * @param timeout - timeout.912 * @return element with text existence status.913 */914 public boolean isElementWithTextPresent(final String text, long timeout) {915 final String decryptedText = cryptoTool.decryptByPattern(text, CRYPTO_PATTERN);916 ExpectedCondition<Boolean> textCondition;917 if (element != null) {918 textCondition = ExpectedConditions.textToBePresentInElement(element, decryptedText);919 } else {920 textCondition = ExpectedConditions.textToBePresentInElementLocated(getBy(), decryptedText);921 }922 return waitUntil(textCondition, timeout);923 //TODO: restore below code as only projects are migrated to "isElementWithContainTextPresent"924// return waitUntil(ExpectedConditions.and(ExpectedConditions.presenceOfElementLocated(getBy()),925// ExpectedConditions.textToBe(getBy(), decryptedText)), timeout);926 }927 928 public void assertElementWithTextPresent(final String text) {929 assertElementWithTextPresent(text, EXPLICIT_TIMEOUT);930 }931 public void assertElementWithTextPresent(final String text, long timeout) {932 if (!isElementWithTextPresent(text, timeout)) {933 Assert.fail(Messager.ELEMENT_WITH_TEXT_NOT_PRESENT.getMessage(getNameWithLocator(), text));934 }935 }936 937 public void assertElementPresent() {938 assertElementPresent(EXPLICIT_TIMEOUT);939 }940 public void assertElementPresent(long timeout) {941 if (!isPresent(timeout)) {942 Assert.fail(Messager.ELEMENT_NOT_PRESENT.getMessage(getNameWithLocator()));943 }944 }945 /**946 * Find Extended Web Element on page using By starting search from this947 * object.948 *949 * @param by Selenium By locator950 * @return ExtendedWebElement if exists otherwise null.951 */952 public ExtendedWebElement findExtendedWebElement(By by) {953 return findExtendedWebElement(by, by.toString(), EXPLICIT_TIMEOUT);954 }955 /**956 * Find Extended Web Element on page using By starting search from this957 * object.958 *959 * @param by Selenium By locator960 * @param timeout to wait961 * @return ExtendedWebElement if exists otherwise null.962 */963 public ExtendedWebElement findExtendedWebElement(By by, long timeout) {964 return findExtendedWebElement(by, by.toString(), timeout);965 }966 /**967 * Find Extended Web Element on page using By starting search from this968 * object.969 *970 * @param by Selenium By locator971 * @param name Element name972 * @return ExtendedWebElement if exists otherwise null.973 */974 public ExtendedWebElement findExtendedWebElement(final By by, String name) {975 return findExtendedWebElement(by, name, EXPLICIT_TIMEOUT);976 }977 /**978 * Find Extended Web Element on page using By starting search from this979 * object.980 *981 * @param by Selenium By locator982 * @param name Element name983 * @param timeout Timeout to find984 * @return ExtendedWebElement if exists otherwise null.985 */986 public ExtendedWebElement findExtendedWebElement(final By by, String name, long timeout) {987 if (isPresent(by, timeout)) {988 return new ExtendedWebElement(by, name, this.driver, this.searchContext);989 } else {990 throw new NoSuchElementException(SpecialKeywords.NO_SUCH_ELEMENT_ERROR + by.toString());991 }992 }993 public List<ExtendedWebElement> findExtendedWebElements(By by) {994 return findExtendedWebElements(by, EXPLICIT_TIMEOUT);995 }996 public List<ExtendedWebElement> findExtendedWebElements(final By by, long timeout) {997 List<ExtendedWebElement> extendedWebElements = new ArrayList<ExtendedWebElement>();998 List<WebElement> webElements = new ArrayList<WebElement>();999 1000 if (isPresent(by, timeout)) {1001 webElements = getElement().findElements(by);1002 } else {1003 throw new NoSuchElementException(SpecialKeywords.NO_SUCH_ELEMENT_ERROR + by.toString());1004 }1005 int i = 1;1006 for (WebElement element : webElements) {1007 String name = "undefined";1008 try {1009 name = element.getText();1010 } catch (Exception e) {1011 /* do nothing */1012 LOGGER.debug("Error while getting text from element.", e);1013 }1014 // we can't initiate ExtendedWebElement using by as it belongs to the list of elements1015 extendedWebElements.add(new ExtendedWebElement(generateByForList(by, i), name, this.driver, this.searchContext));1016 i++;1017 }1018 return extendedWebElements;1019 }1020 public boolean waitUntilElementDisappear(final long timeout) {1021 try {1022 if (this.element == null) {1023 // if element not found it will cause NoSuchElementException1024 findElement();1025 } else {1026 // if element is stale, it will cause StaleElementReferenceException1027 this.element.isDisplayed();1028 }1029 return waitUntil(ExpectedConditions.or(ExpectedConditions.stalenessOf(this.element),1030 ExpectedConditions.invisibilityOf(this.element)),1031 timeout);1032 } catch (NoSuchElementException | StaleElementReferenceException e) {1033 // element not present so means disappear1034 return true;1035 }1036 }1037 public ExtendedWebElement format(Object... objects) {1038 String locator = by.toString();1039 By by = null;1040 if (locator.startsWith(LocatorType.ID.getStartsWith())) {1041 if (caseInsensitiveConverter != null) {1042 by = caseInsensitiveConverter.convert(by);1043 } else {1044 by = By.id(String.format(StringUtils.remove(locator, LocatorType.ID.getStartsWith()), objects));1045 }1046 }1047 if (locator.startsWith(LocatorType.NAME.getStartsWith())) {1048 if (caseInsensitiveConverter != null) {1049 by = caseInsensitiveConverter.convert(by);1050 } else {1051 by = By.id(String.format(StringUtils.remove(locator, LocatorType.NAME.getStartsWith()), objects));1052 }1053 }1054 if (locator.startsWith(LocatorType.XPATH.getStartsWith())) {1055 if (caseInsensitiveConverter != null) {1056 by = caseInsensitiveConverter.convert(by);1057 } else {1058 by = By.xpath(String.format(StringUtils.remove(locator, LocatorType.XPATH.getStartsWith()), objects));1059 }1060 }1061 if (locator.startsWith(LocatorType.LINKTEXT.getStartsWith())) {1062 if (caseInsensitiveConverter != null) {1063 by = caseInsensitiveConverter.convert(by);1064 } else {1065 by = By.xpath(String.format(StringUtils.remove(locator, LocatorType.LINKTEXT.getStartsWith()), objects));1066 }1067 }1068 if (locator.startsWith("partialLinkText: ")) {1069 by = By.partialLinkText(String.format(StringUtils.remove(locator, "partialLinkText: "), objects));1070 }1071 if (locator.startsWith("css: ")) {1072 by = By.cssSelector(String.format(StringUtils.remove(locator, "css: "), objects));1073 }1074 if (locator.startsWith("tagName: ")) {1075 by = By.tagName(String.format(StringUtils.remove(locator, "tagName: "), objects));1076 }1077 /*1078 * All ClassChain locators start from **. e.g FindBy(xpath = "**'/XCUIElementTypeStaticText[`name CONTAINS[cd] '%s'`]")1079 */1080 if (locator.startsWith("By.IosClassChain: **")) {1081 by = MobileBy.iOSClassChain(String.format(StringUtils.remove(locator, "By.IosClassChain: "), objects));1082 }1083 if (locator.startsWith("By.IosNsPredicate: **")) {1084 by = MobileBy.iOSNsPredicateString(String.format(StringUtils.remove(locator, "By.IosNsPredicate: "), objects));1085 }1086 if (locator.startsWith("By.AccessibilityId: ")) {1087 by = MobileBy.AccessibilityId(String.format(StringUtils.remove(locator, "By.AccessibilityId: "), objects));1088 }1089 if (locator.startsWith("By.Image: ")) {1090 String formattedLocator = String.format(StringUtils.remove(locator, "By.Image: "), objects);1091 Path path = Paths.get(formattedLocator);1092 LOGGER.debug("Formatted locator is : " + formattedLocator);1093 String base64image;1094 try {1095 base64image = new String(Base64.encode(Files.readAllBytes(path)));1096 } catch (IOException e) {1097 throw new RuntimeException(1098 "Error while reading image file after formatting. Formatted locator : " + formattedLocator, e);1099 }1100 LOGGER.debug("Base64 image representation has benn successfully obtained after formatting.");1101 by = MobileBy.image(base64image);1102 }1103 if (locator.startsWith("By.AndroidUIAutomator: ")) {1104 by = MobileBy.AndroidUIAutomator(String.format(StringUtils.remove(locator, "By.AndroidUIAutomator: "), objects));1105 LOGGER.debug("Formatted locator is : " + by.toString());1106 }1107 return new ExtendedWebElement(by, name, this.driver, this.searchContext, objects);1108 }1109 /**1110 * Pause for specified timeout.1111 * 1112 * @param timeout in seconds.1113 */1114 public void pause(long timeout) {1115 CommonUtils.pause(timeout);1116 }1117 public void pause(double timeout) {1118 CommonUtils.pause(timeout);1119 }1120 1121 public interface ActionSteps {1122 void doClick();1123 1124 void doClickByJs();1125 1126 void doClickByActions();1127 1128 void doDoubleClick();1129 void doRightClick();1130 1131 void doHover(Integer xOffset, Integer yOffset);1132 void doType(String text);1133 void doSendKeys(Keys keys);1134 void doAttachFile(String filePath);1135 void doCheck();1136 void doUncheck();1137 1138 boolean doIsChecked();1139 1140 String doGetText();1141 Point doGetLocation();1142 Dimension doGetSize();1143 String doGetAttribute(String name);1144 boolean doSelect(String text);1145 boolean doSelectValues(final String[] values);1146 boolean doSelectByMatcher(final BaseMatcher<String> matcher);1147 boolean doSelectByPartialText(final String partialSelectText);1148 boolean doSelectByIndex(final int index);1149 1150 String doGetSelectedValue();1151 1152 List<String> doGetSelectedValues();1153 }1154 private Object executeAction(ACTION_NAME actionName, ActionSteps actionSteps, Object... inputArgs) {1155 Object result = null;1156 switch (actionName) {1157 case CLICK:1158 actionSteps.doClick();1159 break;1160 case CLICK_BY_JS:1161 actionSteps.doClickByJs();1162 break;1163 case CLICK_BY_ACTIONS:1164 actionSteps.doClickByActions();1165 break;1166 case DOUBLE_CLICK:1167 actionSteps.doDoubleClick();1168 break;1169 case HOVER:1170 actionSteps.doHover((Integer) inputArgs[0], (Integer) inputArgs[1]);1171 break;1172 case RIGHT_CLICK:1173 actionSteps.doRightClick();1174 break;1175 case GET_TEXT:1176 result = actionSteps.doGetText();1177 break;1178 case GET_LOCATION:1179 result = actionSteps.doGetLocation();1180 break;1181 case GET_SIZE:1182 result = actionSteps.doGetSize();1183 break;1184 case GET_ATTRIBUTE:1185 result = actionSteps.doGetAttribute((String) inputArgs[0]);1186 break;1187 case SEND_KEYS:1188 actionSteps.doSendKeys((Keys) inputArgs[0]);1189 break;1190 case TYPE:1191 actionSteps.doType((String) inputArgs[0]);1192 break;1193 case ATTACH_FILE:1194 actionSteps.doAttachFile((String) inputArgs[0]);1195 break;1196 case CHECK:1197 actionSteps.doCheck();1198 break;1199 case UNCHECK:1200 actionSteps.doUncheck();1201 break;1202 case IS_CHECKED:1203 result = actionSteps.doIsChecked();1204 break;1205 case SELECT:1206 result = actionSteps.doSelect((String) inputArgs[0]);1207 break;1208 case SELECT_VALUES:1209 result = actionSteps.doSelectValues((String[]) inputArgs);1210 break;1211 case SELECT_BY_MATCHER:1212 result = actionSteps.doSelectByMatcher((BaseMatcher<String>) inputArgs[0]);1213 break;1214 case SELECT_BY_PARTIAL_TEXT:1215 result = actionSteps.doSelectByPartialText((String) inputArgs[0]);1216 break;1217 case SELECT_BY_INDEX:1218 result = actionSteps.doSelectByIndex((int) inputArgs[0]);1219 break;1220 case GET_SELECTED_VALUE:1221 result = actionSteps.doGetSelectedValue();1222 break;1223 case GET_SELECTED_VALUES:1224 result = actionSteps.doGetSelectedValues();1225 break;1226 default:1227 Assert.fail("Unsupported UI action name" + actionName.toString());1228 break;1229 }1230 return result;1231 }1232 /**1233 * doAction on element.1234 *1235 * @param actionName1236 * ACTION_NAME1237 * @param timeout1238 * long1239 * @param waitCondition1240 * to check element conditions before action1241 * @return1242 * Object1243 */1244 private Object doAction(ACTION_NAME actionName, long timeout, ExpectedCondition<?> waitCondition) {1245 // [VD] do not remove null args otherwise all actions without arguments will be broken!1246 Object nullArgs = null;1247 return doAction(actionName, timeout, waitCondition, nullArgs);1248 }1249 private Object doAction(ACTION_NAME actionName, long timeout, ExpectedCondition<?> waitCondition,1250 Object...inputArgs) {1251 1252 if (waitCondition != null) {1253 //do verification only if waitCondition is not null1254 if (!waitUntil(waitCondition, timeout)) {1255 //TODO: think about raising exception otherwise we do extra call and might wait and hangs especially for mobile/appium1256 LOGGER.error(Messager.ELEMENT_CONDITION_NOT_VERIFIED.getMessage(actionName.getKey(), getNameWithLocator()));1257 }1258 }1259 1260 if (isLocalized) {1261 isLocalized = false; // single verification is enough for this particular element1262 L10N.verify(this);1263 }...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful