11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/headless_browser_tool/tools/visual_diff_tool.rb', line 11
def execute
current_state = capture_page_state
previous_state = browser.previous_state || {}
changes = {
url_changed: previous_state[:url] != current_state[:url],
title_changed: previous_state[:title] != current_state[:title],
new_elements: find_new_elements(previous_state[:elements], current_state[:elements]),
removed_elements: find_removed_elements(previous_state[:elements], current_state[:elements]),
text_changes: find_text_changes(previous_state[:texts], current_state[:texts]),
form_values_changed: compare_form_values(previous_state[:forms], current_state[:forms]),
new_images: current_state[:images] - (previous_state[:images] || []),
viewport_position: current_state[:scroll]
}
browser.previous_state = current_state
summarize_changes(changes, current_state)
end
|