diff --git a/packages/axe-core-api/e2e/selenium/Gemfile.lock b/packages/axe-core-api/e2e/selenium/Gemfile.lock deleted file mode 100644 index 89c6b5bf..00000000 --- a/packages/axe-core-api/e2e/selenium/Gemfile.lock +++ /dev/null @@ -1,68 +0,0 @@ -PATH - remote: ../../../axe-core-watir - specs: - axe-core-watir (4.9.0) - axe-core-api - dumb_delegator - -PATH - remote: ../.. - specs: - axe-core-api (4.9.0) - dumb_delegator - virtus - -GEM - remote: https://rubygems.org/ - specs: - axiom-types (0.1.1) - descendants_tracker (~> 0.0.4) - ice_nine (~> 0.11.0) - thread_safe (~> 0.3, >= 0.3.1) - base64 (0.2.0) - coercible (1.0.0) - descendants_tracker (~> 0.0.1) - descendants_tracker (0.0.4) - thread_safe (~> 0.3, >= 0.3.1) - diff-lcs (1.5.1) - dumb_delegator (1.0.0) - ice_nine (0.11.2) - rexml (3.2.6) - rspec (3.13.0) - rspec-core (~> 3.13.0) - rspec-expectations (~> 3.13.0) - rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-support (3.13.1) - rubyzip (2.3.2) - selenium-webdriver (4.19.0) - base64 (~> 0.2) - rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2, < 3.0) - websocket (~> 1.0) - thread_safe (0.3.6) - virtus (2.0.0) - axiom-types (~> 0.1) - coercible (~> 1.0) - descendants_tracker (~> 0.0, >= 0.0.3) - websocket (1.2.10) - -PLATFORMS - arm64-darwin-23 - ruby - -DEPENDENCIES - axe-core-api! - axe-core-watir! - rspec - selenium-webdriver - -BUNDLED WITH - 2.5.7 diff --git a/packages/axe-core-api/lib/axe/api/run.rb b/packages/axe-core-api/lib/axe/api/run.rb index cfbcd93e..3ae4e3f7 100644 --- a/packages/axe-core-api/lib/axe/api/run.rb +++ b/packages/axe-core-api/lib/axe/api/run.rb @@ -104,8 +104,6 @@ def within_about_blank_context(page) end new_handle = new_handles[0] driver.switch_to.window new_handle - - driver.get "about:blank" ret = yield page diff --git a/packages/axe-core-api/lib/axe/core.rb b/packages/axe-core-api/lib/axe/core.rb index 80af5276..7127a16f 100644 --- a/packages/axe-core-api/lib/axe/core.rb +++ b/packages/axe-core-api/lib/axe/core.rb @@ -41,13 +41,18 @@ def use_run_partial def assert_frame_ready begin ready = Timeout.timeout(10) { - @page.evaluate_script <<-JS - document.readyState === 'complete' - JS + wait = Selenium::WebDriver::Wait.new(:timeout => 10) + wait.until { + readyState = @page.evaluate_script <<-JS + document.readyState + JS + readyState === 'complete' + } } rescue Timeout::Error ready = false end + raise Exception.new "Page/frame not ready" if not ready end diff --git a/packages/axe-core-api/spec/axe/core_spec.rb b/packages/axe-core-api/spec/axe/core_spec.rb index a31faed4..6b315235 100644 --- a/packages/axe-core-api/spec/axe/core_spec.rb +++ b/packages/axe-core-api/spec/axe/core_spec.rb @@ -7,8 +7,7 @@ module Axe let(:page) { spy("page", evaluate_script: false) } - before { allow(page).to receive(:evaluate_script).and_return(false, true, false) } - + before { allow(page).to receive(:evaluate_script).and_return(false, 'complete', false) } describe "initialize" do # We have removed comments from `axe.min.js`, so excluding this test # Hence cannot do start_with("/*! aXe"), instead do a function we know should exist check @@ -25,6 +24,14 @@ module Axe expect(page).not_to have_received(:execute_script) end end + + context "when document.readyState is interactive" do + before { allow(page).to receive(:evaluate_script).and_return(false, 'interactive', 'interactive', 'complete') } + it "should check ready frame until complete, then proceed" do + described_class.new(page) + expect(page).to have_received(:execute_script).with(a_string_including ("axe.run=")) + end + end end describe "call" do