Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ferrum/frame/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def evaluate_on(node:, expression:, by_value: true, wait: 0)
private

def call(expression:, arguments: [], on: nil, wait: 0, handle: true, **options)
errors = [NodeNotFoundError, NoExecutionContextError]
# do not rescue -> retry if we operate on an existing node
errors = on ? [] : [NodeNotFoundError, NoExecutionContextError]

Utils::Attempt.with_retry(errors: errors, max: INTERMITTENT_ATTEMPTS, wait: INTERMITTENT_SLEEP) do
params = options.dup
Expand Down
11 changes: 11 additions & 0 deletions spec/frame/runtime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@
end
end

describe "#evaluate_on" do
it "does not retry if node is not around anymore" do
browser.go_to("/ferrum/table")
node = browser.at_xpath(".//td")

browser.go_to("/ferrum/table")
expect(Ferrum::Utils::Attempt).to receive(:with_retry).with(hash_including(errors: [])).and_call_original
expect { browser.evaluate_on(node: node, expression: "this.textContent") }.to raise_error(Ferrum::NodeNotFoundError)
end
end

describe "#add_script_tag" do
it "adds by url" do
browser.go_to
Expand Down