/** * Проверка, что у элемента есть атрибут с ожидаемым значением (в приоритете: из property, из переменной сценария, значение аргумента) */ @Тогда("^элемент \"([^\"]*)\" содержит атрибут \"([^\"]*)\" со значением \"(.*)\"$") public void checkElemContainsAtrWithValue(String elementName, String attribute, String expectedAttributeValue) { expectedAttributeValue = getPropertyOrStringVariableOrValue(expectedAttributeValue); SelenideElement currentElement = akitaScenario.getCurrentPage().getElement(elementName); String currentAtrValue = currentElement.attr(attribute); assertThat(String.format("Элемент [%s] не содержит атрибут [%s] со значением [%s]", elementName, attribute, expectedAttributeValue) , currentAtrValue, equalToIgnoringCase(expectedAttributeValue)); }
public boolean isTestFailure() { boolean isFailure = false; $(Schrodinger.byDataId("div", "messagesPanel")).waitUntil(Condition.appears, MidPoint.TIMEOUT_LONG_1_M); ElementsCollection detailBoxes = $$(Schrodinger.byDataId("div", MODAL_FEEDBACK_BOX_ID)); for (SelenideElement element : detailBoxes) { element.waitUntil(Condition.appears, MidPoint.TIMEOUT_LONG_1_M); String attr = element.attr("class"); if (attr != null && !attr.isEmpty()) { if (attr.contains("box-danger")) { isFailure = true; break; } } } clickOk(); // Not sure if this is good practice return isFailure; }
String attr = element.attr("class");
public FocusSetAssignmentsModal<T> selectType(String option) { SelenideElement tabElement = $(Schrodinger.byElementValue("a", "class", "tab-label", option)) .waitUntil(Condition.appears, MidPoint.TIMEOUT_DEFAULT_2_S); String classActive = tabElement.attr("class"); tabElement.click(); if (!classActive.contains("active")) { $(Schrodinger.byElementValue("a", "class", "tab-label", option)) .waitUntil(Condition.attribute("class", classActive + " active"), MidPoint.TIMEOUT_DEFAULT_2_S).exists(); } return this; }