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

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

Source:ExtendedWebElement.java Github

copy

Full Screen

...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 }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);1296 }1297 1298 @Override1299 public void doClickByActions() {1300 DriverListener.setMessages(Messager.ELEMENT_CLICKED.getMessage(getName()),1301 Messager.ELEMENT_NOT_CLICKED.getMessage(getNameWithLocator()));1302 LOGGER.info("Do click by Actions for element: " + getNameWithLocator());1303 Actions actions = new Actions(getDriver());1304 actions.moveToElement(element).click().perform();1305 } 1306 1307 @Override1308 public void doDoubleClick() {1309 DriverListener.setMessages(Messager.ELEMENT_DOUBLE_CLICKED.getMessage(getName()),1310 Messager.ELEMENT_NOT_DOUBLE_CLICKED.getMessage(getNameWithLocator()));1311 1312 WebDriver drv = getDriver();1313 Actions action = new Actions(drv);1314 action.moveToElement(element).doubleClick(element).build().perform();1315 }1316 1317 @Override1318 public void doHover(Integer xOffset, Integer yOffset) {1319 DriverListener.setMessages(Messager.ELEMENT_HOVERED.getMessage(getName()),1320 Messager.ELEMENT_NOT_HOVERED.getMessage(getNameWithLocator()));1321 1322 WebDriver drv = getDriver();1323 Actions action = new Actions(drv);1324 if (xOffset != null && yOffset!= null) {1325 action.moveToElement(element, xOffset, yOffset).build().perform();1326 } else {1327 action.moveToElement(element).build().perform();1328 }1329 }1330 1331 @Override1332 public void doSendKeys(Keys keys) {1333 DriverListener.setMessages(Messager.KEYS_SEND_TO_ELEMENT.getMessage(keys.toString(), getName()),1334 Messager.KEYS_NOT_SEND_TO_ELEMENT.getMessage(keys.toString(), getNameWithLocator()));1335 element.sendKeys(keys);1336 }1337 @Override1338 public void doType(String text) {1339 final String decryptedText = cryptoTool.decryptByPattern(text, CRYPTO_PATTERN);1340/* if (!element.getText().isEmpty()) {1341 DriverListener.setMessages(Messager.KEYS_CLEARED_IN_ELEMENT.getMessage(getName()),1342 Messager.KEYS_NOT_CLEARED_IN_ELEMENT.getMessage(getNameWithLocator()));1343 element.clear();1344 }1345*/1346 DriverListener.setMessages(Messager.KEYS_CLEARED_IN_ELEMENT.getMessage(getName()),1347 Messager.KEYS_NOT_CLEARED_IN_ELEMENT.getMessage(getNameWithLocator()));1348 element.clear();1349 String textLog = (!decryptedText.equals(text) ? "********" : text);1350 DriverListener.setMessages(Messager.KEYS_SEND_TO_ELEMENT.getMessage(textLog, getName()),1351 Messager.KEYS_NOT_SEND_TO_ELEMENT.getMessage(textLog, getNameWithLocator()));1352 element.sendKeys(decryptedText);1353 }1354 @Override1355 public void doAttachFile(String filePath) {1356 final String decryptedText = cryptoTool.decryptByPattern(filePath, CRYPTO_PATTERN);1357 String textLog = (!decryptedText.equals(filePath) ? "********" : filePath);1358 DriverListener.setMessages(Messager.FILE_ATTACHED.getMessage(textLog, getName()),1359 Messager.FILE_NOT_ATTACHED.getMessage(textLog, getNameWithLocator()));1360 ((JavascriptExecutor) getDriver()).executeScript("arguments[0].style.display = 'block';", element);1361 ((RemoteWebDriver) castDriver(getDriver())).setFileDetector(new LocalFileDetector());1362 element.sendKeys(decryptedText);1363 }1364 @Override1365 public String doGetText() {1366 String text = element.getText();1367 LOGGER.debug(Messager.ELEMENT_ATTRIBUTE_FOUND.getMessage("Text", text, getName()));1368 return text;1369 }1370 @Override1371 public Point doGetLocation() {1372 Point point = element.getLocation();1373 LOGGER.debug(Messager.ELEMENT_ATTRIBUTE_FOUND.getMessage("Location", point.toString(), getName()));1374 return point;1375 }1376 @Override1377 public Dimension doGetSize() {1378 Dimension dim = element.getSize();1379 LOGGER.debug(Messager.ELEMENT_ATTRIBUTE_FOUND.getMessage("Size", dim.toString(), getName()));1380 return dim;1381 }1382 @Override1383 public String doGetAttribute(String name) {1384 String attribute = element.getAttribute(name);1385 LOGGER.debug(Messager.ELEMENT_ATTRIBUTE_FOUND.getMessage(name, attribute, getName()));1386 return attribute;1387 }1388 @Override1389 public void doRightClick() {1390 DriverListener.setMessages(Messager.ELEMENT_RIGHT_CLICKED.getMessage(getName()),1391 Messager.ELEMENT_NOT_RIGHT_CLICKED.getMessage(getNameWithLocator()));1392 1393 WebDriver drv = getDriver();1394 Actions action = new Actions(drv);1395 action.moveToElement(element).contextClick(element).build().perform();1396 }1397 @Override...

Full Screen

Full Screen

doGetAttribute

Using AI Code Generation

copy

Full Screen

1String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName");2String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName", "attributeValue");3String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName", "attributeValue", "attributeValue");4String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName", "attributeValue", "attributeValue", "attributeValue");5String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName", "attributeValue", "attributeValue", "attributeValue", "attributeValue");6String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName", "attributeValue", "attributeValue", "attributeValue", "attributeValue", "attributeValue");7String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName", "attributeValue", "attributeValue", "attributeValue", "attributeValue", "attributeValue", "attributeValue");8String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName", "attributeValue", "attributeValue", "attributeValue", "attributeValue", "attributeValue", "attributeValue", "attributeValue");9String attributeValue = driver.findElement(By.id("myId")).doGetAttribute("attributeName", "attributeValue", "attributeValue", "attributeValue", "attributeValue", "attributeValue", "attributeValue

Full Screen

Full Screen

doGetAttribute

Using AI Code Generation

copy

Full Screen

1WebDriver driver = new ChromeDriver();2driver.switchTo().frame("iframeResult");3ExtendedWebElement input = new ExtendedWebElement(driver.findElement(By.id("fname")));4String value = input.doGetAttribute("value");5System.out.println("Value of the attribute \"value\" is " + value);6driver.quit();

Full Screen

Full Screen

doGetAttribute

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.chrome.ChromeDriver;6import org.openqa.selenium.chrome.ChromeOptions;7import org.openqa.selenium.remote.DesiredCapabilities;8import org.openqa.selenium.remote.RemoteWebDriver;9import java.net.MalformedURLException;10import java.net.URL;11public class Test {12 public static void main(String[] args) throws MalformedURLException {13 ChromeOptions options = new ChromeOptions();14 WebDriver driver = new ChromeDriver(options);15 driver.switchTo().frame(iframe);16 ExtendedWebElement extendedWebElement = new ExtendedWebElement(link);17 System.out.println(extendedWebElement.doGetAttribute("target"));18 }19}

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