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

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

Source:ExtendedWebElement.java Github

copy

Full Screen

...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 }1264 Object output = null;1265 try {1266 this.element = getElement();1267 output = overrideAction(actionName, inputArgs);1268 } catch (StaleElementReferenceException e) {1269 //TODO: analyze mobile testing for staled elements. Potentially it should be fixed by appium java client already1270 // sometime Appium instead printing valid StaleElementException generate java.lang.ClassCastException:1271 // com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to java.lang.String1272 LOGGER.debug("catched StaleElementReferenceException: ", e);1273 // try to find again using driver context and do action1274 element = this.findElement();1275 output = overrideAction(actionName, inputArgs);1276 }1277 return output;1278 }1279 // single place for all supported UI actions in carina core1280 private Object overrideAction(ACTION_NAME actionName, Object...inputArgs) {1281 Object output = executeAction(actionName, new ActionSteps() {1282 @Override1283 public void doClick() {1284 DriverListener.setMessages(Messager.ELEMENT_CLICKED.getMessage(getName()),1285 Messager.ELEMENT_NOT_CLICKED.getMessage(getNameWithLocator()));1286 element.click();1287 }1288 1289 @Override1290 public void doClickByJs() {1291 DriverListener.setMessages(Messager.ELEMENT_CLICKED.getMessage(getName()),1292 Messager.ELEMENT_NOT_CLICKED.getMessage(getNameWithLocator()));1293 LOGGER.info("Do click by JavascriptExecutor for element: " + getNameWithLocator());1294 JavascriptExecutor executor = (JavascriptExecutor) getDriver();1295 executor.executeScript("arguments[0].click();", element);...

Full Screen

Full Screen

executeAction

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo.gui.components;2import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;3import com.qaprosoft.carina.core.gui.AbstractUIObject;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.support.FindBy;6public class FooterMenu extends AbstractUIObject {7 private ExtendedWebElement aboutLink;8 private ExtendedWebElement blogLink;9 private ExtendedWebElement contactLink;10 public FooterMenu(WebDriver driver) {11 super(driver);12 }13 public void clickAboutLink() {14 aboutLink.click();15 }16 public void clickBlogLink() {17 blogLink.click();18 }19 public void clickContactLink() {20 contactLink.click();21 }22}23package com.qaprosoft.carina.demo.gui.pages;24import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;25import com.qaprosoft.carina.core.gui.AbstractPage;26import com.qaprosoft.carina.demo.gui.components.FooterMenu;27import org.openqa.selenium.WebDriver;28import org.openqa.selenium.support.FindBy;29public class AboutPage extends AbstractPage {30 private ExtendedWebElement title;31 private ExtendedWebElement aboutText;32 private ExtendedWebElement aboutImage;33 private FooterMenu footerMenu;34 public AboutPage(WebDriver driver) {35 super(driver);36 }37 public String getAboutPageTitle() {38 return title.getText();39 }40 public String getAboutPageText() {41 return aboutText.getText();42 }43 public boolean isAboutImagePresent() {44 return aboutImage.isPresent();45 }46 public FooterMenu getFooterMenu() {47 return footerMenu;48 }49}50package com.qaprosoft.carina.demo.gui.pages;51import com.qaprosoft.carina.core

Full Screen

Full Screen

executeAction

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;2import org.openqa.selenium.By;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.support.FindBy;6import org.openqa.selenium.support.PageFactory;7public class ExtendedWebElementTest {8 @FindBy(id = "test")9 private ExtendedWebElement test;10 public ExtendedWebElementTest(WebDriver driver) {11 PageFactory.initElements(driver, this);12 }13 public void testExecuteAction() {14 test.executeAction("click");15 }16}17import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;18import org.openqa.selenium.By;19import org.openqa.selenium.WebDriver;20import org.openqa.selenium.WebElement;21import org.openqa.selenium.support.FindBy;22import org.openqa.selenium.support.PageFactory;23public class ExtendedWebElementTest {24 @FindBy(id = "test")25 private ExtendedWebElement test;26 public ExtendedWebElementTest(WebDriver driver) {27 PageFactory.initElements(driver, this);28 }29 public void testExecuteAction() {30 test.executeAction("click");31 }32}33import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;34import org.openqa.selenium.By;35import org.openqa.selenium.WebDriver;36import org.openqa.selenium.WebElement;37import org.openqa.selenium.support.FindBy;38import org.openqa.selenium.support.PageFactory;39public class ExtendedWebElementTest {40 @FindBy(id = "test")41 private ExtendedWebElement test;42 public ExtendedWebElementTest(WebDriver driver) {43 PageFactory.initElements(driver, this);44 }45 public void testExecuteAction() {46 test.executeAction("click");47 }48}49import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;50import org.openqa.selenium.By;51import org.openqa.selenium.WebDriver;52import org.openqa.selenium.WebElement;53import org.openqa.selenium.support.FindBy;54import org.openqa.selenium.support.PageFactory;55public class ExtendedWebElementTest {56 @FindBy(id = "test")57 private ExtendedWebElement test;58 public ExtendedWebElementTest(WebDriver driver) {59 PageFactory.initElements(driver, this);60 }61 public void testExecuteAction() {

Full Screen

Full Screen

executeAction

Using AI Code Generation

copy

Full Screen

1com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.click(WebElement element) throws Exception{2 executeAction("click", element);3}4com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.type(WebElement element, String text) throws Exception{5 executeAction("type", element, text);6}7com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.getText(WebElement element) throws Exception{8 return executeAction("getText", element);9}10com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.getValue(WebElement element) throws Exception{11 return executeAction("getValue", element);12}13com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.getAttribute(WebElement element, String attribute) throws Exception{14 return executeAction("getAttribute", element, attribute);15}16com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.isElementPresent(WebElement element) throws Exception{17 return executeAction("isElementPresent", element);18}19com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.isEnabled(WebElement element) throws Exception{20 return executeAction("isEnabled", element);21}22com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement.isSelected(WebElement element) throws Exception{23 return executeAction("isSelected

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