public Boolean compareInputAttributeValue(String name, String expectedValue) { SelenideElement property = findProperty(name); SelenideElement value = property.$(By.xpath(".//input[contains(@class,\"form-control\")]")); String valueElement = value.getValue(); if (!valueElement.isEmpty()) { return valueElement.equals(expectedValue); } else if (!expectedValue.isEmpty()) { return false; } else { return true; } }
public Paging<T> pageSize(int size) { Validate.isTrue(size > 0, "Size must be larger than zero."); SelenideElement parent = getParentElement(); SelenideElement button = parent.$(By.cssSelector(".btn.btn-default.dropdown-toggle")); button.click(); button.parent().$(By.className("dropdown-menu")).$$x(".//a").first().click(); SelenideElement popover = parent.$$(By.className("popover-title")) .findBy(Condition.text("Page size")).parent(); //todo fix localization popover.$(By.tagName("input")).setValue(Integer.toString(size)); popover.$(By.tagName("button")).click(); return this; }
private void moveThroughPages(int offsetFromActual) { SelenideElement ul = getParentElement().$(By.cssSelector(".pagination.pagination-sm.no-margin.pull-right")); ElementsCollection col = ul.$$x(".//li"); SelenideElement active = col.find(Condition.cssClass("active")); int index = col.indexOf(active); index = index + offsetFromActual; if (index < 2 || index > col.size() - 2) { // it's <<, <, >, >> throw new SchrodingerException("Can't move through paging, page doesn't exist"); } col.get(index).$x(".//a").click(); }
public Paging<T> paging() { SelenideElement pagingElement = getParentElement().$(By.className("boxed-table-footer-paging")); return new Paging(this, pagingElement); }
public Paging<T> previous() { getParentElement().$(Schrodinger.byElementValue("a", "<")).click(); return this; }
public String getSystemProperty(String propertyNameUserHome) { SelenideElement propertiesTable = $(Schrodinger.byElementValue("h3","System properties")).waitUntil(Condition.appear,MidPoint.TIMEOUT_DEFAULT_2_S).parent().$(By.cssSelector(".table.table-striped")); ReadOnlyTable readOnlyTable = new ReadOnlyTable(this,propertiesTable); return readOnlyTable.getParameterValue(propertyNameUserHome); } }
public PrismForm<T> removeFileAsAttributeValue(String name) { SelenideElement property = findProperty(name); property.$(Schrodinger.byElementAttributeValue("a", "title", "Remove file")).click(); return this; }
public String getTabBadgeText(String resourceKey) { SelenideElement element = getParentElement().$(Schrodinger.bySchrodingerDataResourceKey(resourceKey)); element.shouldBe(Condition.visible); SelenideElement badge = element.$(Schrodinger.byDataId("small", "count")); badge.shouldBe(Condition.visible); return badge.getValue(); }
@Override public Search<ResourcesPageTable<T>> search() { SelenideElement searchElement = getParentElement().$(By.cssSelector(".form-inline.pull-right.search-form")); return new Search<>(this, searchElement); } }
@Override public ViewResourcePage clickByName(String name) { getParentElement().$(Schrodinger.byElementValue("span", "data-s-id", "label", name)) .waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S).click(); return new ViewResourcePage(); }
public PrismForm<T> setDropDownAttributeValue(QName name, String value) { SelenideElement property = findProperty(name); ElementsCollection values = property.$$(By.className("prism-property-value")); if (values.size() > 0) { SelenideElement dropDown = values.first().$(By.tagName("select")); if (dropDown != null){ dropDown.selectOptionContainingText(value); } } return this; }
public PrismForm<T> setFileForUploadAsAttributeValue(String name, File file) { SelenideElement property = findProperty(name); property.$(By.cssSelector("input.form-object-value-binary-file-input")).uploadFile(file); return this; }
public PrismForm<T> addAttributeValue(String name, String value) { SelenideElement property = findProperty(name); $(By.className("prism-properties")).waitUntil(Condition.appears,MidPoint.TIMEOUT_MEDIUM_6_S); ElementsCollection values = property.$$(By.className("prism-property-value")); if (values.size() == 1) { values.first().$(By.className("form-control")).setValue(value); } // todo implement return this; }
private SelenideElement verifyAndFetchActiveTab(SelenideElement link) { link.shouldBe(Condition.visible); link.click(); SelenideElement li = link.parent(); li.shouldHave(Condition.cssClass("active")); return li.parent().parent().$(By.cssSelector(".tab-pane.active")); } }
public PrismForm<T> addAttributeValue(QName name, String value) { SelenideElement property = findProperty(name); ElementsCollection values = property.$$(By.className("prism-property-value")); if (values.size() == 1) { values.first().$(By.className("form-control")).setValue(value); } // todo implement return this; }
public PrismForm<T> changeAttributeValue(String name, String oldValue, String newValue) { SelenideElement property = findProperty(name); $(By.className("prism-properties")).waitUntil(Condition.appears,MidPoint.TIMEOUT_MEDIUM_6_S); ElementsCollection values = property.$$(By.className("prism-property-value")); if (values.size() == 1) { values.first().$(By.className("form-control")).setValue(newValue); } // todo implement return this; }
public LoginPage logout() { SelenideElement userMenu = $(".dropdown.user.user-menu"); userMenu.$(By.cssSelector(".dropdown-toggle")).click(); userMenu.$(By.cssSelector(".user-footer")) .$(Schrodinger.byElementAttributeValue("input", "type", "submit")).click(); //todo implement return new LoginPage(); } }
@Override public UserPage clickByName(String name) { getParentElement().$(Schrodinger.byElementValue("span", "data-s-id", "label", name)) .waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S).click(); return new UserPage(); }
public InputBox<Search<T>> byFullText() { SelenideElement linksContainer = getParentElement().$(Schrodinger.byDataId("div", "linksContainer")).waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S); try { linksContainer.$(Schrodinger.byDataId("a", "fullText")).waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S).click(); } catch (Throwable t) { // all is ok, fullText search is already selected option, TODO: Schrodinger should provide easy method to check component existence } // we assume fulltext is enabled in systemconfig, else error is thrown here: SelenideElement fullTextField = getParentElement().$(Schrodinger.byDataId("input", "fullTextField")).waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S); return new InputBox<> (this, fullTextField); } }