2023-10-09 20:11:16 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PageObjects
|
|
|
|
module Components
|
|
|
|
class DToggleSwitch < PageObjects::Components::Base
|
|
|
|
attr_reader :context
|
|
|
|
|
|
|
|
def initialize(context)
|
|
|
|
@context = context
|
|
|
|
end
|
|
|
|
|
2024-10-24 05:11:19 +08:00
|
|
|
def label_component
|
|
|
|
find(context, visible: :all).ancestor("label.d-toggle-switch__label")
|
2023-10-09 20:11:16 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def toggle
|
2024-10-24 05:11:19 +08:00
|
|
|
label_component.click
|
2023-10-09 20:11:16 +08:00
|
|
|
end
|
2024-08-30 12:53:36 +08:00
|
|
|
|
|
|
|
def checked?
|
2024-10-24 05:11:19 +08:00
|
|
|
label_component.has_css?(".d-toggle-switch__checkbox[aria-checked=\"true\"]", visible: :all)
|
2024-08-30 12:53:36 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def unchecked?
|
2024-10-24 05:11:19 +08:00
|
|
|
label_component.has_css?(
|
2024-08-30 12:53:36 +08:00
|
|
|
".d-toggle-switch__checkbox[aria-checked=\"false\"]",
|
2024-10-24 05:11:19 +08:00
|
|
|
visible: :all,
|
2024-08-30 12:53:36 +08:00
|
|
|
)
|
|
|
|
end
|
2023-10-09 20:11:16 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|