browserctl 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/bin/browserctl +29 -0
- data/examples/test_automation_practices/advanced/ab_testing.rb +38 -0
- data/examples/test_automation_practices/advanced/broken_images.rb +25 -0
- data/examples/test_automation_practices/advanced/file_download.rb +40 -0
- data/examples/test_automation_practices/advanced/iframes.rb +37 -0
- data/examples/test_automation_practices/advanced/shadow_dom.rb +35 -0
- data/examples/test_automation_practices/{login.rb → auth/login.rb} +4 -4
- data/examples/test_automation_practices/{login_negative.rb → auth/login_negative.rb} +4 -4
- data/examples/test_automation_practices/dialogs/alerts.rb +45 -0
- data/examples/test_automation_practices/{notifications.rb → dialogs/notifications.rb} +7 -7
- data/examples/test_automation_practices/{dynamic_elements.rb → dynamic/dynamic_elements.rb} +9 -8
- data/examples/test_automation_practices/dynamic/tables.rb +47 -0
- data/examples/test_automation_practices/{checkboxes.rb → forms/checkboxes.rb} +6 -6
- data/examples/test_automation_practices/forms/file_upload.rb +30 -0
- data/examples/test_automation_practices/forms/forms.rb +47 -0
- data/examples/test_automation_practices/forms/slider.rb +51 -0
- data/examples/test_automation_practices/interactions/context_menu.rb +54 -0
- data/examples/test_automation_practices/interactions/drag_drop.rb +41 -0
- data/examples/test_automation_practices/interactions/exit_intent.rb +47 -0
- data/examples/test_automation_practices/interactions/hover.rb +30 -0
- data/examples/test_automation_practices/interactions/key_press.rb +38 -0
- data/lib/browserctl/client.rb +42 -0
- data/lib/browserctl/commands/ask.rb +20 -0
- data/lib/browserctl/commands/dialog.rb +33 -0
- data/lib/browserctl/commands/page.rb +1 -1
- data/lib/browserctl/server/command_dispatcher.rb +8 -0
- data/lib/browserctl/server/handlers/interaction.rb +87 -0
- data/lib/browserctl/server/handlers/page_lifecycle.rb +4 -0
- data/lib/browserctl/version.rb +1 -1
- data/lib/browserctl/workflow.rb +12 -0
- metadata +24 -7
- data/examples/test_automation_practices/key_press.rb +0 -41
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
Browserctl.workflow "test_automation_practices/key_press" do
|
|
4
|
-
desc "Key press page: dispatch keyboard events, verify last-key display and history list update"
|
|
5
|
-
|
|
6
|
-
param :base_url, default: "https://moatazeldebsy.github.io/test-automation-practices"
|
|
7
|
-
param :screenshot_path, default: File.expand_path(".browserctl/screenshots/test_automation_practices_key_press.png")
|
|
8
|
-
|
|
9
|
-
step "open key press page" do
|
|
10
|
-
open_page(:main, url: "#{base_url}/#/key-press")
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
step "dispatch key events and verify last-key display" do
|
|
14
|
-
keys = %w[A B C D E]
|
|
15
|
-
keys.each do |key|
|
|
16
|
-
client.evaluate(
|
|
17
|
-
"main",
|
|
18
|
-
"document.dispatchEvent(new KeyboardEvent('keydown', { key: '#{key}', bubbles: true }))"
|
|
19
|
-
)
|
|
20
|
-
sleep 0.1
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
last = client.evaluate("main",
|
|
24
|
-
"document.querySelector('[data-test=\"last-key-pressed\"]')?.innerText?.trim()")[:result]
|
|
25
|
-
assert last == keys.last, "expected last key '#{keys.last}', got: #{last.inspect}"
|
|
26
|
-
store(:keys, keys)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
step "verify key history contains all dispatched keys" do
|
|
30
|
-
keys = fetch(:keys)
|
|
31
|
-
history = client.evaluate(
|
|
32
|
-
"main",
|
|
33
|
-
"Array.from(document.querySelectorAll('[data-test^=\"key-\"]')).map(el => el.innerText?.trim())"
|
|
34
|
-
)[:result]
|
|
35
|
-
# History shows most recent first; each entry typically contains the key label
|
|
36
|
-
keys.each do |key|
|
|
37
|
-
assert history.any? { |entry| entry&.include?(key) }, "expected '#{key}' in history, got: #{history.inspect}"
|
|
38
|
-
end
|
|
39
|
-
page(:main).screenshot(path: screenshot_path)
|
|
40
|
-
end
|
|
41
|
-
end
|