diff --git a/CHANGELOG.md b/CHANGELOG.md index a9f5c13..35b0656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ [rubycdp/ferrum#716] ### Fixed +- Setting a text field to a value ending in `\n` no longer fails now and then with `Ferrum::NoExecutionContextError` + when the form submits and the page navigates away before the field refocuses - `response_headers` are looked up case-insensitively as with rack_test, `["Content-Type"]` returned `nil` - A click on a node the page removes before the hit test raises `ObsoleteNode`, which Capybara retries, instead of `Ferrum::JavaScriptError: node.getRootNode(...).elementFromPoint is not a function` [#359] diff --git a/lib/capybara/cuprite/node/typing.rb b/lib/capybara/cuprite/node/typing.rb index cc49358..772cf89 100644 --- a/lib/capybara/cuprite/node/typing.rb +++ b/lib/capybara/cuprite/node/typing.rb @@ -63,7 +63,7 @@ def move_caret_to_end def refocus node.evaluate("this.blur(); this.focus()") - rescue Ferrum::NodeNotFoundError + rescue Ferrum::NodeNotFoundError, Ferrum::NoExecutionContextError nil end end diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 4f94dda..6a2e7c6 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -495,6 +495,17 @@ expect(element.value).to eq("Hello there!") end + it "sets the value when the page navigates away before the field refocuses" do + element = @session.find(:css, "#change_me") + node = element.native.node + allow(node).to receive(:evaluate).and_call_original + allow(node).to receive(:evaluate).with("this.blur(); this.focus()").and_raise(Ferrum::NoExecutionContextError) + + element.native.set("Hello") + + expect(element.value).to eq("Hello") + end + it "raises for an unknown clear: value" do element = @session.find(:css, "#change_me") expect { element.set("a", clear: :foo) }