com.codeborne.selenide.ElementsCollection Java Examples
The following examples show how to use
com.codeborne.selenide.ElementsCollection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableImpl.java From masquerade with Apache License 2.0 | 7 votes |
@Override public ElementsCollection selectRows(By rowBy) { this.shouldBe(VISIBLE) .shouldBe(LOADED) .shouldBe(ENABLED); ElementsCollection rows = getRows(rowBy); WebDriver webDriver = WebDriverRunner.getWebDriver(); Actions action = new Actions(webDriver); for (SelenideElement row : rows) { row.shouldNotHave(selectedClass); Keys controlKey = getControlKey(); action.keyDown(controlKey) .click(row.getWrappedElement()) .keyUp(controlKey) .build() .perform(); } return rows; }
Example #2
Source File: TabSheetImpl.java From masquerade with Apache License 2.0 | 6 votes |
@Override public List<Tab> getVisibleTabs() { shouldBe(VISIBLE); String tabsXpath = "./div[(contains(@class, 'v-tabsheet-tabcontainer'))]" + "//td[contains(@class, 'v-tabsheet-tabitemcell')]"; ElementsCollection elements = $$(byChain(by, byXpath(tabsXpath))); List<Tab> tabs = new ArrayList<>(); for (int i = 0; i < elements.size(); i++) { tabs.add(new TabImpl(byTarget(elements.get(i)), "Tab.index: " + i)); } return tabs; }
Example #3
Source File: LocatorMap.java From justtestlah with Apache License 2.0 | 6 votes |
/** * Get a Selenide collection locator. * * @param key locator key * @param platform platform * @param params locator key parameters * @return {@link ElementsCollection} */ public ElementsCollection getCollectionLocator(String key, Platform platform, Object... params) { Pair<String, String> platformKey = getRawLocator(key, platform, params); String type = platformKey.getLeft(); String rawValue = platformKey.getRight(); if (type.equalsIgnoreCase(CSS)) { return $$(By.cssSelector(formatValue(rawValue, params))); } else if (type.equalsIgnoreCase(XPATH)) { return $$(By.xpath(formatValue(rawValue, params))); } else if (type.equalsIgnoreCase(ID)) { return $$(By.id(formatValue(rawValue, params))); } else if (type.equalsIgnoreCase(ACCESIBILITY_ID)) { return $$(ByAccessibilityId.AccessibilityId(formatValue(rawValue, params))); } else if (type.equalsIgnoreCase(UIAUTOMATOR)) { return $$(ByAndroidUIAutomator.AndroidUIAutomator(formatValue(rawValue, params))); } else if (type.equalsIgnoreCase(IMAGE)) { return $$(MobileBy.image(ImageUtils.getImageAsBase64String(rawValue))); } else { return $$(formatValue(rawValue, params)); } }
Example #4
Source File: DataGridImpl.java From masquerade with Apache License 2.0 | 6 votes |
@Override public ElementsCollection selectRows(By rowBy) { this.shouldBe(VISIBLE) .shouldBe(LOADED) .shouldBe(ENABLED); ElementsCollection rows = getRows(rowBy); WebDriver webDriver = WebDriverRunner.getWebDriver(); Actions action = new Actions(webDriver); for (SelenideElement row : rows) { row.shouldNotHave(selectedClass); Keys controlKey = getControlKey(); action.keyDown(controlKey) .click(row.getWrappedElement()) .keyUp(controlKey) .build() .perform(); } return rows; }
Example #5
Source File: ComponentFactory.java From n2o-framework with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public <T extends ComponentsCollection> T produce(ElementsCollection elements, Class<T> collectionClass) { T collection = (T) findAndProduce(collectionClass, collections); collection.setElements(elements); return collection; }
Example #6
Source File: AkitaPage.java From akita with Apache License 2.0 | 5 votes |
private void checkCollectionFieldType(Field f) { if (ElementsCollection.class.isAssignableFrom(f.getType())) { return; } else if (List.class.isAssignableFrom(f.getType())) { ParameterizedType listType = (ParameterizedType) f.getGenericType(); Class<?> listClass = (Class<?>) listType.getActualTypeArguments()[0]; if (SelenideElement.class.isAssignableFrom(listClass) || AkitaPage.class.isAssignableFrom(listClass)) { return; } } throw new IllegalStateException( format("Поле с аннотацией @Name должно иметь тип SelenideElement или List<SelenideElement>.\n" + "Если поле описывает блок, оно должно принадлежать классу, унаследованному от AkitaPage.\n" + "Найдено поле с типом %s", f.getType())); }
Example #7
Source File: AkitaPage.java From akita with Apache License 2.0 | 5 votes |
/** * Получение элемента-списка со страницы по имени */ @SuppressWarnings("unchecked") public ElementsCollection getElementsList(String listName) { Object value = namedElements.get(listName); if (!(value instanceof List)) { throw new IllegalArgumentException("Список " + listName + " не описан на странице " + this.getClass().getName()); } FindBy listSelector = Arrays.stream(this.getClass().getDeclaredFields()) .filter(f -> f.getDeclaredAnnotation(Name.class) != null && f.getDeclaredAnnotation(Name.class).value().equals(listName)) .map(f -> f.getDeclaredAnnotation(FindBy.class)) .findFirst().get(); FindBy.FindByBuilder findByBuilder = new FindBy.FindByBuilder(); return $$(findByBuilder.buildIt(listSelector, null)); }
Example #8
Source File: ListVerificationSteps.java From akita with Apache License 2.0 | 5 votes |
/** * Проверка появления списка на странице в течение DEFAULT_TIMEOUT. * В случае, если свойство "waitingCustomElementsTimeout" в application.properties не задано, * таймаут равен 10 секундам */ @Тогда("^список \"([^\"]*)\" отображается на странице$") @When("^list \"([^\"]*)\" is visible$") public void listIsPresentedOnPage(String elementName) { ElementsCollection elements = akitaScenario.getCurrentPage().getElementsList(elementName); akitaScenario.getCurrentPage().waitElementsUntil( Condition.appear, DEFAULT_TIMEOUT, elements); }
Example #9
Source File: SelenideAppiumFieldDecorator.java From selenide-appium with MIT License | 5 votes |
@Override public Object decorate(ClassLoader loader, Field field) { builder.setAnnotated(field); By selector = builder.buildBy(); if (selector == null) { selector = new Annotations(field).buildBy(); } if (selector instanceof ByIdOrName) { return decorateWithAppium(loader, field); } else if (SelenideElement.class.isAssignableFrom(field.getType())) { return ElementFinder.wrap(driver, driver.getWebDriver(), selector, 0); } else if (ElementsCollection.class.isAssignableFrom(field.getType())) { return new ElementsCollection(new BySelectorCollection(driver, selector)); } else if (ElementsContainer.class.isAssignableFrom(field.getType())) { return createElementsContainer(selector, field); } else if (isDecoratableList(field, ElementsContainer.class)) { return createElementsContainerList(field); } else if (isDecoratableList(field, SelenideElement.class)) { return SelenideElementListProxy.wrap(driver, factory.createLocator(field)); } return super.decorate(loader, field); }
Example #10
Source File: N2oInputSelect.java From n2o-framework with Apache License 2.0 | 5 votes |
@Override public void shouldSelectedMulti(String... values) { ElementsCollection selectedItems = element().$$(".n2o-input-select-selected-list .selected-item"); selectedItems.shouldHaveSize(values.length); if (values.length != 0) selectedItems.shouldHave(CollectionCondition.textsInAnyOrder(values)); }
Example #11
Source File: SelenideAddons.java From neodymium-library with MIT License | 5 votes |
/** * Returns an supplier that will return all results if any. It will return elements that are found by parentSelector * and have a no result for subElementSelector. It does NOT return the subelements, it is meant to be a workaround * for poor CSS where the parent is only recognizable by looking at its children, but we don't need the children. * Important, this is meant to be lazy so don't call get() when you setup a field or so, only when you really need * the element. It reselects all the time! * * @param parentSelector * The selector that is used to find subElementSelector * @param subElementSelector * The selector that shall not be contained by the parentSelector * @return an supplier that will return the result later */ public static Supplier<ElementsCollection> parentsWithoutSubElement(final By parentSelector, final By subElementSelector) { return new Supplier<ElementsCollection>() { @Override public ElementsCollection get() { List<SelenideElement> list = $$(parentSelector).stream().filter(e -> { return !e.$(subElementSelector).exists(); }).collect(Collectors.toList()); return new ElementsCollection(new WebElementsCollectionWrapper(WebDriverRunner.driver(), list)); }; }; }
Example #12
Source File: SelenideAddons.java From neodymium-library with MIT License | 5 votes |
/** * Returns an supplier that will return all results if any. It will return elements that are found by parentSelector * and have a result for subElementSelector. It does NOT return the subelements, it is meant to be a workaround for * poor CSS where the parent is only recognizable by looking at its children, but we don't need the children. * Important, this is meant to be lazy so don't call get() when you setup a field or so, only when you really need * the element. It reselects all the time! * * @param parentSelector * The selector that is used to find subElementSelector * @param subElementSelector * The selector that is shall have the element selected by parentSelector * @return an supplier that will return the result later */ public static Supplier<ElementsCollection> parentsBySubElement(final By parentSelector, final By subElementSelector) { return new Supplier<ElementsCollection>() { @Override public ElementsCollection get() { List<SelenideElement> list = $$(parentSelector).stream().filter(e -> { return e.$(subElementSelector).exists(); }).collect(Collectors.toList()); return new ElementsCollection(new WebElementsCollectionWrapper(WebDriverRunner.driver(), list)); }; }; }
Example #13
Source File: TableImpl.java From masquerade with Apache License 2.0 | 5 votes |
@Override @Deprecated public ElementsCollection getAllLines() { this.shouldBe(VISIBLE) .shouldBe(LOADED); return impl.findAll(TagNames.TR); }
Example #14
Source File: N2oSelenide.java From n2o-framework with Apache License 2.0 | 4 votes |
public static <T extends ComponentsCollection> T collection(ElementsCollection elements, Class<T> collectionClass) { return factory.produce(elements, collectionClass); }
Example #15
Source File: SearchResultsPage.java From google with MIT License | 4 votes |
public ElementsCollection getResults() { return $$("#res .g"); }
Example #16
Source File: TableImpl.java From masquerade with Apache License 2.0 | 4 votes |
@Override public ElementsCollection getCells(int row) { return getAllLines().get(row).findAll(TagNames.TD); }
Example #17
Source File: N2oComponentsCollection.java From n2o-framework with Apache License 2.0 | 4 votes |
public ElementsCollection elements() { return elements; }
Example #18
Source File: N2oComponentsCollection.java From n2o-framework with Apache License 2.0 | 4 votes |
@Override public void setElements(ElementsCollection elements) { this.elements = elements; }
Example #19
Source File: N2oCodeEditor.java From n2o-framework with Apache License 2.0 | 4 votes |
@Override public void shouldBeEmpty() { ElementsCollection lines = element().$$(".ace_line"); lines.shouldHaveSize(1); lines.get(0).shouldBe(Condition.empty); }
Example #20
Source File: N2oInputSelect.java From n2o-framework with Apache License 2.0 | 4 votes |
@Override public void clearItems(String... items) { ElementsCollection selectedItems = element().$$(".n2o-input-select-selected-list .selected-item"); Arrays.stream(items).forEach(s -> selectedItems.find(Condition.text(s)).$("button").click()); }
Example #21
Source File: N2oInputSelect.java From n2o-framework with Apache License 2.0 | 4 votes |
private ElementsCollection popUpButtons() { return selectPopUp().$$("button"); }
Example #22
Source File: N2oDropdownButton.java From n2o-framework with Apache License 2.0 | 4 votes |
private ElementsCollection menuItems() { return element().parent().$$("div.dropdown-menu .btn.btn-secondary,.dropdown-item"); }
Example #23
Source File: Table.java From masquerade with Apache License 2.0 | 2 votes |
/** * Will be removed in 2.0 * * @deprecated Use {@link #getRows(By)} with {@link Selectors#isVisible()} * @return all rows */ @Deprecated ElementsCollection getAllLines();
Example #24
Source File: Spectators.java From akita with Apache License 2.0 | 2 votes |
/** * Перегрузка метода для работы с ElementsCollection и использования стандартных методов обработки списков * * @param selenideCondition Selenide.Condition * @param timeout максимальное время ожидания в миллисекундах для перехода элементов в заданное состояние * @param selenideElements ElementsCollection */ public static void waitElementsUntil(Condition selenideCondition, int timeout, ElementsCollection selenideElements) { selenideElements.shouldBe(conditionToConditionCollection(selenideCondition), timeout); }
Example #25
Source File: AkitaPage.java From akita with Apache License 2.0 | 2 votes |
/** * Обертка над Selenide.waitUntil для работы со списком элементов * * @param elements список selenide-элементов */ public void waitElementsUntil(Condition condition, int timeout, ElementsCollection elements) { Spectators.waitElementsUntil(condition, timeout, elements); }
Example #26
Source File: BasePage.java From justtestlah with Apache License 2.0 | 2 votes |
/** * Selenide style collection locator. * * @param locatorKey locator key (can include placeholders) * @param params parameters to replace the placeholders * @return {@link ElementsCollection} */ @SuppressWarnings("squid:S00100") protected ElementsCollection $$(String locatorKey, Object... params) { return Selenide.$$( locators.getCollectionLocator(locatorKey, configuration.getPlatform(), params)); }
Example #27
Source File: Table.java From masquerade with Apache License 2.0 | 2 votes |
/** * Obtain reference to Table rows. * <br> * Supported bys: * <ul> * <li>{@link Selectors#byText(String)}</li> * <li>{@link Selectors#byCells(String...)}</li> * <li>{@link Selectors#withText(String)}</li> * <li>{@link Selectors#byRowIndex(int)}</li> * <li>{@link Selectors#byIndex(int)}</li> * <li>{@link Selectors#isSelected()}</li> * <li>{@link Selectors#isVisible()}</li> * </ul> * * @param rowBy row selector * @return selenide element collection */ ElementsCollection getRows(By rowBy);
Example #28
Source File: Table.java From masquerade with Apache License 2.0 | 2 votes |
/** * Obtain reference to Table cell. * <br> * Supported bys: * <ul> * <li>{@link Selectors#byText(String)}</li> * <li>{@link Selectors#withText(String)}</li> * <li>{@link Selectors#byClassName(String)}</li> * <li>{@link Selectors#byRowIndex(int)}</li> * </ul> * * @param cellBy cell selector * @return selenide element */ ElementsCollection getCells(By cellBy);
Example #29
Source File: Table.java From masquerade with Apache License 2.0 | 2 votes |
/** * Select Table rows. * <br> * Supported bys: * <ul> * <li>{@link Selectors#byText(String)}</li> * <li>{@link Selectors#byCells(String...)}</li> * <li>{@link Selectors#withText(String)}</li> * <li>{@link Selectors#isSelected()}</li> * <li>{@link Selectors#byRowIndex(int)}</li> * <li>{@link Selectors#byIndex(int)}</li> * </ul> * * @param rowBy row selector * @return selenide element collection */ @Log ElementsCollection selectRows(By rowBy);
Example #30
Source File: DataGrid.java From masquerade with Apache License 2.0 | 2 votes |
/** * Select DataGrid rows. * <br> * Supported bys: * <ul> * <li>{@link Selectors#byText(String)}</li> * <li>{@link Selectors#byCells(String...)}</li> * <li>{@link Selectors#withText(String)}</li> * <li>{@link Selectors#isSelected()}</li> * <li>{@link Selectors#byRowIndex(int)}</li> * <li>{@link Selectors#byIndex(int)}</li> * </ul> * * @param rowBy row selector * @return selenide element collection */ ElementsCollection selectRows(By rowBy);