From 2a41667e0206fa1ac25780ab0c835ad873ed0815 Mon Sep 17 00:00:00 2001 From: Maya Afanaseva Date: Thu, 14 Dec 2023 15:01:01 +0200 Subject: [PATCH] 4934_toggleSlideRefacWithAssert --- .../angular/asserts/SlideToggleAssert.java | 25 +++++++++++++++++++ .../angular/elements/common/SlideToggle.java | 9 +++---- 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SlideToggleAssert.java diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SlideToggleAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SlideToggleAssert.java new file mode 100644 index 0000000000..50c766521e --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SlideToggleAssert.java @@ -0,0 +1,25 @@ +package com.epam.jdi.light.angular.asserts; + +import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; + +import com.epam.jdi.light.angular.elements.common.SlideToggle; +import com.epam.jdi.light.asserts.generic.UIAssert; +import com.epam.jdi.light.common.JDIAction; +import org.hamcrest.Matchers; + +public class SlideToggleAssert extends UIAssert { + + @Override + @JDIAction("Assert that '{name}' is disabled") + public SlideToggleAssert disabled() { + jdiAssert(element().isDisabled(), Matchers.is(true), "Element is enabled"); + return this; + } + + @Override + @JDIAction("Assert that '{name}' is disabled") + public SlideToggleAssert enabled() { + jdiAssert(element().isDisabled(), Matchers.is(false), "Element is disabled"); + return this; + } +} diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/SlideToggle.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/SlideToggle.java index bdc55de998..8f7129072b 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/SlideToggle.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/common/SlideToggle.java @@ -1,5 +1,6 @@ package com.epam.jdi.light.angular.elements.common; +import com.epam.jdi.light.elements.common.UIElement; import com.epam.jdi.light.ui.html.elements.common.Checkbox; /** @@ -15,15 +16,13 @@ public boolean isSelected() { @Override public boolean isEnabled() { - if (hasClass("mat-disabled")) { - return false; - } - return super.isEnabled(); + return !isDisabled(); } @Override public boolean isDisabled() { - return !isEnabled(); + UIElement e = find("//button"); + return e.hasAttribute("disabled"); } @Override