Java tutorial
/* * Copyright (c) 2010-2018 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.evolveum.midpoint.schrodinger.component.common.table; import com.codeborne.selenide.Condition; import com.codeborne.selenide.SelenideElement; import com.evolveum.midpoint.schrodinger.MidPoint; import com.evolveum.midpoint.schrodinger.component.Component; import com.evolveum.midpoint.schrodinger.component.common.Paging; import com.evolveum.midpoint.schrodinger.component.common.Search; import com.evolveum.midpoint.schrodinger.util.Schrodinger; import org.openqa.selenium.By; import static com.codeborne.selenide.Selenide.$; /** * Created by Viliam Repan (lazyman). */ public class Table<T> extends Component<T> { public Table(T parent, SelenideElement parentElement) { super(parent, parentElement); } public Search<? extends Table> search() { SelenideElement searchElement = getParentElement().$(By.cssSelector(".form-inline.pull-right.search-form")); return new Search<>(this, searchElement); } public Paging<T> paging() { SelenideElement pagingElement = getParentElement().$(By.className("boxed-table-footer-paging")); return new Paging(this, pagingElement); } public Table<T> selectAll() { $(Schrodinger.bySelfOrAncestorElementAttributeValue("input", "type", "checkbox", "data-s-id", "topToolbars")).waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S).click(); return this; } public boolean currentTableContains(String name) { // TODO replate catch Throwable with some less generic error try { return $(Schrodinger.byElementValue("Span", name)) .waitUntil(Condition.visible, MidPoint.TIMEOUT_MEDIUM_6_S).is(Condition.visible); } catch (Throwable t) { return false; } } }