Skip to content

Commit

Permalink
5076 Fix Autocomplete tests
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-korost committed Sep 21, 2023
1 parent 1d0a32f commit 856dc27
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package io.github.com;

import com.epam.jdi.light.elements.pageobjects.annotations.JSite;
import com.epam.jdi.light.elements.pageobjects.annotations.Url;;
import io.github.com.pages.AngularPage;
import io.github.com.pages.ButtonsPage;
import io.github.com.pages.ProgressBarPage;
import io.github.com.pages.ProgressSpinnerPage;
import com.epam.jdi.light.elements.pageobjects.annotations.Url;
import io.github.com.pages.*;

@JSite("https://jdi-testing.github.io/jdi-light/angular-page/#/")
public class StaticSite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class AutocompletePage extends NewAngularPage {
@UI("#autocomplete-display-value-input")
public AutoComplete displayValueAutocomplete;

@UI("label[for='autocomplete-display-value-input'] > mat-label")
public AutoComplete displayValueLabelAutocomplete;

@UI("#autocomplete-filter-input")
public AutoComplete filterAutocomplete;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.github.epam.TestsInit;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;

import java.util.Arrays;
Expand All @@ -11,9 +10,8 @@
import java.util.Map;

import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.*;
import static io.github.com.StaticSite.autocompletePage;

// TODO Move to the new page
public class AutocompleteTests extends TestsInit {

@BeforeClass
Expand Down Expand Up @@ -66,7 +64,7 @@ public void verifySimpleAutocomplete() {

@Test
public void verifyDisplayValueAutocomplete() {
autocompletePage.displayValueAutocomplete.has().displayValue("Assignee");
autocompletePage.displayValueLabelAutocomplete.has().text("Assignee");
autocompletePage.displayValueAutocomplete.has().placeholder("");
autocompletePage.displayValueAutocomplete.is().enabled();
autocompletePage.displayValueAutocomplete.is().notMandatory();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#arguments=--headless
arguments=--headless
2 changes: 1 addition & 1 deletion jdi-light-angular-tests/src/test/resources/test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ log.level=INFO
#remote.type=sauce | browserstack
#driver.remote.url=http://localhost:4444/wd/hub
screenshot.strategy=on failure|on assert
headless=false
headless=true
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public AutoCompleteAssert collapsed() {
@JDIAction("Assert that '{name}' text {0}")
@Override
public AutoCompleteAssert text(String expected) {
jdiAssert(element().getValue(), Matchers.is(expected));
jdiAssert(element().getText(), Matchers.is(expected));
return this;
}

Expand Down Expand Up @@ -79,7 +79,7 @@ public AutoCompleteAssert valid() {

@JDIAction("Assert that '{name}' has display value")
public AutoCompleteAssert displayValue(String expected) {
jdiAssert(element().displayValue(), Matchers.is(expected));
jdiAssert(element().getValue(), Matchers.is(expected));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
public class AutoComplete extends UIBaseElement<AutoCompleteAssert> implements HasLabel, SetValue, HasPlaceholder, IsInput, IsText {

private String optionsCss = "mat-option";
private String optionsGroupsCss = "mat-optgroup>label";
private String optionsGroupsCss = "mat-optgroup > span";
private String optionsGroupsAndValuesCss = "mat-optgroup";
private String displayValueCss = "mat-label";
private String autocompleteAttrPrefix = "_ngcontent-";
Expand Down Expand Up @@ -80,7 +80,7 @@ public Boolean isOptionHighlighted(String value) {
WebList values = getOptions(optionsCss);
UIElement element = values.get(value);
String selected = element.core().getAttribute("class");
return selected.contains("mat-active");
return selected.contains("mat-mdc-option-active");
}

public void setValue(String inputValue, String selectValue) {
Expand Down Expand Up @@ -215,7 +215,7 @@ public Boolean isMandatory() {

@JDIAction("Is '{name} invalidated")
public Boolean isInvalidated() {
return "true".equals(core().getAttribute("aria-invalid"));
return core().getAttribute("class").contains("ng-invalid");
}

@JDIAction("Is '{name} disabled")
Expand Down

0 comments on commit 856dc27

Please sign in to comment.