Skip to content

Commit eae9383

Browse files
committed
Console and network logs
1 parent 8fcfb30 commit eae9383

13 files changed

Lines changed: 955 additions & 475 deletions

File tree

example/wdio.conf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const config: Options.Testrunner = {
6363
capabilities: [
6464
{
6565
browserName: 'chrome',
66-
browserVersion: '145.0.7632.110', // specify chromium browser version for testing
66+
browserVersion: '145.0.7632.117', // specify chromium browser version for testing
6767
'goog:chromeOptions': {
6868
args: [
6969
'--headless',

packages/app/src/components/workbench/logs.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,15 @@ export class DevtoolsSource extends Element {
120120
{} as Record<string, unknown>
121121
)}"
122122
></wdio-devtools-list>
123-
<wdio-devtools-list
124-
label="Result"
125-
class="text-xs"
126-
.list="${typeof this.command.result === 'object'
127-
? this.command.result
128-
: [this.command.result]}"
129-
></wdio-devtools-list>
123+
${this.command.result !== null && this.command.result !== undefined
124+
? html`<wdio-devtools-list
125+
label="Result"
126+
class="text-xs"
127+
.list="${typeof this.command.result === 'object'
128+
? this.command.result
129+
: [this.command.result]}"
130+
></wdio-devtools-list>`
131+
: ''}
130132
`
131133
}
132134
}

packages/app/src/components/workbench/metadata.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,40 @@ export class DevtoolsMetadata extends Element {
3333
return html`<wdio-devtools-placeholder></wdio-devtools-placeholder>`
3434
}
3535

36-
const { url } = this.metadata
36+
const m = this.metadata as any
37+
const sessionInfo: Record<string, unknown> = {}
38+
if (m.sessionId) sessionInfo['Session ID'] = m.sessionId
39+
if (m.testEnv) sessionInfo['Environment'] = m.testEnv
40+
if (m.host) sessionInfo['WebDriver Host'] = m.host
41+
if (m.modulePath) sessionInfo['Test File'] = m.modulePath
42+
if (m.url) sessionInfo['URL'] = m.url
43+
44+
const caps = m.capabilities || {}
45+
const desiredCaps = m.desiredCapabilities || {}
46+
3747
return html`
38-
<wdio-devtools-list
39-
label="Metadata"
40-
.list="${{ url }}"
41-
></wdio-devtools-list>
48+
${Object.keys(sessionInfo).length
49+
? html`<wdio-devtools-list
50+
label="Session"
51+
.list="${sessionInfo}"
52+
></wdio-devtools-list>`
53+
: ''}
4254
<wdio-devtools-list
4355
label="Capabilities"
44-
.list="${this.metadata.capabilities}"
45-
></wdio-devtools-list>
46-
<wdio-devtools-list
47-
label="Options"
48-
.list="${this.metadata.options}"
56+
.list="${caps}"
4957
></wdio-devtools-list>
58+
${Object.keys(desiredCaps).length
59+
? html`<wdio-devtools-list
60+
label="Desired Capabilities"
61+
.list="${desiredCaps}"
62+
></wdio-devtools-list>`
63+
: ''}
64+
${m.options && Object.keys(m.options).length
65+
? html`<wdio-devtools-list
66+
label="Options"
67+
.list="${m.options}"
68+
></wdio-devtools-list>`
69+
: ''}
5070
`
5171
}
5272
}

packages/nightwatch-devtools/example/nightwatch.conf.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module.exports = {
2323
browserName: 'chrome',
2424
'goog:chromeOptions': {
2525
args: ['--headless', '--no-sandbox', '--disable-dev-shm-usage']
26-
}
26+
},
27+
'goog:loggingPrefs': { performance: 'ALL' }
2728
},
2829
// Simple configuration - just call the function to get globals
2930
globals: nightwatchDevtools({ port: 3000 })
Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
export const PAGE_TRANSITION_COMMANDS = [
2-
'url',
3-
'navigateTo',
4-
'click',
5-
'submitForm'
6-
] as const
7-
81
/**
92
* Internal Nightwatch commands to exclude from capture
10-
* These are helper/platform detection commands not relevant to users
113
*/
124
export const INTERNAL_COMMANDS_TO_IGNORE = [
135
'isAppiumClient',
@@ -36,14 +28,8 @@ export const INTERNAL_COMMANDS_TO_IGNORE = [
3628
'executeScript'
3729
] as const
3830

39-
/**
40-
* Console method types for log capturing
41-
*/
4231
export const CONSOLE_METHODS = ['log', 'info', 'warn', 'error'] as const
4332

44-
/**
45-
* Log level detection patterns
46-
*/
4733
export const LOG_LEVEL_PATTERNS: ReadonlyArray<{
4834
level: 'trace' | 'debug' | 'info' | 'warn' | 'error'
4935
pattern: RegExp
@@ -55,28 +41,14 @@ export const LOG_LEVEL_PATTERNS: ReadonlyArray<{
5541
{ level: 'error', pattern: /\berror\b/i }
5642
] as const
5743

58-
/**
59-
* Console log source types
60-
*/
6144
export const LOG_SOURCES = {
6245
BROWSER: 'browser',
6346
TEST: 'test',
6447
TERMINAL: 'terminal'
6548
} as const
6649

67-
/**
68-
* ANSI escape code regex - matches all ANSI escape sequences including:
69-
* - Color codes: \x1b[36m, \x1b[39m
70-
* - Cursor control: \x1b[2K, \x1b[1G, \x1b[1A
71-
* - Cursor visibility: \x1b[?25l, \x1b[?25h
72-
* - SGR parameters: \x1b[1m, \x1b[22m
73-
* Pattern: ESC [ (optional ?)(digits/semicolons)(letter)
74-
*/
7550
export const ANSI_REGEX = /\x1b\[[?]?[0-9;]*[A-Za-z]/g
7651

77-
/**
78-
* Default values
79-
*/
8052
export const DEFAULTS = {
8153
CID: '0-0',
8254
TEST_NAME: 'unknown',
@@ -85,9 +57,7 @@ export const DEFAULTS = {
8557
DURATION: 0
8658
} as const
8759

88-
/**
89-
* Timing constants (in milliseconds)
90-
*/
60+
/** Timing constants (in milliseconds) */
9161
export const TIMING = {
9262
UI_RENDER_DELAY: 150,
9363
TEST_START_DELAY: 100,
@@ -98,9 +68,6 @@ export const TIMING = {
9868
BROWSER_POLL_INTERVAL: 1000
9969
} as const
10070

101-
/**
102-
* Test states
103-
*/
10471
export const TEST_STATE = {
10572
PENDING: 'pending',
10673
RUNNING: 'running',
@@ -109,9 +76,13 @@ export const TEST_STATE = {
10976
SKIPPED: 'skipped'
11077
} as const
11178

112-
export type TestState = (typeof TEST_STATE)[keyof typeof TEST_STATE]
113-
11479
/**
115-
* Temporary UID generation pattern
80+
* Generic pattern matching Nightwatch commands whose result is a boolean.
11681
*/
117-
export const TEMP_UID_PREFIX = 'temp'
82+
export const BOOLEAN_COMMAND_PATTERN =
83+
/^waitFor|^is[A-Z]|^has[A-Z]|(Visible|Present|Enabled|Selected|NotVisible|NotPresent)$/
84+
85+
export const NAVIGATION_COMMANDS = ['url', 'navigate', 'navigateTo'] as const
86+
87+
/** Spinner progress frames — suppress from UI Console output. */
88+
export const SPINNER_RE = /^[]/u

0 commit comments

Comments
 (0)