Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4911-refactoringRadioButtonTests #5087

Merged
merged 36 commits into from
Nov 19, 2023

Conversation

MayaElf
Copy link
Contributor

@MayaElf MayaElf commented Oct 2, 2023

No description provided.

@MayaElf MayaElf requested a review from vklonin October 2, 2023 09:44
@MayaElf MayaElf self-assigned this Oct 2, 2023
@MayaElf MayaElf changed the title 4911-refactoringRadioButtonTests [WIP] 4911-refactoringRadioButtonTests Oct 2, 2023
@MayaElf MayaElf linked an issue Oct 2, 2023 that may be closed by this pull request
12 tasks
@MayaElf MayaElf force-pushed the 4911_radioButtonTestsRefactoring branch from b7e3ec3 to b1559df Compare October 17, 2023 13:27
@MayaElf MayaElf changed the title [WIP] 4911-refactoringRadioButtonTests 4911-refactoringRadioButtonTests Oct 19, 2023
@MayaElf MayaElf requested a review from pnatashap October 19, 2023 11:23
Copy link
Contributor

@pnatashap pnatashap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the control was checked

@@ -17,15 +17,15 @@ public class RadioButtons extends com.epam.jdi.light.ui.html.elements.complex.Ra
@Override
public WebList list() {
WebList radioBtnWebList = new WebList(base()).setup(b -> b.setSearchRule("Any", ANY_ELEMENT))
.setUIElementName(LABEL);
.setUIElementName(LABEL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мы не трогаем никакой проект, кроме ангуляра

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправила


/**
* To see an example of RadioButtons web element please visit https://material.angular.io/components/radio/overview.
*/

public class RadioButtons extends UIBaseElement<RadioButtonsAssert> {
public class RadioButtons extends UIListBase<UISelectAssert<RadioButtonsAssert, RadioButtons>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласно наименованиям angular это называется RadioGroup, мы всегда сохраняем имена
RadioButton - отдельный элемент со своими свойствами, именно их список мы должны уметь возвращать

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

изменила


@JDIAction("Click '{name}' button by tag value '{0}'")
public void click(String value) {
getRadioButtonByTagValue(value).click();
getRadioButtonByTagValue(value).find(By.cssSelector(".mdc-form-field")).click();
}

@JDIAction("'{name}' radio button contain value '{0}'")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

комментарий не соответствует возвращаемому значению

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправила

@@ -32,6 +35,35 @@ private UIElement getRadioButtonByTagValue(String value) {
return element;
}

public AngularColors color(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

цвет - свойство отдельного элемента, вот туда и надо его вынести

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у нас в других реализациях (смотрела bootstrap и material-ui) тоже сделано только через группу, нет отдельного элемента кнопки.
вы предлагаете в ангуляре сделать отдельную реализацию для кнопки, правильно понимаю комментарий?

if (getRadioButtonByTagValue(value).hasClass("mat-primary")) {
return AngularColors.PRIMARY;
}
if (getRadioButtonByTagValue(value).hasClass("mat-warn")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

каждый раз вызывать поиск элемента - очень плохо, элемент нужно получать один раз

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправила


@JDIAction("'{name}'aria-label is '{0}'")
public boolean isAriaLabel(String ariaLabel) {
return core().attr("aria-label").equalsIgnoreCase(ariaLabel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже самое с area-label, как в предыдущем ПР

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

удалила


@JDIAction("'{name}'label is in before position")
public boolean isBeforePosition() {
return core().attr("labelposition").equalsIgnoreCase("before");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

свойство может стоять на группе (или не стоять) и отдельно у каждого radio может быть переопределено, это половина решения, получается

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавила

@MayaElf MayaElf requested a review from pnatashap October 25, 2023 11:23
@MayaElf MayaElf force-pushed the 4911_radioButtonTestsRefactoring branch from de3722f to a25a035 Compare October 25, 2023 11:28
Copy link
Contributor

@pnatashap pnatashap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предыдущий комментарий не понят

return core().hasAttribute("disabled");
}

@JDIAction("'{name}'is required")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@JDIAction("'{name}'is required")
@JDIAction("'{name}' is required")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проставила пробелы

return getRadioButtonByTagValue(value).attr("class").contains("mat-mdc-radio-checked");
}

private UIElement getRadioButtonByTagValue(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Метод должен быть public, так же должен быть метод, который получает весь список RadioButton.

Допустим, нам нужно сделать проверки для всех элементов в RadioGroup, мы должны иметь возможность получить список и прогнать. Если мы каждый раз будем получать по имени, это будет крайне медленно.
Помимо того, что сейчас у нас нет возможности проверить, какие опции нам туда подсунули.
Я в предыдущем ревью написала, что нам нужен класс для описания группы и для описания каждого отдельного RadioButton

Copy link
Contributor Author

@MayaElf MayaElf Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. public + аннтоция проставлены
  2. у нас есть реализованный метод getRadioButtons(), как раз используем его для получения кнопки по имени.
    @JDIAction("Get radio button by tag value {0}")
    public UIElement getRadioButtonByTagValue(String value) {
    UIElement element = null;
    for (UIElement e : getRadioButtons()) {
    if (e.find("input").attr("value").equalsIgnoreCase(value)) {
    element = e;
    }
    }
    return element;
    }
  3. отдельный RadioButton, насколько я поняла, обсуждаем сегодня 26 10 23 в 16.00 на синке

import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matchers;

import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert;

public class RadioButtonsAssert extends UIAssert<RadioButtonsAssert, RadioButtons> {
public class RadioButtonsAssert extends UISelectAssert<RadioButtonsAssert, RadioGroup> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Раз мы переименовали в RadioButton, и этот класс тоже должен был следом переименоваться

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

заменила

public class RadioButtonTests extends TestsInit {
private static final String SPRING = "Spring";
private static final String SUMMER = "Summer";
private static final String AUTUMN = "Autumn";
private static final String WINTER = "Winter";
private static final String primary = "primary";
private static final String accent = "accent";
private static final String warn = "warn";

@BeforeMethod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В предыдущем ПР уже писала про BeforeMethod

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

заменила

@pnatashap
Copy link
Contributor

@MayaElf MayaElf requested a review from pnatashap October 26, 2023 11:42
Copy link
Contributor

@pnatashap pnatashap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я так и не вижу класса для описания RadioButton и его проверок, как в указанном примере

getRadioButtonByTagValue(value).find(By.cssSelector(".mdc-form-field")).click();
}

@JDIAction("'{name}' radio button contain value '{0}'")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

комментарий не соответствует функции

@MayaElf MayaElf force-pushed the 4911_radioButtonTestsRefactoring branch from 1402f58 to 609725d Compare October 31, 2023 14:47
@MayaElf MayaElf requested a review from pnatashap October 31, 2023 14:53
Copy link
Contributor

@pnatashap pnatashap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тесты не смотрела, только контролы

import org.openqa.selenium.By;

public class RadioButton extends UIBaseElement<RadioButtonAssert> implements HasLabel {
private static final String INPUT_SELECTION_CONTROL = "//input[@type='radio']";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final String INPUT_SELECTION_CONTROL = "//input[@type='radio']";
private static final String INPUT_SELECTION_CONTROL = ".//input[@type='radio']";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поправила

}

@JDIAction("'{name}' element label is in before position")
public boolean isRadioButtonBeforePosition() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public boolean isRadioButtonBeforePosition() {
public boolean hasBeforePosition() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поправила


@JDIAction("'{name}' element label is in before position")
public boolean isRadioButtonBeforePosition() {
return attr("labelposition").equalsIgnoreCase("before");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Метод даст неправильный результат для "Radio group label position before 1" и "Radio group label position before 2" с тестового сайта

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправила

if (hasClass("mat-warn")) {
return AngularColors.WARN;
} else
return AngularColors.ACCENT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для отдельной кнопки если значение не задано в нем самом, оно определено для всей группы

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

пересмотрела все наши реализации, цвета на уровне группы нет ни в одной. поэтому, извините, не соображу, как взять цвет с уровня группы

Copy link
Contributor

@pnatashap pnatashap Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну вот на тестовом сайте вверху есть "Radio buttons configuration", у него только один контрол цветной, остальные темные, а по этому алгоритму получается, что у всех всегда одинаковый код, значит что-то не так в этом алгоритме

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спасибо, исправила


@JDIAction("Click '{name}' radio button with value '{0}'")
public void click(String value) {
getRadioButtonByValue(value).find(By.cssSelector(".mdc-form-field")).click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему мы просто не можем по кнопке и кликнуть?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

когда в вертикальной группе кнопка большого размера (как у нас на сайте ), он кликает в середину и не происходит выделения радио батон. клик есть, а выделения нет.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так у нас клик переопределен, как такое может быть?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Долго разбиралась, если честно, почему падают тесты. Думала, что это из-за ngModel реализации. А потом перебором вариантов нашла, что лефтэреа клик выделяет. Добавила указание на форм-филд тесты перестали падать. Предполагаю, что даже при переопределении вертикальные кнопки оказываются слишком большие. Если убрать find(By.cssSelector(".mdc-form-field")) , то все тесты на вертикальные радио кнопки падают, клик есть, выделения нет :( Для горизонтальных кнопок все работает без find(By.cssSelector(".mdc-form-field"))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 Кликать по mdc-form-field не безопасно, не все части приводят к выделению, надо кликать по mdc-radio
2 Любая такая проблема не повод оставлять непонятный код внутри другого класса

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправила

}

@JDIAction("'{name}' radio button contain value '{0}'")
public boolean isChecked(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. почему такого метода нет у RadioButton? это же его информация
  2. где метод для получения выбранного?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавила

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему не используется?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавила в тест

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не вижу где

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. по checked
    @test(description = "Test verifies value and the radio-button is checked")
    public void basicRadioButtonsTest() {
    basicRadioGroup.show();
    basicRadioGroup.is().displayed();
    basicRadioGroup.click("2");
    basicRadioGroup.click("1");
    basicRadioGroup.click("2");
    basicRadioGroup.is().checked("2");
    basicRadioGroup.is().notChecked("1");
    basicRadioGroup.radioButtons().get(1).is().checked();
    basicRadioGroup.radioButtons().get(0).is().notChecked();
    }
  2. получение выбранного
    @test(description = "Test verifies that there is checked radio-button in the group")
    public void getCheckedRadioButtonTest() {
    colorRadioGroup.has().checkedRadioButton();
    requiredRadioGroup.has().noCheckedRadioButton();
    }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Еще раз перечитай первый вопрос
  2. Посмотри на вот эту строку кода https://github.com/jdi-testing/jdi-light/pull/5087/files#diff-278ebeb52c9d2a302e5401e2a7c09a8bbdfea63f44f2c823a1c391e1b0ef7ccdR60
  3. Исправь ошибку

public RadioButton getRadioButtonByValue(String value) {
RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.find("input").attr("value").equalsIgnoreCase(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему у RadioButton нет метода по получению его подписи?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавила

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему не используется?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавила тест

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не вижу

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@test(description = "Test verifies radio button label")
public void radioButtonLabelTest() {
requiredRadioGroup.radioButtons().get(0).has().label("One");
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Речь про полное нарушение инкапсуляции, ты залазишь в дочерний элемент, что-то оттуда берешь и считаешь, что это нормально.
Мы можем захотеть работать с элементами по label, можем по value.

@MayaElf MayaElf requested a review from pnatashap November 7, 2023 13:46
@@ -5,6 +5,10 @@
<module name="SuppressionFilter">
<property name="file" value="${samedir}/suppressions.xml" />
</module>
<module name="NewlineAtEndOfFile">
<property name="severity" value="error"/>
<property name="lineSeparator" value="lf_cr_crlf"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этот стиль используется в нескольких проектах, если мы его изменим тут, оно потом может сломать после вливания, ПР на стиль должен быть отдельным ПР в master вместе с исправлением всех файлов, которые этому условию не удовлетворяют

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спасибо, откатила изменения в этом пиаре, сделала отдельный

if (hasClass("mat-warn")) {
return AngularColors.WARN;
} else
return AngularColors.ACCENT;
Copy link
Contributor

@pnatashap pnatashap Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну вот на тестовом сайте вверху есть "Radio buttons configuration", у него только один контрол цветной, остальные темные, а по этому алгоритму получается, что у всех всегда одинаковый код, значит что-то не так в этом алгоритме


@JDIAction("Click '{name}' radio button with value '{0}'")
public void click(String value) {
getRadioButtonByValue(value).find(By.cssSelector(".mdc-form-field")).click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так у нас клик переопределен, как такое может быть?

}

@JDIAction("'{name}' radio button contain value '{0}'")
public boolean isChecked(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему не используется?

public RadioButton getRadioButtonByValue(String value) {
RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.find("input").attr("value").equalsIgnoreCase(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему не используется?

public RadioButton getCheckedRadioButton() {
RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.hasClass("mat-mdc-radio-checked")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

у кнопки есть метод, который отдает значение, выделен он или нет, почему не использовать его?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправила


@JDIAction("Click '{name}' radio button")
public void click() {
find(By.cssSelector(".mdc-form-field")).click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

локатор частично дублируется с 42 строкой

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынесла в константу

@MayaElf MayaElf force-pushed the 4911_radioButtonTestsRefactoring branch 2 times, most recently from bb2454f to 0a147ac Compare November 8, 2023 12:25
@MayaElf MayaElf requested a review from pnatashap November 10, 2023 10:30
Copy link
Contributor

@pnatashap pnatashap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflicts after changes in styles

@MayaElf MayaElf force-pushed the 4911_radioButtonTestsRefactoring branch 3 times, most recently from b6e5d92 to 2782704 Compare November 14, 2023 09:13
@MayaElf MayaElf force-pushed the 4911_radioButtonTestsRefactoring branch from 2782704 to 49c0ac7 Compare November 14, 2023 09:18
@MayaElf MayaElf requested a review from pnatashap November 14, 2023 10:57

@JDIAction("Click '{name}' radio button with value '{0}'")
public void click(String value) {
getRadioButtonByValue(value).find(By.cssSelector(".mdc-form-field")).click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 Кликать по mdc-form-field не безопасно, не все части приводят к выделению, надо кликать по mdc-radio
2 Любая такая проблема не повод оставлять непонятный код внутри другого класса

}

@JDIAction("'{name}' radio button contain value '{0}'")
public boolean isChecked(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не вижу где

public RadioButton getRadioButtonByValue(String value) {
RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.find("input").attr("value").equalsIgnoreCase(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не вижу

RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.isChecked()) {
radioButton = e;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а почему мы отсюда не возвращаем значение?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

45 строка вернет либо чекнутую радиобатон, либо нулл. оба случая покрыты
@JDIAction("Get '{name}' checked radio-button")
public RadioButton getCheckedRadioButton() {
RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.isChecked()) {
radioButton = e;
}
}
return radioButton;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У тебя есть RadioGroup из 50 пунктов, ты переберешь их все, потом только что-то вернешь, хотя знаешь, что выделенным элементом может быть только один. Как исправить проблему длительного выполнения?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

заменено на стрим

@MayaElf MayaElf requested a review from pnatashap November 15, 2023 14:50
}

@JDIAction("'{name}' radio button contain value '{0}'")
public boolean isChecked(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Еще раз перечитай первый вопрос
  2. Посмотри на вот эту строку кода https://github.com/jdi-testing/jdi-light/pull/5087/files#diff-278ebeb52c9d2a302e5401e2a7c09a8bbdfea63f44f2c823a1c391e1b0ef7ccdR60
  3. Исправь ошибку

RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.isChecked()) {
radioButton = e;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У тебя есть RadioGroup из 50 пунктов, ты переберешь их все, потом только что-то вернешь, хотя знаешь, что выделенным элементом может быть только один. Как исправить проблему длительного выполнения?

public RadioButton getRadioButtonByValue(String value) {
RadioButton radioButton = null;
for (RadioButton e : radioButtons()) {
if (e.find("input").attr("value").equalsIgnoreCase(value)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Речь про полное нарушение инкапсуляции, ты залазишь в дочерний элемент, что-то оттуда берешь и считаешь, что это нормально.
Мы можем захотеть работать с элементами по label, можем по value.

@JDIAction("'{name}' has no checked radio button")
public RadioGroupAssert noCheckedRadioButton() {
jdiAssert(element().getCheckedRadioButton(), Matchers.nullValue(),
"There is checked radio button in the group");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну правильнее написать, что именно выделено, а не просто что что-то выделено, отлаживать же надо, что было


@Override
@JDIAction("Get if '{name}' is disabled")
public boolean isDisabled() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если мы переопределили isDisabled, то логично и isEnabled переопределить, чтобы быстрее работал

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавлено

}

@JDIAction("'{name}' is disabled")
public boolean isDisabled() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже должна быть аннотация Override и надо переопределить isEnabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

добавлено

@MayaElf MayaElf force-pushed the 4911_radioButtonTestsRefactoring branch from 0eaddfa to 86d62dd Compare November 17, 2023 11:03
@MayaElf MayaElf requested a review from pnatashap November 17, 2023 14:16
@pnatashap pnatashap merged commit edfcbce into angular_rework_development Nov 19, 2023
@pnatashap
Copy link
Contributor

исправления зашли в тупик, все исправила сама

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests refactoring: Radio button element
2 participants