public V get(K key) { Pair<K, V> first = null; try { if (ignoreCase) first = LinqUtils.first(pairs, pair -> pair.key.toString().toLowerCase().equals(key.toString().toLowerCase())); first = LinqUtils.first(pairs, pair -> pair.key.equals(key)); } catch (Exception ignore) { } return (first != null) ? first.value : null; }
private String getSelected(List<WebElement> els) { WebElement element = first(els, this::isSelectedAction); if (element == null) throw exception("No elements selected. Override getSelectedAction or place locator to <select> tag"); return element.getText(); }
public Text getTextElement() { Field textField = first(getClass().getDeclaredFields(), f -> (f.getType() == Text.class) || (f.getType() == IText.class)); if (textField == null) throw exception("Can't find Text Element '%s'", toString()); return (Text) getValueField(textField, element); } }
private void setField(Object row, Field[] fields, String fieldName, Function<Field, Object> valueFunc) { Field field = LinqUtils.first(fields, f -> f.getName().equalsIgnoreCase(fieldName)); if (field == null) return; try { writeField(field, row, valueFunc.apply(field), true); } catch (IllegalAccessException e) { throw exception("Can't write field with name: " + fieldName); } }
public Text getTextElement() { Field textField = LinqUtils.first(getClass().getDeclaredFields(), f -> (f.getType() == Text.class) || (f.getType() == IText.class)); if (textField == null) throw exception("Can't find Text Element '%s'", toString()); return (Text) getValueField(textField, element); } }
private void setField(Object row, Field[] fields, String fieldName, Function<Field, Object> valueFunc) { Field field = LinqUtils.first(fields, f -> f.getName().equalsIgnoreCase(fieldName)); if (field == null) return; try { writeField(field, row, valueFunc.apply(field), true); } catch (IllegalAccessException e) { throw exception("Can't write field with name: " + fieldName); } }
public static <T> T getFirstField(Object obj, Class<?>... types) { return (T) getValueField(LinqUtils.first(obj.getClass().getDeclaredFields(), field -> isExpectedClass(field, types)), obj); } private static boolean isExpectedClass(Field field, Class<?>... types) {
private Clickable getFromList(List<WebElement> els, String name) { WebElement element = first(els, el -> el.getText().toLowerCase().trim().equals(name.toLowerCase().trim())); if (element == null) throw exception("Can't find option '%s'. Please fix allLabelsLocator", name); Clickable cl = new Clickable(element); cl.setParent(getParent()); return cl; } @Override
private Clickable getClickable(String name) { List<Field> fields = getFields(this, IClickable.class); Field result = LinqUtils.first(fields, field -> AnnotationsUtil.getElementName(field).toLowerCase().contains(name.toLowerCase())); return (Clickable) getValueField(result, this); }
private Clickable getClickable(String name) { List<Field> fields = getFields(this, IClickable.class); Field result = LinqUtils.first(fields, field -> AnnotationsUtil.getElementName(field).toLowerCase().contains(name.toLowerCase())); return (Clickable) getValueField(result, this); }
private Clickable getClickable(String name) { List<Field> fields = getFields(this, IClickable.class); Field result = LinqUtils.first(fields, field -> AnnotationsUtil.getElementName(field).toLowerCase().contains(name.toLowerCase())); return (Clickable) getValueField(result, this); }
protected void chooseItemAction(String[] names, Consumer<WebElement> action) { String[] nodes = SplitToList(names); if (menuLevelsLocators.size() == 0 && hasLocator()) menuLevelsLocators.add(getLocator()); if (menuLevelsLocators.size() < nodes.length) return; for(int i = 0; i < nodes.length; i++) { String value = nodes[i]; List<WebElement> elements = new Selector<>(menuLevelsLocators.get(i)).getElements(); WebElement element = first(elements, el -> el.getText().equals(value)); action.accept(element); } }
protected void chooseItemAction(String[] names, Consumer<WebElement> action) { String[] nodes = SplitToList(names); if (menuLevelsLocators.size() == 0 && hasLocator()) menuLevelsLocators.add(getLocator()); if (menuLevelsLocators.size() < nodes.length) return; for(int i = 0; i < nodes.length; i++) { String value = nodes[i]; List<WebElement> elements = new Selector<>(menuLevelsLocators.get(i)).getElements(); WebElement element = first(elements, el -> el.getText().equals(value)); action.accept(element); } }
private String getSelected(List<WebElement> els) { WebElement element = first(els, this::isSelectedAction); if (element == null) throw exception("No elements selected. Override getSelectedAction or place locator to <select> tag"); new Element(element).invoker.processDemoMode(); return element.getText(); }
private String getSelected(List<WebElement> els) { WebElement element = first(els, this::isSelectedAction); if (element == null) throw exception("No elements selected. Override getSelectedAction or place locator to <select> tag"); new Element(element).invoker.processDemoMode(); return element.getText(); }
private Cell addCell(int colIndex, int rowIndex, int colNum, int rowNum, String colName, String rowName) { Cell cell = allCells.size() != 0 ? (Cell) first(allCells, c -> c.columnNum() == colNum && c.rowNum() == rowNum) : null; if (cell != null) return cell.updateData(colName, rowName); cell = new Cell(colIndex, rowIndex, colNum, rowNum, colName, rowName, this); cell.setParent(this); if (cache) allCells.add(cell); return cell; }
private Cell addCell(int colIndex, int rowIndex, int colNum, int rowNum, String colName, String rowName) { Cell cell = allCells.size() != 0 ? (Cell) first(allCells, c -> c.columnNum() == colNum && c.rowNum() == rowNum) : null; if (cell != null) return cell.updateData(colName, rowName); cell = new Cell(colIndex, rowIndex, colNum, rowNum, colName, rowName, this); cell.setParent(this); if (cache) allCells.add(cell); return cell; }
private Cell addCell(WebElement webElement, int colNum, int rowNum, String colName, String rowName) { Cell cell = (Cell) first(allCells, c -> c.columnNum() == colNum && c.rowNum() == rowNum); if (cell != null) { cell.setWebElement(webElement); return cell.updateData(colName, rowName); } cell = new Cell(webElement, colNum, rowNum, colName, rowName, this); if (cache) allCells.add(cell); return cell; } }
private Cell addCell(WebElement webElement, int colNum, int rowNum, String colName, String rowName) { Cell cell = (Cell) first(allCells, c -> c.columnNum() == colNum && c.rowNum() == rowNum); if (cell != null) { cell.setWebElement(webElement); return cell.updateData(colName, rowName); } cell = new Cell(webElement, colNum, rowNum, colName, rowName, this); if (cache) allCells.add(cell); return cell; } }
private Cell addCell(WebElement webElement, int colNum, int rowNum, String colName, String rowName) { Cell cell = (Cell) first(allCells, c -> c.columnNum() == colNum && c.rowNum() == rowNum); if (cell != null) { cell.setWebElement(webElement); return cell.updateData(colName, rowName); } cell = new Cell(webElement, colNum, rowNum, colName, rowName, cellLocatorTemplate, this); if (cache) allCells.add(cell); return cell; } }