mcp-web-inspector 0.4.2 β 0.4.3
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.
- package/README.md +603 -228
- package/dist/index.js +75 -2
- package/dist/toolHandler.js +1 -1
- package/dist/tools/browser/content/screenshot.js +47 -8
- package/dist/tools/browser/inspection/check_visibility.js +24 -0
- package/dist/tools/browser/inspection/compare_element_alignment.js +20 -0
- package/dist/tools/browser/inspection/element_exists.js +14 -0
- package/dist/tools/browser/inspection/find_by_text.js +21 -0
- package/dist/tools/browser/inspection/get_computed_styles.js +17 -0
- package/dist/tools/browser/inspection/get_test_ids.js +22 -0
- package/dist/tools/browser/inspection/inspect_ancestors.js +24 -0
- package/dist/tools/browser/inspection/inspect_dom.js +30 -0
- package/dist/tools/browser/inspection/measure_element.js +18 -0
- package/dist/tools/browser/inspection/query_selector.js +21 -0
- package/dist/tools/common/types.d.ts +10 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -457,295 +457,652 @@ rm -rf ./.mcp-web-inspector/screenshots # Clear screenshots only
|
|
|
457
457
|
---
|
|
458
458
|
|
|
459
459
|
## Core Tools
|
|
460
|
+
### Inspection
|
|
461
|
+
|
|
462
|
+
#### `inspect_dom`
|
|
463
|
+
π PRIMARY INSPECTION TOOL - START HERE FOR LAYOUT DEBUGGING: Progressive DOM inspection that shows parent-child relationships, centering issues, spacing gaps, and scrollable containers. Skips wrapper divs and shows only semantic elements (header, nav, main, form, button, elements with test IDs, ARIA roles, etc.).
|
|
464
|
+
|
|
465
|
+
WORKFLOW: Call without selector for page overview, then drill down by calling with child's selector.
|
|
466
|
+
|
|
467
|
+
DETECTS: Scrollable containers (shows "scrollable βοΈ 36px" when scrollHeight > clientHeight), parent-relative positioning, vertical/horizontal centering, sibling spacing gaps, layout patterns.
|
|
468
|
+
|
|
469
|
+
OUTPUT FORMAT:
|
|
470
|
+
```
|
|
471
|
+
[0] <button data-testid="menu">
|
|
472
|
+
@ (16,8) 40Γ40px β Absolute viewport position (x,y) and size
|
|
473
|
+
from edges: β16px β1144px β8px β8px β Distance from parent edges (β8px = β8px means vertically centered)
|
|
474
|
+
"Menu"
|
|
475
|
+
β visible, β‘ interactive
|
|
476
|
+
|
|
477
|
+
[1] <div data-testid="title">
|
|
478
|
+
@ (260,2) 131Γ28px
|
|
479
|
+
from edges: β244px β244px β2px β42px β Equal left/right (244px) = horizontally centered, unequal top/bottom = NOT vertically centered
|
|
480
|
+
gap from [0]: β16px β Spacing between siblings
|
|
481
|
+
"Title"
|
|
482
|
+
β visible, 2 children
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
SYMBOLS: β=visible, β=hidden, β‘=interactive, ββ=horizontal edges, ββ=vertical edges, βοΈ=vertical scroll, βοΈ=horizontal scroll
|
|
486
|
+
CENTERING: Equal left/right distances = horizontally centered, equal top/bottom = vertically centered
|
|
487
|
+
SCROLL DETECTION: Automatically detects scrollable containers and shows overflow amount (e.g., "scrollable βοΈ 397px" means 397px of hidden content). No need to use evaluate() to compare scrollHeight/clientHeight.
|
|
488
|
+
|
|
489
|
+
RELATED TOOLS: For comparing TWO elements' alignment (not parent-child), use compare_element_alignment(). For box model (padding/margin), use measure_element().
|
|
490
|
+
|
|
491
|
+
β οΈ More efficient than get_html() or evaluate() for structural analysis. Use BEFORE visual tools (screenshot) or evaluate(). Supports testid shortcuts.
|
|
492
|
+
|
|
493
|
+
- Parameters:
|
|
494
|
+
- selector (string, optional): CSS selector, text selector, or testid shorthand to inspect. Omit for page overview (defaults to body). Use 'testid:login-form', '#main', etc.
|
|
495
|
+
- includeHidden (boolean, optional): Include hidden elements in results (default: false)
|
|
496
|
+
- maxChildren (number, optional): Maximum number of children to show (default: 20)
|
|
497
|
+
- maxDepth (number, optional): Maximum depth to drill through non-semantic wrapper elements when looking for semantic children (default: 5). Increase for extremely deeply nested components, decrease to 1 to see only immediate children without drilling.
|
|
498
|
+
- elementIndex (number, optional): When selector matches multiple elements, use this 1-based index to select a specific one (e.g., 2 = second element). Default: first visible element.
|
|
499
|
+
|
|
500
|
+
- Output Format:
|
|
501
|
+
- Optional selection header when multiple matches (with chosen index).
|
|
502
|
+
- For each listed element:
|
|
503
|
+
- Indexed tag with best identifier (testid/ID/classes).
|
|
504
|
+
- Position line: @ (x,y) widthΓheight px.
|
|
505
|
+
- from edges: left/right/top/bottom distances; centering hints.
|
|
506
|
+
- gap from [prev]: spacing between siblings when applicable.
|
|
507
|
+
- Text snippet in quotes (trimmed).
|
|
508
|
+
- Status: β visible / β hidden, β‘ interactive, N children.
|
|
509
|
+
- Scrollable markers βοΈ/βοΈ with overflow amount when detected.
|
|
510
|
+
|
|
511
|
+
- Examples:
|
|
512
|
+
- inspect_dom({})
|
|
513
|
+
- inspect_dom({ selector: 'testid:menu' })
|
|
514
|
+
- inspect_dom({ selector: '#content', maxChildren: 10 })
|
|
515
|
+
|
|
516
|
+
- Example Output (inspect_dom({})):
|
|
517
|
+
```
|
|
518
|
+
[0] <header data-testid="site-header">
|
|
519
|
+
@ (0,0) 1280Γ64px
|
|
520
|
+
from edges: β0px β0px β0px β1216px
|
|
521
|
+
"My App"
|
|
522
|
+
β visible, 3 children
|
|
523
|
+
|
|
524
|
+
[1] <main id="content">
|
|
525
|
+
@ (0,64) 1280Γ640px
|
|
526
|
+
from edges: β0px β0px β64px β512px
|
|
527
|
+
"Welcome back"
|
|
528
|
+
β visible, 5 children, scrollable βοΈ 320px
|
|
529
|
+
```
|
|
530
|
+
- Example Output (inspect_dom({ selector: 'testid:menu' })):
|
|
531
|
+
```
|
|
532
|
+
[0] <button data-testid="menu">
|
|
533
|
+
@ (16,8) 40Γ40px
|
|
534
|
+
from edges: β16px β1224px β8px β16px
|
|
535
|
+
"Menu"
|
|
536
|
+
β visible, β‘ interactive
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
#### `inspect_ancestors`
|
|
540
|
+
DEBUG LAYOUT CONSTRAINTS: Walk up the DOM tree to find where width constraints, margins, borders, and overflow clipping come from. Shows for each ancestor: position/size, width constraints (w, max-w, min-w), margins with directional arrows (ββββ format), padding, display type, borders (directional if non-uniform), overflow (π=hidden, βοΈ=scroll), flexbox context (flex direction justify items gap), grid context (cols rows gap), position/z-index/transform when set. Automatically detects horizontal centering via auto margins and flags clipping points (π―). Essential for debugging unexpected centering, constrained width, or clipped content. Default: 10 ancestors (reaches <body> in most React apps), max: 15. Use after inspect_dom() to understand parent layout constraints.
|
|
541
|
+
|
|
542
|
+
- Parameters:
|
|
543
|
+
- selector (string, required): CSS selector or testid shorthand for the element to start from (e.g., 'testid:header', '#main')
|
|
544
|
+
- limit (number, optional): Maximum number of ancestors to traverse (default: 10, max: 15). Increase for deeply nested component frameworks.
|
|
545
|
+
- elementIndex (number, optional): When selector matches multiple elements, use this 1-based index to select a specific one (e.g., 2 = second element). Default: first visible element.
|
|
546
|
+
|
|
547
|
+
- Output Format:
|
|
548
|
+
- Header showing selected element index when selector matched multiple.
|
|
549
|
+
- For each ancestor (starting from target):
|
|
550
|
+
- [i] <tag> | testid:... or classes
|
|
551
|
+
- @ (x,y) widthΓheight px
|
|
552
|
+
- Inline summary: w, display (if not block), m/p, max-w, min-w
|
|
553
|
+
- Flexbox/Grid context when present (direction, gap, grid templates)
|
|
554
|
+
- Margin breakdown with arrows (ββββ) and centering diagnostics
|
|
555
|
+
- Border details when set (directional if non-uniform)
|
|
556
|
+
- Overflow state: π hidden, βοΈ/βοΈ scroll + overflow amount
|
|
557
|
+
- Extra: position/z-index/transform when non-default
|
|
558
|
+
- Diagnostics: π― CLIPPING POINT / SCROLLABLE CONTAINER / WIDTH CONSTRAINT
|
|
559
|
+
|
|
560
|
+
- Examples:
|
|
561
|
+
- inspect_ancestors({ selector: 'testid:submit-button' })
|
|
562
|
+
- inspect_ancestors({ selector: '#content', limit: 15 })
|
|
563
|
+
|
|
564
|
+
- Example Output (inspect_ancestors({ selector: 'testid:submit-button' })):
|
|
565
|
+
```
|
|
566
|
+
Selected: testid:submit-button (1 of 2 matches)
|
|
567
|
+
|
|
568
|
+
Ancestor Chain:
|
|
569
|
+
|
|
570
|
+
[0] <button> | testid:submit-button
|
|
571
|
+
@ (860,540) 120x40px | w:120px display:inline-block
|
|
572
|
+
margin: β0px β0px β0px β0px
|
|
573
|
+
border: 1px solid rgb(0, 122, 255)
|
|
574
|
+
β none
|
|
575
|
+
|
|
576
|
+
[1] <div> | form-actions
|
|
577
|
+
@ (800,520) 240x80px | w:240px display:flex m:0px p:16px gap:8px
|
|
578
|
+
flex: row, justify:center, align:center, gap:8px
|
|
579
|
+
margin: βauto βauto β Horizontally centered (likely margin:0 auto)
|
|
580
|
+
border: none
|
|
581
|
+
overflow: π hidden
|
|
582
|
+
π― CLIPPING POINT - May clip overflowing children
|
|
583
|
+
|
|
584
|
+
[2] <form> | #login-form
|
|
585
|
+
@ (640,200) 560x480px | w:560px max-w:600px
|
|
586
|
+
position:relative
|
|
587
|
+
π― WIDTH CONSTRAINT
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
#### `compare_element_alignment`
|
|
591
|
+
COMPARE TWO ELEMENTS: Get comprehensive alignment and dimension comparison in one call. Shows edge alignment (top, left, right, bottom), center alignment (horizontal, vertical), and dimensions (width, height). Perfect for debugging 'are these headers aligned?' or 'do these panels match?'. Returns all alignment info with β/β symbols and pixel differences. For parent-child centering, use inspect_dom() instead (automatically shows if children are centered in parent). More efficient than evaluate() with manual getBoundingClientRect() calculations.
|
|
592
|
+
|
|
593
|
+
- Parameters:
|
|
594
|
+
- selector1 (string, required): CSS selector, text selector, or testid shorthand for the first element (e.g., 'testid:main-header', '#header')
|
|
595
|
+
- selector2 (string, required): CSS selector, text selector, or testid shorthand for the second element (e.g., 'testid:chat-header', '#secondary-header')
|
|
596
|
+
|
|
597
|
+
- Output Format:
|
|
598
|
+
- Optional warnings when a selector matched multiple elements (using first).
|
|
599
|
+
- Header: Alignment: <elem1> vs <elem2>
|
|
600
|
+
- Two lines with each element's position and size: @ (x,y) wΓh px
|
|
601
|
+
- Edges block: Top/Left/Right/Bottom with β/β and diffs
|
|
602
|
+
- Centers block: Horizontal/Vertical center alignment with β/β and diffs
|
|
603
|
+
- Dimensions block: Width/Height same or different with β/β and diffs
|
|
604
|
+
- Optional hint to run inspect_ancestors(...) when large misalignment detected
|
|
605
|
+
|
|
606
|
+
- Examples:
|
|
607
|
+
- compare_element_alignment({ selector1: 'testid:header-title', selector2: 'testid:subtitle' })
|
|
608
|
+
- compare_element_alignment({ selector1: '#left-panel', selector2: '#right-panel' })
|
|
609
|
+
|
|
610
|
+
- Example Output (compare_element_alignment({ selector1: '#left-panel', selector2: '#right-panel' })):
|
|
611
|
+
```
|
|
612
|
+
Alignment: <div #left-panel> vs <div #right-panel>
|
|
613
|
+
#left-panel: @ (80,120) 320Γ600px
|
|
614
|
+
#right-panel: @ (440,120) 320Γ600px
|
|
615
|
+
|
|
616
|
+
Edges:
|
|
617
|
+
Top: β aligned (both @ 120px)
|
|
618
|
+
Left: β not aligned (80px vs 440px, diff: 360px)
|
|
619
|
+
Right: β not aligned (400px vs 760px, diff: 360px)
|
|
620
|
+
Bottom: β aligned (both @ 720px)
|
|
621
|
+
|
|
622
|
+
Centers:
|
|
623
|
+
Horizontal: β not aligned (240px vs 600px, diff: 360px)
|
|
624
|
+
Vertical: β aligned (both @ 420px)
|
|
625
|
+
|
|
626
|
+
Dimensions:
|
|
627
|
+
Width: β same (320px)
|
|
628
|
+
Height: β same (600px)
|
|
629
|
+
```
|
|
460
630
|
|
|
461
|
-
|
|
631
|
+
#### `get_computed_styles`
|
|
632
|
+
INSPECT CSS PROPERTIES: Get computed CSS values for specific properties (display, position, width, etc.). Use when you need raw CSS values or specific properties not shown by measure_element(). Returns styles grouped by category (Layout, Visibility, Spacing, Typography). For box model visualization (padding/margin), use measure_element() instead.
|
|
462
633
|
|
|
463
|
-
|
|
464
|
-
|
|
634
|
+
- Parameters:
|
|
635
|
+
- selector (string, required): CSS selector, text selector, or testid shorthand (e.g., 'testid:submit-button', '#main')
|
|
636
|
+
- properties (string, optional): Comma-separated list of CSS properties to retrieve (e.g., 'display,width,color'). If not specified, returns common layout properties: display, position, width, height, opacity, visibility, z-index, overflow, margin, padding, font-size, font-weight, color, background-color
|
|
637
|
+
- elementIndex (number, optional): When selector matches multiple elements, use this 1-based index to select a specific one (e.g., 2 = second element). Default: first visible element.
|
|
465
638
|
|
|
466
|
-
|
|
467
|
-
-
|
|
468
|
-
-
|
|
469
|
-
-
|
|
470
|
-
-
|
|
639
|
+
- Output Format:
|
|
640
|
+
- Optional selection header when multiple elements matched.
|
|
641
|
+
- Header: 'Computed Styles: <tag id/class/testid>'
|
|
642
|
+
- One or more sections: Layout, Visibility, Spacing, Typography, Other
|
|
643
|
+
- Each section lists 'property: value' lines for requested properties
|
|
471
644
|
|
|
472
|
-
|
|
473
|
-
-
|
|
474
|
-
-
|
|
475
|
-
- Discovering interactive elements in complex UIs
|
|
476
|
-
- Navigating deeply nested component libraries (Material-UI, Ant Design)
|
|
645
|
+
- Examples:
|
|
646
|
+
- get_computed_styles({ selector: 'testid:login-form' })
|
|
647
|
+
- get_computed_styles({ selector: '#hero', properties: 'display,width,color' })
|
|
477
648
|
|
|
478
|
-
|
|
649
|
+
- Example Output (get_computed_styles({ selector: 'testid:login-form' })):
|
|
479
650
|
```
|
|
480
|
-
1
|
|
481
|
-
|
|
482
|
-
|
|
651
|
+
β Warning: Selector matched 2 elements, showing 1 (use elementIndex to target a specific one)
|
|
652
|
+
|
|
653
|
+
Computed Styles: <form data-testid="login-form">
|
|
654
|
+
|
|
655
|
+
Layout:
|
|
656
|
+
display: block
|
|
657
|
+
position: static
|
|
658
|
+
width: 560px
|
|
659
|
+
height: 480px
|
|
660
|
+
|
|
661
|
+
Visibility:
|
|
662
|
+
opacity: 1
|
|
663
|
+
visibility: visible
|
|
664
|
+
z-index: auto
|
|
665
|
+
overflow: visible
|
|
666
|
+
|
|
667
|
+
Spacing:
|
|
668
|
+
margin: 0px
|
|
669
|
+
padding: 24px
|
|
670
|
+
|
|
671
|
+
Typography:
|
|
672
|
+
font-size: 16px
|
|
673
|
+
font-weight: 400
|
|
674
|
+
color: rgb(33, 37, 41)
|
|
483
675
|
```
|
|
484
676
|
|
|
485
|
-
#### `
|
|
486
|
-
|
|
677
|
+
#### `check_visibility`
|
|
678
|
+
Check if an element is visible to the user. CRITICAL for debugging click/interaction failures. Returns detailed visibility information including viewport intersection, clipping by overflow:hidden, and whether element needs scrolling. Supports testid shortcuts (e.g., 'testid:submit-button').
|
|
487
679
|
|
|
488
|
-
|
|
489
|
-
-
|
|
490
|
-
-
|
|
491
|
-
- Understanding naming conventions used in the codebase
|
|
680
|
+
- Parameters:
|
|
681
|
+
- selector (string, required): CSS selector, text selector, or testid shorthand (e.g., 'testid:login-button', '#submit', 'text=Click here')
|
|
682
|
+
- elementIndex (number, optional): When selector matches multiple elements, use this 1-based index to select a specific one (e.g., 2 = second element). Default: first visible element.
|
|
492
683
|
|
|
493
|
-
|
|
494
|
-
|
|
684
|
+
- Output Format:
|
|
685
|
+
- Header: Visibility: <tag id/class/testid>
|
|
686
|
+
- Status line: β visible/β hidden, β/β in viewport with % visible
|
|
687
|
+
- CSS: opacity, display, visibility
|
|
688
|
+
- Optional interactability issues: disabled, readonly, aria-disabled, pointer-events:none
|
|
689
|
+
- Optional Issues block: clipped by parent overflow, covered by element (with descriptor and ~coverage%), needs scroll
|
|
690
|
+
- Optional Suggestions: scroll_to_element, modal/overlay hint, interaction state note
|
|
691
|
+
- Optional tip to run inspect_ancestors when clipping is detected
|
|
495
692
|
|
|
496
|
-
|
|
497
|
-
-
|
|
498
|
-
-
|
|
499
|
-
- Finding the right element among multiple matches
|
|
500
|
-
- Understanding element state (visible, hidden, interactive)
|
|
693
|
+
- Examples:
|
|
694
|
+
- check_visibility({ selector: 'testid:submit' })
|
|
695
|
+
- check_visibility({ selector: '#login button', elementIndex: 2 })
|
|
501
696
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
- `showAttributes` - Display specific HTML attributes
|
|
697
|
+
- Example Output (check_visibility({ selector: 'testid:submit' })):
|
|
698
|
+
```
|
|
699
|
+
Visibility: <button data-testid="submit">
|
|
506
700
|
|
|
507
|
-
|
|
701
|
+
β visible, β in viewport
|
|
702
|
+
opacity: 1, display: inline-block, visibility: visible
|
|
703
|
+
```
|
|
704
|
+
- Example Output (check_visibility({ selector: '#hero-cta' })):
|
|
705
|
+
```
|
|
706
|
+
Visibility: <a #hero-cta>
|
|
508
707
|
|
|
509
|
-
|
|
510
|
-
|
|
708
|
+
β hidden, β not in viewport (45% visible)
|
|
709
|
+
opacity: 1, display: block, visibility: visible
|
|
511
710
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
- Checking if elements are clipped by parent containers
|
|
711
|
+
Issues:
|
|
712
|
+
β covered by another element (~60% covered)
|
|
713
|
+
Covering: <div .modal-backdrop> (z-index: 9999)
|
|
714
|
+
β needs scroll to bring into view
|
|
517
715
|
|
|
518
|
-
|
|
519
|
-
|
|
716
|
+
β Call scroll_to_element before clicking
|
|
717
|
+
β Element may be behind modal, overlay, or fixed header
|
|
718
|
+
```
|
|
520
719
|
|
|
521
|
-
|
|
522
|
-
-
|
|
523
|
-
- Ensuring consistent spacing across components
|
|
524
|
-
- Validating grid layouts
|
|
525
|
-
- Checking responsive design consistency
|
|
720
|
+
#### `query_selector`
|
|
721
|
+
Test a selector and return detailed information about all matched elements. Essential for selector debugging and finding the right element to interact with. Returns compact text format with element tag, position, text content, visibility status, and interaction capability. Shows why elements are hidden (display:none, opacity:0, zero size). Supports testid shortcuts (e.g., 'testid:submit-button'). Use limit parameter to control how many matches to show (default: 10). NEW: Use onlyVisible parameter to filter results (true=visible only, false=hidden only, undefined=all).
|
|
526
722
|
|
|
527
|
-
|
|
528
|
-
|
|
723
|
+
- Parameters:
|
|
724
|
+
- selector (string, required): CSS selector, text selector, or testid shorthand to test (e.g., 'button.submit', 'testid:login-form', 'text=Sign In')
|
|
725
|
+
- limit (number, optional): Maximum number of elements to return detailed info for (default: 10, recommended max: 50)
|
|
726
|
+
- onlyVisible (boolean, optional): Filter results by visibility: true = show only visible elements, false = show only hidden elements, undefined/not specified = show all elements (default: undefined)
|
|
727
|
+
- showAttributes (string, optional): Comma-separated list of HTML attributes to display for each element (e.g., 'id,name,aria-label,href,type'). If not specified, attributes are not shown.
|
|
529
728
|
|
|
530
|
-
|
|
531
|
-
-
|
|
532
|
-
-
|
|
533
|
-
-
|
|
534
|
-
-
|
|
729
|
+
- Output Format:
|
|
730
|
+
- Header showing total matches (and filtered visible/hidden counts if requested).
|
|
731
|
+
- For each match (up to limit):
|
|
732
|
+
- Index with element tag and identifier (testid/id/class).
|
|
733
|
+
- Position line: @ (x,y) widthxheight px.
|
|
734
|
+
- Optional trimmed text content in quotes.
|
|
735
|
+
- Optional listed attributes if requested.
|
|
736
|
+
- Status line: β visible or β hidden with reason (display:none, opacity:0, zero size); β‘ interactive when applicable.
|
|
737
|
+
- Footer with how many are shown vs omitted and a tip to increase limit.
|
|
535
738
|
|
|
536
|
-
|
|
537
|
-
-
|
|
538
|
-
-
|
|
539
|
-
- Locating overflow:hidden containers that clip elements
|
|
540
|
-
- Understanding why elements have constrained widths
|
|
541
|
-
- Debugging deeply nested component library layouts (Material-UI, Chakra, Ant Design)
|
|
739
|
+
- Examples:
|
|
740
|
+
- query_selector({ selector: 'a', limit: 3 })
|
|
741
|
+
- query_selector({ selector: 'testid:submit', onlyVisible: true, showAttributes: 'href,aria-label' })
|
|
542
742
|
|
|
543
|
-
|
|
743
|
+
- Example Output (query_selector({ selector: 'a', limit: 2 })):
|
|
544
744
|
```
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
745
|
+
Found 5 elements matching "a":
|
|
746
|
+
|
|
747
|
+
[0] <a #home-link>
|
|
748
|
+
@ (16,12) 80x20px
|
|
749
|
+
"Home"
|
|
750
|
+
href: "/"
|
|
751
|
+
β visible, β‘ interactive
|
|
752
|
+
|
|
753
|
+
[1] <a class="nav-item">
|
|
754
|
+
@ (104,12) 120x20px
|
|
755
|
+
"Products"
|
|
756
|
+
β visible, β‘ interactive
|
|
757
|
+
|
|
758
|
+
Showing 2 of 5 matches (3 omitted)
|
|
759
|
+
Use limit parameter to show more: { selector: "a", limit: 5 }
|
|
551
760
|
```
|
|
552
761
|
|
|
553
|
-
|
|
762
|
+
#### `get_test_ids`
|
|
763
|
+
Discover all test identifiers on the page (data-testid, data-test, data-cy, etc.). Returns a compact text list grouped by attribute type. Essential for test-driven workflows and understanding what elements can be reliably selected. Use the returned test IDs with selector shortcuts like 'testid:submit-button'.
|
|
554
764
|
|
|
555
|
-
|
|
556
|
-
|
|
765
|
+
- Parameters:
|
|
766
|
+
- attributes (string, optional): Comma-separated list of test ID attributes to search for (default: 'data-testid,data-test,data-cy')
|
|
767
|
+
- showAll (boolean, optional): If true, display all test IDs without truncation. If false (default), shows first 8 test IDs per attribute with a summary for longer lists.
|
|
557
768
|
|
|
558
|
-
|
|
559
|
-
-
|
|
560
|
-
-
|
|
561
|
-
-
|
|
562
|
-
-
|
|
769
|
+
- Output Format:
|
|
770
|
+
- 'Found N test IDs' header or 'Found 0 test IDs' with tips
|
|
771
|
+
- For each attribute group: attribute name with count and a compact comma-separated list (or truncated with '... and X more')
|
|
772
|
+
- Optional duplicate warnings: attribute:value appears N times
|
|
773
|
+
- Suggestion block with best practices and usage tip for selector shortcuts
|
|
563
774
|
|
|
564
|
-
|
|
565
|
-
|
|
775
|
+
- Examples:
|
|
776
|
+
- get_test_ids({})
|
|
777
|
+
- get_test_ids({ showAll: true })
|
|
778
|
+
- get_test_ids({ attributes: 'data-testid,data-cy' })
|
|
566
779
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
- Understanding box model layout
|
|
571
|
-
- Checking margin/padding/border values
|
|
780
|
+
- Example Output (get_test_ids({})):
|
|
781
|
+
```
|
|
782
|
+
Found 5 test IDs:
|
|
572
783
|
|
|
573
|
-
|
|
574
|
-
|
|
784
|
+
data-testid (3):
|
|
785
|
+
submit, email-input, password-input
|
|
575
786
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
- Scraping visible text
|
|
579
|
-
- Verifying page loaded correctly
|
|
787
|
+
data-cy (2):
|
|
788
|
+
navbar, footer
|
|
580
789
|
|
|
581
|
-
|
|
582
|
-
|
|
790
|
+
π‘ Tip: Use these test IDs with selector shortcuts:
|
|
791
|
+
testid:submit β [data-testid="submit"]
|
|
792
|
+
```
|
|
793
|
+
- Example Output (get_test_ids({ showAll: false })):
|
|
794
|
+
```
|
|
795
|
+
Found 14 test IDs:
|
|
583
796
|
|
|
584
|
-
|
|
585
|
-
-
|
|
586
|
-
|
|
587
|
-
|
|
797
|
+
data-testid (12):
|
|
798
|
+
submit, email-input, password-input, remember-me, login-form, link-register, link-forgot, header-title,
|
|
799
|
+
... and 4 more
|
|
800
|
+
π‘ Use showAll: true to see all 12 test IDs
|
|
588
801
|
|
|
589
|
-
|
|
590
|
-
|
|
802
|
+
data-cy (2):
|
|
803
|
+
navbar, footer
|
|
804
|
+
```
|
|
591
805
|
|
|
592
|
-
|
|
593
|
-
-
|
|
594
|
-
- Monitoring network issues
|
|
595
|
-
- Finding specific log messages
|
|
596
|
-
- Tracking console warnings
|
|
806
|
+
#### `measure_element`
|
|
807
|
+
π MEASUREMENT TOOL - DEBUG SPACING ISSUES: See padding, margin, border, and dimension measurements in visual box model format. Use when elements have unexpected spacing or size. Returns compact visual representation showing content β padding β border β margin with directional arrows (β24px for top margin, etc.). Also provides raw dimensions useful for scroll detection (clientHeight vs content height). For parent-child centering issues, use inspect_dom() first (shows if child is centered in parent). For comparing alignment between two elements, use compare_element_alignment(). For quick scroll detection, use inspect_dom() instead (shows 'scrollable βοΈ'). More readable than get_computed_styles() or evaluate() for box model debugging.
|
|
597
808
|
|
|
598
|
-
|
|
809
|
+
- Parameters:
|
|
810
|
+
- selector (string, required): CSS selector or testid shorthand (e.g., 'testid:submit', '#login-button')
|
|
811
|
+
- elementIndex (number, optional): When selector matches multiple elements, use this 1-based index to select a specific one (e.g., 2 = second element). Default: first visible element.
|
|
812
|
+
|
|
813
|
+
- Output Format:
|
|
814
|
+
- Header: Element: <tag id/class/testid>
|
|
815
|
+
- Position/size line: @ (x,y) widthxheight px
|
|
816
|
+
- Box Model section: Content size, Padding (with directional arrows), Border (with arrows or shorthand), Margin (with arrows)
|
|
817
|
+
- Total Space line: totalWidthxtotalHeight px (with margin)
|
|
818
|
+
- Optional suggestion to run inspect_ancestors when unusual spacing detected
|
|
819
|
+
|
|
820
|
+
- Examples:
|
|
821
|
+
- measure_element({ selector: 'testid:card' })
|
|
822
|
+
- measure_element({ selector: '#hero' })
|
|
823
|
+
|
|
824
|
+
- Example Output (measure_element({ selector: 'testid:card' })):
|
|
825
|
+
```
|
|
826
|
+
Element: <div data-testid="card">
|
|
827
|
+
@ (240,320) 360x240px
|
|
828
|
+
|
|
829
|
+
Box Model:
|
|
830
|
+
Content: 328x208px
|
|
831
|
+
Padding: β16px β16px β8px β8px
|
|
832
|
+
Border: none
|
|
833
|
+
Margin: β0px β24px β0px β0px
|
|
834
|
+
|
|
835
|
+
Total Space: 360x264px (with margin)
|
|
836
|
+
```
|
|
599
837
|
|
|
600
838
|
#### `find_by_text`
|
|
601
|
-
Find elements by text content with exact
|
|
839
|
+
Find elements by their text content. Essential for finding elements without good selectors, especially in poorly structured DOM. Returns elements with position, visibility, and interaction state. Supports exact match, case-sensitive search, and NEW: regex pattern matching for advanced text searching (e.g., '/\d+ items?/' to find elements with numbers).
|
|
840
|
+
|
|
841
|
+
- Parameters:
|
|
842
|
+
- text (string, required): Text to search for in elements. If regex=true, this can be a regex pattern in /pattern/flags format (e.g., '/\d+/i' for case-insensitive numbers) or a raw pattern string.
|
|
843
|
+
- exact (boolean, optional): Whether to match text exactly (default: false, allows partial matches). Ignored if regex=true.
|
|
844
|
+
- caseSensitive (boolean, optional): Whether search should be case-sensitive (default: false). Ignored if regex=true (use regex flags instead).
|
|
845
|
+
- regex (boolean, optional): Whether to treat 'text' as a regex pattern (default: false). If true, supports /pattern/flags format or raw pattern. Examples: '/sign.*/i' (case-insensitive), '/\d+ items?/' (numbers + optional 's').
|
|
846
|
+
- limit (number, optional): Maximum number of elements to return (default: 10)
|
|
602
847
|
|
|
603
|
-
|
|
604
|
-
-
|
|
605
|
-
-
|
|
606
|
-
-
|
|
607
|
-
-
|
|
848
|
+
- Output Format:
|
|
849
|
+
- Header showing 'No elements found ...' or 'Found N elements ...'
|
|
850
|
+
- Up to limit results, each with:
|
|
851
|
+
- <tag id/class/testid ...> line with key attributes
|
|
852
|
+
- Position line: @ (x,y) widthxheight px
|
|
853
|
+
- Trimmed text content (if any)
|
|
854
|
+
- Visibility and interactability status
|
|
855
|
+
- Footer shows how many are displayed vs omitted and how to increase limit
|
|
608
856
|
|
|
609
|
-
|
|
610
|
-
-
|
|
611
|
-
-
|
|
857
|
+
- Examples:
|
|
858
|
+
- find_by_text({ text: 'Sign in' })
|
|
859
|
+
- find_by_text({ text: '/^Next \d+$/', regex: true })
|
|
860
|
+
- find_by_text({ text: 'Delete', exact: true, caseSensitive: true })
|
|
861
|
+
|
|
862
|
+
- Example Output (find_by_text({ text: 'Sign in' })):
|
|
863
|
+
```
|
|
864
|
+
Found 3 elements containing "Sign in":
|
|
865
|
+
|
|
866
|
+
[0] <button data-testid="primary-cta">
|
|
867
|
+
@ (640,420) 120x40px
|
|
868
|
+
"Sign in"
|
|
869
|
+
β visible
|
|
870
|
+
|
|
871
|
+
[1] <a class="link" href="/signin">
|
|
872
|
+
@ (600,480) 68x20px
|
|
873
|
+
"Sign in"
|
|
874
|
+
β visible, β‘ interactive
|
|
875
|
+
|
|
876
|
+
[2] <div class="menu-item">
|
|
877
|
+
@ (40,360) 200x24px
|
|
878
|
+
"Sign in"
|
|
879
|
+
β hidden
|
|
880
|
+
|
|
881
|
+
Showing all 3 matches
|
|
882
|
+
```
|
|
612
883
|
|
|
613
884
|
#### `element_exists`
|
|
614
|
-
Ultra-lightweight existence
|
|
885
|
+
Quick check if an element exists on the page. Ultra-lightweight alternative to query_selector_all when you only need existence confirmation. Returns simple exists/not found status. Most common check before attempting interaction. Supports testid shortcuts.
|
|
615
886
|
|
|
616
|
-
|
|
617
|
-
-
|
|
618
|
-
- Polling for element appearance
|
|
619
|
-
- Conditional logic based on element presence
|
|
887
|
+
- Parameters:
|
|
888
|
+
- selector (string, required): CSS selector, text selector, or testid shorthand (e.g., 'testid:submit-button', '#main')
|
|
620
889
|
|
|
621
|
-
|
|
890
|
+
- Output Format:
|
|
891
|
+
- Returns one line:
|
|
892
|
+
- β exists: <tag id/class> (N matches) when found (N optional)
|
|
893
|
+
- β not found: <original selector> when none
|
|
622
894
|
|
|
623
|
-
|
|
624
|
-
|
|
895
|
+
- Examples:
|
|
896
|
+
- element_exists({ selector: 'testid:submit' })
|
|
897
|
+
- element_exists({ selector: '#does-not-exist' })
|
|
625
898
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
-
|
|
631
|
-
|
|
899
|
+
- Example Output (element_exists({ selector: 'testid:submit' })):
|
|
900
|
+
```
|
|
901
|
+
β exists: <button data-testid="submit">
|
|
902
|
+
```
|
|
903
|
+
- Example Output (element_exists({ selector: '.card' })):
|
|
904
|
+
```
|
|
905
|
+
β exists: <div .card> (3 matches)
|
|
906
|
+
```
|
|
907
|
+
- Example Output (element_exists({ selector: '#does-not-exist' })):
|
|
908
|
+
```
|
|
909
|
+
β not found: #does-not-exist
|
|
910
|
+
```
|
|
632
911
|
|
|
633
|
-
|
|
634
|
-
- Browser window is **visible by default** for interactive debugging
|
|
635
|
-
- Use `headless: true` for automation, CI/CD, or when you don't need visual feedback
|
|
636
|
-
- Use `headless: false` (or omit) when debugging interactively
|
|
912
|
+
### Navigation
|
|
637
913
|
|
|
638
914
|
#### `go_back`
|
|
639
|
-
Navigate back in browser history
|
|
640
|
-
|
|
641
|
-
**Use Cases:**
|
|
642
|
-
- Testing back button behavior
|
|
643
|
-
- Debugging navigation state
|
|
644
|
-
- Verifying history management
|
|
645
|
-
- Testing multi-page workflows
|
|
915
|
+
Navigate back in browser history
|
|
646
916
|
|
|
647
917
|
#### `go_forward`
|
|
648
|
-
Navigate forward in browser history
|
|
918
|
+
Navigate forward in browser history
|
|
649
919
|
|
|
650
|
-
|
|
651
|
-
-
|
|
652
|
-
- Verifying browser history state
|
|
653
|
-
- Debugging navigation flows
|
|
920
|
+
#### `navigate`
|
|
921
|
+
Navigate to a URL. Browser sessions (cookies, localStorage, sessionStorage) are automatically saved in ./.mcp-web-inspector/user-data directory and persist across restarts. To clear saved sessions, delete the directory.
|
|
654
922
|
|
|
655
|
-
|
|
656
|
-
|
|
923
|
+
- Parameters:
|
|
924
|
+
- url (string, required): URL to navigate to the website specified
|
|
925
|
+
- browserType (string, optional): Browser type to use (chromium, firefox, webkit). Defaults to chromium
|
|
926
|
+
- device (string, optional): Device preset to emulate. Uses device configurations for viewport, user agent, and device scale factor. When specified, overrides width/height parameters. Mobile: iphone-se, iphone-14, iphone-14-pro, pixel-5, ipad, samsung-s21. Desktop: desktop-1080p (1920x1080), desktop-2k (2560x1440), laptop-hd (1366x768).
|
|
927
|
+
- width (number, optional): Viewport width in pixels. If not specified, automatically matches screen width. Ignored if device is specified.
|
|
928
|
+
- height (number, optional): Viewport height in pixels. If not specified, automatically matches screen height. Ignored if device is specified.
|
|
929
|
+
- timeout (number, optional): Navigation timeout in milliseconds
|
|
930
|
+
- waitUntil (string, optional): Navigation wait condition
|
|
931
|
+
- headless (boolean, optional): Run browser in headless mode (default: false - browser window visible)
|
|
657
932
|
|
|
658
|
-
|
|
659
|
-
-
|
|
660
|
-
- Element-specific screenshots
|
|
661
|
-
- Custom viewport sizes
|
|
662
|
-
- Save to custom directory
|
|
933
|
+
#### `scroll_by`
|
|
934
|
+
Scroll a container (or page) by a specific number of pixels. Auto-detects scroll direction when only one is available. Essential for: testing sticky headers/footers, triggering infinite scroll, carousel navigation, precise scroll position testing. Use 'html' or 'body' for page scrolling. Positive pixels = down/right, negative = up/left. Outputs: β success summary with axis position and percent of max scroll; β οΈ boundary notice when movement is limited; β οΈ ambiguous-direction guidance when both axes scroll; β οΈ not-scrollable report with ancestor suggestions; π‘ follow-up tips matching the detected scenario.
|
|
663
935
|
|
|
664
|
-
|
|
665
|
-
|
|
936
|
+
- Parameters:
|
|
937
|
+
- selector (string, required): CSS selector of scrollable container (use 'html' or 'body' for page scroll, e.g., 'testid:chat-container', '.scrollable-list', 'html')
|
|
938
|
+
- pixels (number, required): Number of pixels to scroll. Positive = down/right, negative = up/left. Example: 500, -200
|
|
939
|
+
- direction (string, optional): Scroll direction: 'vertical' (default), 'horizontal', or 'auto' (detects available direction). Use 'auto' for smart detection.
|
|
940
|
+
|
|
941
|
+
#### `scroll_to_element`
|
|
942
|
+
Scroll an element into view. Automatically handles scrolling within the nearest scrollable ancestor (page or scrollable container). Essential for: making elements visible before interaction, triggering lazy-loaded content, testing scroll behavior. Position: start (top of viewport), center (middle), end (bottom). Default: start.
|
|
943
|
+
|
|
944
|
+
- Parameters:
|
|
945
|
+
- selector (string, required): CSS selector, text selector, or test ID (e.g., 'testid:submit-btn', '#login-button', 'text=Load More')
|
|
946
|
+
- position (string, optional): Where to align element in viewport: 'start' (top), 'center' (middle), 'end' (bottom). Default: 'start'
|
|
666
947
|
|
|
667
|
-
###
|
|
948
|
+
### Interaction
|
|
668
949
|
|
|
669
950
|
#### `click`
|
|
670
|
-
Click an element on the page
|
|
951
|
+
Click an element on the page
|
|
952
|
+
|
|
953
|
+
- Parameters:
|
|
954
|
+
- selector (string, required): CSS selector for the element to click
|
|
955
|
+
|
|
956
|
+
#### `drag`
|
|
957
|
+
Drag an element to a target location
|
|
671
958
|
|
|
672
|
-
|
|
673
|
-
-
|
|
674
|
-
-
|
|
675
|
-
- Debugging click event handlers
|
|
676
|
-
- Simulating user interactions during inspection
|
|
959
|
+
- Parameters:
|
|
960
|
+
- sourceSelector (string, required): CSS selector for the element to drag
|
|
961
|
+
- targetSelector (string, required): CSS selector for the target location
|
|
677
962
|
|
|
678
963
|
#### `fill`
|
|
679
|
-
|
|
964
|
+
fill out an input field
|
|
680
965
|
|
|
681
|
-
|
|
682
|
-
-
|
|
683
|
-
-
|
|
684
|
-
- Simulating user data entry
|
|
685
|
-
- Testing autocomplete and search features
|
|
966
|
+
- Parameters:
|
|
967
|
+
- selector (string, required): CSS selector for input field
|
|
968
|
+
- value (string, required): Value to fill
|
|
686
969
|
|
|
687
970
|
#### `hover`
|
|
688
|
-
Hover
|
|
971
|
+
Hover an element on the page
|
|
689
972
|
|
|
690
|
-
|
|
691
|
-
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
973
|
+
- Parameters:
|
|
974
|
+
- selector (string, required): CSS selector for element to hover
|
|
975
|
+
|
|
976
|
+
#### `press_key`
|
|
977
|
+
Press a keyboard key
|
|
978
|
+
|
|
979
|
+
- Parameters:
|
|
980
|
+
- key (string, required): Key to press (e.g. 'Enter', 'ArrowDown', 'a')
|
|
981
|
+
- selector (string, optional): Optional CSS selector to focus before pressing key
|
|
695
982
|
|
|
696
983
|
#### `select`
|
|
697
|
-
Select an
|
|
984
|
+
Select an element on the page with Select tag
|
|
698
985
|
|
|
699
|
-
|
|
700
|
-
-
|
|
701
|
-
-
|
|
702
|
-
- Simulating user form completion
|
|
703
|
-
- Testing dependent field updates
|
|
986
|
+
- Parameters:
|
|
987
|
+
- selector (string, required): CSS selector for element to select
|
|
988
|
+
- value (string, required): Value to select
|
|
704
989
|
|
|
705
990
|
#### `upload_file`
|
|
706
|
-
Upload a file to an
|
|
991
|
+
Upload a file to an input[type='file'] element on the page
|
|
707
992
|
|
|
708
|
-
|
|
709
|
-
-
|
|
710
|
-
-
|
|
711
|
-
- Simulating document/image uploads
|
|
712
|
-
- Testing upload validation
|
|
993
|
+
- Parameters:
|
|
994
|
+
- selector (string, required): CSS selector for the file input element
|
|
995
|
+
- filePath (string, required): Absolute path to the file to upload
|
|
713
996
|
|
|
714
|
-
|
|
715
|
-
Drag an element from source to target location.
|
|
997
|
+
### Content
|
|
716
998
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
- Debugging sortable lists
|
|
720
|
-
- Testing reorderable components
|
|
721
|
-
- Validating drag interactions
|
|
999
|
+
#### `get_html`
|
|
1000
|
+
β οΈ RARELY NEEDED: Get raw HTML markup from the page (no rendering, just source code). Most tasks need structured inspection instead. ONLY use get_html for: (1) checking specific HTML attributes or element nesting, (2) analyzing markup structure, (3) debugging SSR/HTML issues. For structured tasks, use: inspect_dom() to understand page structure with positions, query_selector() to find and inspect elements, get_computed_styles() for CSS values. Auto-returns HTML if <2000 chars (small elements), shows preview with token-based confirmation if larger. Scripts removed by default for security/size. Supports testid shortcuts.
|
|
722
1001
|
|
|
723
|
-
|
|
724
|
-
|
|
1002
|
+
- Parameters:
|
|
1003
|
+
- selector (string, optional): CSS selector, text selector, or testid shorthand to limit HTML extraction to a specific container. Omit to get entire page HTML. Example: 'testid:main-content' or '#app'
|
|
1004
|
+
- elementIndex (number, optional): When selector matches multiple elements, use this 1-based index to select a specific one (e.g., 2 = second element). Default: first visible element.
|
|
1005
|
+
- clean (boolean, optional): Remove noise from HTML: false (default) = remove scripts only, true = remove scripts + styles + comments + meta tags for minimal markup
|
|
1006
|
+
- maxLength (number, optional): Maximum number of characters to return (default: 20000)
|
|
1007
|
+
- confirmToken (string, optional): Confirmation token from preview response (required to retrieve large HTML). Get this token by calling without confirmToken first - the preview will include the token to use.
|
|
1008
|
+
|
|
1009
|
+
#### `get_text`
|
|
1010
|
+
β οΈ RARELY NEEDED: Get ALL visible text content from the entire page (no structure, just raw text). Most tasks need structured inspection instead. ONLY use get_text for: (1) extracting text for content analysis (word count, language detection), (2) searching for text when location is completely unknown, (3) text-only snapshots for comparison. For structured tasks, use: inspect_dom() to understand page structure, find_by_text() to locate specific text with context, query_selector() to find elements. Returns plain text up to 20000 chars (truncated if longer). Supports testid shortcuts.
|
|
1011
|
+
|
|
1012
|
+
- Parameters:
|
|
1013
|
+
- selector (string, optional): CSS selector, text selector, or testid shorthand to limit text extraction to a specific container. Omit to get text from entire page. Example: 'testid:article-body' or '#main-content'
|
|
1014
|
+
- elementIndex (number, optional): When selector matches multiple elements, use this 1-based index to select a specific one (e.g., 2 = second element). Default: first visible element.
|
|
1015
|
+
- maxLength (number, optional): Maximum number of characters to return (default: 20000)
|
|
1016
|
+
|
|
1017
|
+
#### `visual_screenshot_for_humans`
|
|
1018
|
+
πΈ VISUAL OUTPUT TOOL - Captures page/element appearance and saves to file. Essential for: visual regression testing, sharing with humans, confirming UI appearance (colors/fonts/images).
|
|
1019
|
+
|
|
1020
|
+
β WRONG: "Take screenshot to debug button alignment"
|
|
1021
|
+
β
RIGHT: "Use compare_element_alignment() - alignment in <100 tokens"
|
|
1022
|
+
|
|
1023
|
+
β WRONG: "Screenshot to check element visibility"
|
|
1024
|
+
β
RIGHT: "Use check_visibility() - instant visibility + diagnostics"
|
|
1025
|
+
|
|
1026
|
+
β WRONG: "Screenshot to inspect layout structure"
|
|
1027
|
+
β
RIGHT: "Use inspect_dom() - hierarchy with positions and visibility"
|
|
1028
|
+
|
|
1029
|
+
β
VALID: "Share with designer for feedback"
|
|
1030
|
+
β
VALID: "Visual regression check"
|
|
1031
|
+
β
VALID: "Confirm gradient/shadow rendering"
|
|
1032
|
+
|
|
1033
|
+
β οΈ Token cost: ~1,500 tokens to read. Structural tools: <100 tokens.
|
|
725
1034
|
|
|
726
|
-
|
|
727
|
-
- Testing keyboard shortcuts
|
|
728
|
-
- Debugging keyboard navigation
|
|
729
|
-
- Testing Enter/Escape key handlers
|
|
730
|
-
- Simulating Tab key navigation
|
|
1035
|
+
Admin control (optional): set env MCP_SCREENSHOT_GUARD=strict to block execution (prevents misuse by default). Unset to allow visuals for human review.
|
|
731
1036
|
|
|
732
|
-
|
|
1037
|
+
Screenshots saved to ./.mcp-web-inspector/screenshots. Example: { name: "login-page", fullPage: true } or { name: "submit-btn", selector: "testid:submit" }
|
|
1038
|
+
|
|
1039
|
+
- Parameters:
|
|
1040
|
+
- name (string, required): Name for the screenshot file (without extension). Example: 'login-page' or 'error-state'
|
|
1041
|
+
- selector (string, optional): CSS selector or testid shorthand for element to screenshot. Example: '#submit-button' or 'testid:login-form'. Omit to capture full viewport.
|
|
1042
|
+
- fullPage (boolean, optional): Capture entire scrollable page instead of just viewport (default: false)
|
|
1043
|
+
- downloadsDir (string, optional): Custom directory for saving screenshot (default: ./.mcp-web-inspector/screenshots). Example: './my-screenshots'
|
|
1044
|
+
|
|
1045
|
+
### Console
|
|
1046
|
+
|
|
1047
|
+
#### `get_console_logs`
|
|
1048
|
+
Retrieve console logs from the browser with filtering options
|
|
1049
|
+
|
|
1050
|
+
- Parameters:
|
|
1051
|
+
- type (string, optional): Type of logs to retrieve (all, error, warning, log, info, debug, exception)
|
|
1052
|
+
- search (string, optional): Text to search for in logs (handles text with square brackets)
|
|
1053
|
+
- limit (number, optional): Maximum number of logs to return
|
|
1054
|
+
- since (string, optional): Filter logs since a specific event: 'last-call' (since last get_console_logs call), 'last-navigation' (since last page navigation), or 'last-interaction' (since last user interaction like click, fill, etc.)
|
|
1055
|
+
- clear (boolean, optional): Whether to clear logs after retrieval (default: false)
|
|
1056
|
+
|
|
1057
|
+
### Evaluation
|
|
733
1058
|
|
|
734
1059
|
#### `evaluate`
|
|
735
|
-
Execute JavaScript
|
|
1060
|
+
βοΈ CUSTOM JAVASCRIPT EXECUTION - Execute arbitrary JavaScript in the browser console and return the result (JSON-stringified). β οΈ NOT for: scroll detection (inspect_dom shows 'scrollable βοΈ'), element dimensions (use measure_element), DOM inspection (use inspect_dom), CSS properties (use get_computed_styles), position comparison (use compare_positions). Use ONLY when specialized tools cannot accomplish the task. Essential for: custom page interactions, complex calculations not covered by other tools. Automatically detects common patterns and suggests better alternatives. High flexibility but less efficient than specialized tools.
|
|
736
1061
|
|
|
737
|
-
|
|
738
|
-
-
|
|
739
|
-
- Extracting complex data not available via other tools
|
|
740
|
-
- Testing JavaScript functions on the page
|
|
741
|
-
- Manipulating page state for testing
|
|
1062
|
+
- Parameters:
|
|
1063
|
+
- script (string, required): JavaScript code to execute
|
|
742
1064
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
1065
|
+
### Network
|
|
1066
|
+
|
|
1067
|
+
#### `get_request_details`
|
|
1068
|
+
Get detailed information about a specific network request by index (from list_network_requests). Returns request/response headers, body (truncated at 500 chars), timing, and size. Request bodies with passwords are automatically masked. Essential for debugging API responses and investigating failed requests.
|
|
1069
|
+
|
|
1070
|
+
- Parameters:
|
|
1071
|
+
- index (number, required): Index of the request from list_network_requests output (e.g., [0], [1], etc.)
|
|
1072
|
+
|
|
1073
|
+
#### `list_network_requests`
|
|
1074
|
+
List recent network requests captured by the browser. Returns compact text format with method, URL, status, resource type, timing, and size. Essential for debugging API calls and performance issues. Use get_request_details() to inspect full headers and body for specific requests.
|
|
1075
|
+
|
|
1076
|
+
- Parameters:
|
|
1077
|
+
- type (string, optional): Filter by resource type: 'xhr', 'fetch', 'script', 'stylesheet', 'image', 'font', 'document', etc. Omit to show all types.
|
|
1078
|
+
- limit (number, optional): Maximum number of requests to return, most recent first (default: 50)
|
|
1079
|
+
|
|
1080
|
+
### Waiting
|
|
1081
|
+
|
|
1082
|
+
#### `wait_for_element`
|
|
1083
|
+
Wait for an element to reach a specific state (visible, hidden, attached, detached). Better than sleep() for waiting on dynamic content. Returns duration and current element status. Supports testid shortcuts (e.g., 'testid:submit-button').
|
|
1084
|
+
|
|
1085
|
+
- Parameters:
|
|
1086
|
+
- selector (string, required): CSS selector, text selector, or testid shorthand (e.g., 'testid:submit-button', '#loading-spinner')
|
|
1087
|
+
- state (string, optional): State to wait for: 'visible' (default), 'hidden', 'attached', 'detached'
|
|
1088
|
+
- timeout (number, optional): Maximum time to wait in milliseconds (default: 10000)
|
|
748
1089
|
|
|
1090
|
+
#### `wait_for_network_idle`
|
|
1091
|
+
Wait for network activity to settle. Waits until there are no network connections for at least 500ms. Better than fixed delays when waiting for AJAX calls or dynamic content loading. Returns actual wait duration and confirmation of idle state.
|
|
1092
|
+
|
|
1093
|
+
- Parameters:
|
|
1094
|
+
- timeout (number, optional): Maximum time to wait in milliseconds (default: 10000)
|
|
1095
|
+
|
|
1096
|
+
### Lifecycle
|
|
1097
|
+
|
|
1098
|
+
#### `close`
|
|
1099
|
+
Close the browser and release all resources
|
|
1100
|
+
|
|
1101
|
+
#### `set_color_scheme`
|
|
1102
|
+
Set the browser color scheme that controls CSS prefers-color-scheme. Defaults to system appearance. Use before inspecting colors or taking screenshots. Options: system (clear override to follow OS/browser setting), dark, light, no-preference (simulate agents with no declared preference). Returns confirmation of the active scheme.
|
|
1103
|
+
|
|
1104
|
+
- Parameters:
|
|
1105
|
+
- scheme (string, required): Color scheme to emulate: 'system', 'dark', 'light', or 'no-preference'. Example: { scheme: 'dark' }
|
|
749
1106
|
## Selector Shortcuts β Time-Saver
|
|
750
1107
|
|
|
751
1108
|
All browser tools support **convenient test ID shortcuts** that save typing and improve readability:
|
|
@@ -842,15 +1199,13 @@ These step-by-step recipes show how to chain tools together for common testing a
|
|
|
842
1199
|
|
|
843
1200
|
```
|
|
844
1201
|
1. navigate({ url: "https://app.example.com/login" })
|
|
845
|
-
2.
|
|
846
|
-
3. fill({ selector: "testid:
|
|
847
|
-
4.
|
|
848
|
-
5.
|
|
849
|
-
6.
|
|
850
|
-
7. get_console_logs({ type: "error" })
|
|
1202
|
+
2. fill({ selector: "testid:email-input", value: "user@example.com" })
|
|
1203
|
+
3. fill({ selector: "testid:password-input", value: "password123" })
|
|
1204
|
+
4. click({ selector: "testid:login-button" })
|
|
1205
|
+
5. wait_for_network_idle()
|
|
1206
|
+
6. get_console_logs({ type: "error" })
|
|
851
1207
|
β Verify no JavaScript errors occurred
|
|
852
|
-
|
|
853
|
-
9. get_text()
|
|
1208
|
+
7. get_text()
|
|
854
1209
|
β Verify success message or dashboard content
|
|
855
1210
|
```
|
|
856
1211
|
|
|
@@ -877,7 +1232,26 @@ These step-by-step recipes show how to chain tools together for common testing a
|
|
|
877
1232
|
properties: "margin,padding,display,flex-direction"
|
|
878
1233
|
})
|
|
879
1234
|
β Shows: display: flex, flex-direction: column, padding: 20px
|
|
880
|
-
|
|
1235
|
+
```
|
|
1236
|
+
1. navigate({ url: "https://dashboard.example.com" })
|
|
1237
|
+
2. inspect_dom({ selector: "testid:sidebar" })
|
|
1238
|
+
β Understand the structure of the problematic area
|
|
1239
|
+
3. measure_element({ selector: "testid:logo" })
|
|
1240
|
+
β @ (20,10) 150x40px
|
|
1241
|
+
4. measure_element({ selector: "testid:menu" })
|
|
1242
|
+
β @ (20,60) 200x300px
|
|
1243
|
+
5. compare_positions({
|
|
1244
|
+
selector1: "testid:logo",
|
|
1245
|
+
selector2: "testid:menu",
|
|
1246
|
+
checkAlignment: "left"
|
|
1247
|
+
})
|
|
1248
|
+
β β aligned (both at x=20)
|
|
1249
|
+
6. get_computed_styles({
|
|
1250
|
+
selector: "testid:sidebar",
|
|
1251
|
+
properties: "margin,padding,display,flex-direction"
|
|
1252
|
+
})
|
|
1253
|
+
β Shows: display: flex, flex-direction: column, padding: 20px
|
|
1254
|
+
```
|
|
881
1255
|
```
|
|
882
1256
|
|
|
883
1257
|
**Why this works**: Progressive inspection + precise measurements reveal layout problems.
|
|
@@ -971,22 +1345,21 @@ These step-by-step recipes show how to chain tools together for common testing a
|
|
|
971
1345
|
|
|
972
1346
|
```
|
|
973
1347
|
1. navigate({ url: "https://dashboard.example.com" })
|
|
974
|
-
2.
|
|
975
|
-
3. compare_positions({
|
|
1348
|
+
2. compare_positions({
|
|
976
1349
|
selector1: "testid:header",
|
|
977
1350
|
selector2: "testid:footer",
|
|
978
1351
|
checkAlignment: "width"
|
|
979
1352
|
})
|
|
980
1353
|
β β aligned (both 1280px)
|
|
981
|
-
|
|
1354
|
+
3. compare_positions({
|
|
982
1355
|
selector1: ".card:nth-child(1)",
|
|
983
1356
|
selector2: ".card:nth-child(2)",
|
|
984
1357
|
checkAlignment: "height"
|
|
985
1358
|
})
|
|
986
1359
|
β β not aligned (difference: 20px)
|
|
987
|
-
|
|
1360
|
+
4. measure_element({ selector: ".card:nth-child(1)" })
|
|
988
1361
|
β @ (20,100) 400x300px
|
|
989
|
-
|
|
1362
|
+
5. measure_element({ selector: ".card:nth-child(2)" })
|
|
990
1363
|
β @ (440,100) 400x320px β 20px taller!
|
|
991
1364
|
```
|
|
992
1365
|
|
|
@@ -1004,7 +1377,8 @@ These step-by-step recipes show how to chain tools together for common testing a
|
|
|
1004
1377
|
β Found 2 elements: .error-message spans
|
|
1005
1378
|
7. get_text({ selector: ".error-message" })
|
|
1006
1379
|
β "Please enter a valid email address"
|
|
1007
|
-
8.
|
|
1380
|
+
8. get_text({ selector: ".error-message" })
|
|
1381
|
+
β Capture validation text for assertions
|
|
1008
1382
|
```
|
|
1009
1383
|
|
|
1010
1384
|
**Why this works**: Wait for element ensures validation messages appear before checking.
|
|
@@ -1018,8 +1392,7 @@ These step-by-step recipes show how to chain tools together for common testing a
|
|
|
1018
1392
|
height: 667
|
|
1019
1393
|
})
|
|
1020
1394
|
β iPhone SE viewport
|
|
1021
|
-
2.
|
|
1022
|
-
3. inspect_dom({ selector: "nav" })
|
|
1395
|
+
2. inspect_dom({ selector: "nav" })
|
|
1023
1396
|
β Check if mobile menu is used
|
|
1024
1397
|
4. element_exists({ selector: "testid:hamburger-menu" })
|
|
1025
1398
|
β β exists (mobile menu visible)
|
|
@@ -1027,7 +1400,8 @@ These step-by-step recipes show how to chain tools together for common testing a
|
|
|
1027
1400
|
β β not found (desktop menu hidden on mobile)
|
|
1028
1401
|
6. click({ selector: "testid:hamburger-menu" })
|
|
1029
1402
|
7. wait_for_element({ selector: "testid:mobile-nav", state: "visible" })
|
|
1030
|
-
8.
|
|
1403
|
+
8. get_text({ selector: "testid:mobile-nav" })
|
|
1404
|
+
β Snapshot of opened mobile menu content
|
|
1031
1405
|
```
|
|
1032
1406
|
|
|
1033
1407
|
**Why this works**: Viewport configuration in navigate enables mobile testing.
|
|
@@ -1047,7 +1421,8 @@ These step-by-step recipes show how to chain tools together for common testing a
|
|
|
1047
1421
|
properties: "display,opacity,visibility,z-index"
|
|
1048
1422
|
})
|
|
1049
1423
|
β display: block, opacity: 1, visibility: visible, z-index: 1000
|
|
1050
|
-
7.
|
|
1424
|
+
7. check_visibility({ selector: "testid:tooltip" })
|
|
1425
|
+
β Double-check that tooltip remains visible
|
|
1051
1426
|
```
|
|
1052
1427
|
|
|
1053
1428
|
**Why this works**: Hover tool + visibility checks validate tooltip behavior.
|