-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_navigation.R
More file actions
72 lines (62 loc) · 1.89 KB
/
test_navigation.R
File metadata and controls
72 lines (62 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Quick navigation test to identify correct selectors
library(shinytest2)
# Load Chrome configuration
source("tests/ui/chrome_config.R")
# Test navigation selectors
cat("=== TESTING NAVIGATION SELECTORS ===\n")
app <- AppDriver$new(
app_dir = ".",
name = "Navigation_Test",
height = 900,
width = 1400,
timeout = 30000
)
# Wait for app to load
app$wait_for_idle(duration = 3000)
# Take screenshot of main page
app$get_screenshot("navigation_test_main.png")
# Debug: Find all available tab elements
tab_info <- app$get_js("
var allLinks = document.querySelectorAll('a');
var results = [];
for (var i = 0; i < allLinks.length; i++) {
var link = allLinks[i];
if (link.textContent.trim() !== '') {
results.push({
text: link.textContent.trim(),
dataValue: link.getAttribute('data-value') || 'no-data-value',
id: link.id || 'no-id',
classes: link.className || 'no-classes',
href: link.href || 'no-href'
});
}
}
return results;
")
cat("Available tabs:\n")
for (i in seq_along(tab_info)) {
tab <- tab_info[[i]]
cat(sprintf(" %d. Text: '%s', data-value: '%s', id: '%s', classes: '%s'\n",
i, tab$text, tab$dataValue, tab$id, tab$classes))
}
# Try clicking on Analyze tab
cat("\nTrying to click Analyze tab...\n")
tryCatch({
# Method 1: Simple selector
app$click("a[data-value='Analyze']")
app$wait_for_idle(duration = 2000)
app$get_screenshot("navigation_test_analyze.png")
cat("✓ Successfully clicked Analyze tab\n")
}, error = function(e) {
cat("✗ Method 1 failed:", e$message, "\n")
# Method 2: Try with visible text
tryCatch({
app$click("//a[text()='Analyze']")
app$wait_for_idle(duration = 2000)
cat("✓ Successfully clicked Analyze tab via text\n")
}, error = function(e2) {
cat("✗ Method 2 also failed:", e2$message, "\n")
})
})
app$stop()
cat("=== NAVIGATION TEST COMPLETE ===\n")