-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
218 lines (189 loc) · 7.27 KB
/
index.html
File metadata and controls
218 lines (189 loc) · 7.27 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri E2E Test App</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.container {
text-align: center;
background: rgba(255, 255, 255, 0.1);
padding: 2rem;
border-radius: 1rem;
backdrop-filter: blur(10px);
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}
h1 {
font-size: 2.5rem;
margin-bottom: 1rem;
font-weight: 300;
}
.counter-section {
margin: 2rem 0;
}
#counter {
font-size: 4rem;
font-weight: bold;
margin: 1rem 0;
color: #61dafb;
}
button {
padding: 12px 24px;
font-size: 1.1rem;
cursor: pointer;
border: none;
border-radius: 8px;
background: linear-gradient(45deg, #61dafb, #21a1f1);
color: white;
transition: all 0.3s ease;
margin: 0.5rem;
box-shadow: 0 4px 15px rgba(97, 218, 251, 0.3);
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(97, 218, 251, 0.4);
}
button:active {
transform: translateY(0);
}
.info-section {
margin-top: 2rem;
font-size: 0.9rem;
opacity: 0.8;
}
.status {
margin-top: 1rem;
padding: 0.5rem;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
font-family: monospace;
}
</style>
</head>
<body>
<div class="container">
<h1>🚀 Tauri Basic App</h1>
<div class="counter-section">
<div id="counter">0</div>
<button id="increment-button">Increment</button>
<button id="decrement-button">Decrement</button>
<button id="reset-button">Reset</button>
</div>
<div class="info-section">
<p>This is a basic Tauri application for WebDriverIO testing.</p>
<div class="status" id="status">Ready for testing</div>
<button id="switch-main-window" class="switch-main-window" style="display:none">Continue to Main</button>
</div>
</div>
<script type="module">
console.log('[App] WDIO Tauri service will configure console forwarding');
console.log('[App] Script loading started');
console.log('[App] typeof window:', typeof window);
console.log('[App] window.__TAURI__ available before plugin import:', typeof window.__TAURI__ !== 'undefined');
// Import WebDriverIO Tauri plugin frontend API
// This provides window.wdioTauri for testing
import '@wdio/tauri-plugin';
console.log('[App] Plugin imported');
console.log('[App] window.wdioTauri available after import:', typeof window.wdioTauri !== 'undefined');
// Generate test logs at various levels
console.trace('[Test] This is a TRACE level log');
console.debug('[Test] This is a DEBUG level log');
console.info('[Test] This is an INFO level log');
console.warn('[Test] This is a WARN level log');
console.error('[Test] This is an ERROR level log');
// Import Tauri API using npm module approach (recommended for v2)
// This is the preferred way in Tauri v2
(async () => {
console.log('[App] Starting Tauri API setup...');
console.log('[App] window.__TAURI__ before setup:', window.__TAURI__);
try {
const { invoke } = await import('@tauri-apps/api/core');
console.log('[App] Successfully imported @tauri-apps/api/core');
// Ensure window.__TAURI__ exists and expose invoke for WebDriver tests
if (!window.__TAURI__) {
console.log('[App] Creating window.__TAURI__');
window.__TAURI__ = {};
}
if (!window.__TAURI__.core) {
console.log('[App] Creating window.__TAURI__.core');
window.__TAURI__.core = {};
}
window.__TAURI__.core.invoke = invoke;
console.log('[App] window.__TAURI__.core.invoke set successfully');
// Listen for log events from Rust backend and log via console.log
// This ensures logs are captured by WebDriver via browser console protocol
const { listen } = await import('@tauri-apps/api/event');
console.log('[App] Setting up log event listener');
await listen('wdio-log', (event) => {
const { source, level, message } = event.payload;
const logMessage = `[Tauri:${source === 'backend' ? 'Backend' : 'Frontend'}] ${message}`;
switch (level) {
case 'trace': console.trace(logMessage); break;
case 'debug': console.debug(logMessage); break;
case 'info': console.info(logMessage); break;
case 'warn': console.warn(logMessage); break;
case 'error': console.error(logMessage); break;
default: console.log(logMessage);
}
});
console.log('[App] Log event listener setup complete');
} catch (error) {
console.warn('[App] Failed to import @tauri-apps/api/core, using global API:', error);
// Fallback: ensure window.__TAURI__.core.invoke exists (should be available with withGlobalTauri: true)
if (!window.__TAURI__?.core?.invoke) {
console.error('[App] Tauri API not available. Make sure withGlobalTauri is enabled in tauri.conf.json');
} else {
console.log('[App] Using global Tauri API');
}
}
console.log('[App] Final window.wdioTauri check:', typeof window.wdioTauri !== 'undefined');
console.log('[App] Final window.__TAURI__ check:', window.__TAURI__);
})();
let count = 0;
const counterElement = document.getElementById('counter');
const incrementButton = document.getElementById('increment-button');
const decrementButton = document.getElementById('decrement-button');
const resetButton = document.getElementById('reset-button');
const statusElement = document.getElementById('status');
function updateCounter() {
counterElement.textContent = count;
statusElement.textContent = `Counter: ${count}`;
}
function updateStatus(message) {
statusElement.textContent = message;
}
incrementButton.addEventListener('click', () => {
count++;
updateCounter();
});
decrementButton.addEventListener('click', () => {
count--;
updateCounter();
});
resetButton.addEventListener('click', () => {
count = 0;
updateCounter();
});
// Initialize
updateCounter();
updateStatus('Application loaded successfully');
// Test Tauri API availability
if (window.__TAURI__) {
updateStatus('Tauri API available - Ready for testing');
} else {
updateStatus('Tauri API not available - Running in browser mode');
}
</script>
</body>
</html>