From 0803e2d2370c04f6b865f6169ba892834ab581fe Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Mon, 26 Aug 2024 14:50:14 +1000 Subject: [PATCH] DEV: Add select_range to composer page object (#28539) Covers the use case of doing this in composer: ```javascript page.execute_script("document.querySelector('.d-editor-input').setSelectionRange(6, 12);") ``` --- spec/system/page_objects/components/composer.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/system/page_objects/components/composer.rb b/spec/system/page_objects/components/composer.rb index 1137373a3b4..5e6e82c39ce 100644 --- a/spec/system/page_objects/components/composer.rb +++ b/spec/system/page_objects/components/composer.rb @@ -237,6 +237,14 @@ module PageObjects JS end + def select_range(start_index, length) + execute_script(<<~JS, text) + const composer = document.querySelector("#{COMPOSER_ID} .d-editor-input"); + composer.focus(); + composer.setSelectionRange(#{start_index}, #{length}); + JS + end + def submit find("#{COMPOSER_ID} .save-or-cancel .create").click end