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

Release 4.3 introduces breaking change for :cuprite driver #243

Open
khiga8 opened this issue Aug 24, 2022 · 5 comments
Open

Release 4.3 introduces breaking change for :cuprite driver #243

khiga8 opened this issue Aug 24, 2022 · 5 comments
Assignees
Labels
in sprint Ticket is in current sprint PRIORITY: moderate Moderate priority item; should be scheduled within a few weeks TYPE: user bug Bug that was found by a user

Comments

@khiga8
Copy link

khiga8 commented Aug 24, 2022

Hi team,

We are trying to upgrade our axe-core-api version from 4.2 to 4.4.1. Here is the related PR.

However, we're blocked due to this new error that emerges:

undefined method `execute_script' for #<Capybara::Cuprite::Browser:0x00005646aaca3770>

I've ran into the same error when bumping to 4.3 and traced it down to this PR: #199 which introduces some changes related to ExecEvalScriptAdapter2.

Stack trace:

NoMethodError: undefined method `execute_script' for #<Capybara::Cuprite::Browser:0x00005646aaca3770>
    /workspaces/view_components/vendor/bundle/ruby/2.7.0/gems/axe-core-api-4.3.2/lib/webdriver_script_adapter/exec_eval_script_adapter.rb:35:in `execute_script_fixed'

Any advice for how we can resolve this? We use the :cuprite driver. We don't have any issues using :cuprite with versions before 4.3.

@khiga8 khiga8 changed the title NoMethodError: undefined method `execute_script' for #<Capybara::Cuprite::Browser:0x00005646aaca3770> Release 4.3 introduces breaking change for :cuprite driver Aug 24, 2022
@uday708
Copy link

uday708 commented Sep 8, 2022

I am also getting undefined method execute_script for #<Capybara::Poltergeist::Browser:0x4be8d40e> error with axe-core-rspec v4.0.0, can someone help me here for any solution. @khiga8

@nialbima
Copy link

I'm having this issue when migrating our system specs to Cuprite. From what I can tell, it's because this method changes the page target to page.driver.browser, which is a Capybara::Cuprite::Browser object:

      def get_selenium(page)
        page = page.driver if page.respond_to?("driver")
        page = page.browser if page.respond_to?("browser") and not page.browser.is_a?(::Symbol)
        page
      end

Doing something gross like monkey-patching the method in doesn't fix the issue. That leads to some other weirdness, and I've now lost a full day to poking at this and need to abandon this migration. If anybody has any tips, I'm ten-thousand-percent ears.

@khiga8
Copy link
Author

khiga8 commented Sep 21, 2022

@uday708 and @nialbima, I never resolved this issue.

I've now lost a full day to poking at this and need to abandon this migration

This happened to me too. I thought it could be a simple update but it didn't turn out that way...

I followed up with the axe team on their Slack group and they mentioned that their code now assumes the driver is selenium, and that adding cuprite support might involve a new package altogether. I've put aside this migration effort for now since our team is considering a move away from cuprite, but perhaps you can follow up with them.

Here's the Slack message in the axe community slack group.

@nialbima
Copy link

@khiga8 Thanks for the link! At this point, it seems like I'm going to be yelling at Selenium for the rest of my career 🙃. If you guys wind up deciding to stick with Cuprite and developing a new gem, I'd be open to contributing.

@camertron
Copy link

camertron commented Nov 7, 2022

I looked into this today and was able to get things working via these three monkeypatches:

module Capybara
  class Session
    alias_method :execute_async_script, :evaluate_async_script
  end

  module Cuprite
    class Browser
      alias_method :execute_async_script, :evaluate_async
    end
  end
end

module Ferrum
  class Frame
    module Runtime
      prepend Module.new {
        def evaluate_async(expression, *args)
          # second argument is a timeout in milliseconds
          super(expression, 10 * 1000, *args)
        end
      }
    end
  end
end

To be clear: I don't think anyone should actually use these, but I thought I'd comment here for posterity and in case it helps with any future work.

@dequejenn dequejenn added the TYPE: user bug Bug that was found by a user label Oct 23, 2023
@dequejenn dequejenn added PRIORITY: moderate Moderate priority item; should be scheduled within a few weeks in sprint Ticket is in current sprint labels Jan 29, 2024
@michael-siek michael-siek removed their assignment Apr 9, 2024
@scottmries scottmries assigned scottmries and unassigned scottmries Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in sprint Ticket is in current sprint PRIORITY: moderate Moderate priority item; should be scheduled within a few weeks TYPE: user bug Bug that was found by a user
Projects
None yet
Development

No branches or pull requests

7 participants