diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7e55d6f2..85892e9e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,11 +11,12 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4"] + ruby: ["3.1", "3.2", "3.3", "3.4", "4.0"] runs-on: ubuntu-latest env: FERRUM_PROCESS_TIMEOUT: 25 FERRUM_DEFAULT_TIMEOUT: 15 + FERRUM_CHROME_DOCKERIZE: true steps: - name: Checkout code uses: actions/checkout@v4 @@ -31,11 +32,6 @@ jobs: with: chrome-version: stable - - name: Fix GA Chrome Permissions - run: | - sudo chown root:root /opt/hostedtoolcache/setup-chrome/chromium/stable/x64/chrome-sandbox - sudo chmod 4755 /opt/hostedtoolcache/setup-chrome/chromium/stable/x64/chrome-sandbox - - name: Run tests run: | mkdir -p /tmp/cuprite diff --git a/lib/capybara/cuprite/browser.rb b/lib/capybara/cuprite/browser.rb index d7ce914e..9d04f44c 100644 --- a/lib/capybara/cuprite/browser.rb +++ b/lib/capybara/cuprite/browser.rb @@ -140,6 +140,7 @@ def source end def drag(node, other, steps, delay = nil, scroll = true) + node.scroll_into_view if scroll x1, y1 = node.find_position mouse.move(x: x1, y: y1) diff --git a/lib/capybara/cuprite/driver.rb b/lib/capybara/cuprite/driver.rb index 30e74308..cc8bef04 100644 --- a/lib/capybara/cuprite/driver.rb +++ b/lib/capybara/cuprite/driver.rb @@ -35,6 +35,8 @@ def initialize(app, options = {}) @screen_size ||= DEFAULT_MAXIMIZE_SCREEN_SIZE @options[:save_path] ||= File.expand_path(Capybara.save_path) if Capybara.save_path + @options[:pending_connection_errors] = true unless @options.key?(:pending_connection_errors) + # It's set for debug() to make devtools tab open correctly. @options[:browser_options] ||= {} unless @options[:browser_options][:"remote-allow-origins"] diff --git a/lib/capybara/cuprite/page.rb b/lib/capybara/cuprite/page.rb index f3e2bf3e..2b21a863 100644 --- a/lib/capybara/cuprite/page.rb +++ b/lib/capybara/cuprite/page.rb @@ -15,6 +15,7 @@ class Page < Ferrum::Page TRIGGER_CLICK_WAIT = ENV.fetch("CUPRITE_TRIGGER_CLICK_WAIT", 0.1).to_f extend Forwardable + delegate %i[at_css at_xpath css xpath current_url current_title body execution_id execution_id! evaluate evaluate_on evaluate_async execute] => :active_frame diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bcc30d69..789d7437 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -36,26 +36,21 @@ module TestSessions RSpec.configure do |config| config.define_derived_metadata do |metadata| regexes = <<~REGEXP.split("\n").map { |s| Regexp.quote(s.strip) }.join("|") - node #drag_to should work with jsTree - node #drag_to should drag and drop an object - node #drag_to should drag and drop if scrolling is needed - node #drag_to should drag a link - node #drag_to should work with Dragula - node #drag_to HTML5 should work with SortableJS - node #drag_to HTML5 should HTML5 drag and drop an object - node #drag_to HTML5 should set clientX/Y in dragover events - node #drag_to HTML5 should not HTML5 drag and drop on a non HTML5 drop element - node #drag_to HTML5 should HTML5 drag and drop when scrolling needed - node #drag_to HTML5 should drag HTML5 default draggable elements - node #drag_to HTML5 should drag HTML5 default draggable element child - node #drag_to should simulate a single held down modifier key - node #drag_to should simulate multiple held down modifier keys - node #drag_to should support key aliases - node #drag_to HTML5 should preserve clientX/Y from last dragover event - node #drag_to HTML5 should simulate a single held down modifier key - node #drag_to HTML5 should simulate multiple held down modifier keys - node #drag_to HTML5 should support key aliases - node #drag_to HTML5 should trigger a dragenter event, before the first dragover event + #drag_to should simulate a single held down modifier key + #drag_to should simulate multiple held down modifier keys + #drag_to should support key aliases + #drag_to HTML5 should HTML5 drag and drop an object + #drag_to HTML5 should HTML5 drag and drop an object child + #drag_to HTML5 should set clientX/Y in dragover events + #drag_to HTML5 should preserve clientX/Y from last dragover event + #drag_to HTML5 should HTML5 drag and drop when scrolling needed + #drag_to HTML5 should drag HTML5 default draggable elements + #drag_to HTML5 should work with SortableJS + #drag_to HTML5 should drag HTML5 default draggable element child + #drag_to HTML5 should simulate a single held down modifier key + #drag_to HTML5 should simulate multiple held down modifier keys + #drag_to HTML5 should support key aliases + #drag_to HTML5 should trigger a dragenter event, before the first dragover event node Element#drop can drop a file node Element#drop can drop multiple files node Element#drop can drop strings @@ -68,6 +63,7 @@ module TestSessions node #set should submit single text input forms if ended with #fill_in should fill in a color field #fill_in should handle carriage returns with line feeds in a textarea correctly + #fill_in should fill in a textarea in a reasonable time by default #has_field with valid should be false if field is invalid #find with spatial filters should find an element above another element #find with spatial filters should find an element below another element @@ -77,7 +73,6 @@ module TestSessions #find with spatial filters should find an element "near" another element #has_css? with spatial requirements accepts spatial options #has_css? with spatial requirements supports spatial sugar - #fill_in should fill in a textarea in a reasonable time by default #has_element? should be true if the given element is on the page #assert_matches_style should raise error if the elements style doesn't contain the given properties #has_css? :style option should support Hash