{
  "doc": {
    "id": "api/commands/trigger",
    "title": "trigger | Cypress Documentation",
    "description": "Trigger an event on a DOM element in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/trigger.md",
    "version": "a8fd16711bdda4c7b5645b9717e588ae99ec2470",
    "updated_at": "2026-05-18T17:21:32.047Z",
    "headings": [
      {
        "id": "api/commands/trigger#trigger",
        "text": "trigger",
        "level": 1
      },
      {
        "id": "api/commands/trigger#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/trigger#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/trigger#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/trigger#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/trigger#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/trigger#mouse-events",
        "text": "Mouse Events",
        "level": 3
      },
      {
        "id": "api/commands/trigger#trigger-a-mouseover-on-the-button",
        "text": "Trigger a mouseover on the button",
        "level": 4
      },
      {
        "id": "api/commands/trigger#simulate-a-long-press-event",
        "text": "Simulate a \"long press\" event",
        "level": 4
      },
      {
        "id": "api/commands/trigger#trigger-a-mousedown-from-a-specific-mouse-button",
        "text": "Trigger a mousedown from a specific mouse button",
        "level": 4
      },
      {
        "id": "api/commands/trigger#jquery-ui-sortable",
        "text": "jQuery UI Sortable",
        "level": 4
      },
      {
        "id": "api/commands/trigger#drag-and-drop",
        "text": "Drag and Drop",
        "level": 4
      },
      {
        "id": "api/commands/trigger#change-event",
        "text": "Change Event",
        "level": 3
      },
      {
        "id": "api/commands/trigger#interact-with-a-range-input-slider",
        "text": "Interact with a range input (slider)",
        "level": 4
      },
      {
        "id": "api/commands/trigger#position",
        "text": "Position",
        "level": 3
      },
      {
        "id": "api/commands/trigger#trigger-a-mousedown-on-the-top-right-of-a-button",
        "text": "Trigger a mousedown on the top right of a button",
        "level": 4
      },
      {
        "id": "api/commands/trigger#coordinates",
        "text": "Coordinates",
        "level": 3
      },
      {
        "id": "api/commands/trigger#specify-explicit-coordinates-relative-to-the-top-left-corner",
        "text": "Specify explicit coordinates relative to the top left corner",
        "level": 4
      },
      {
        "id": "api/commands/trigger#options",
        "text": "Options",
        "level": 3
      },
      {
        "id": "api/commands/trigger#specify-that-the-event-should-not-bubble",
        "text": "Specify that the event should not bubble",
        "level": 4
      },
      {
        "id": "api/commands/trigger#specify-the-exact-clientx-and-clienty-the-event-should-have",
        "text": "Specify the exact clientX and clientY the event should have",
        "level": 4
      },
      {
        "id": "api/commands/trigger#fire-other-event-types",
        "text": "Fire other Event types.",
        "level": 3
      },
      {
        "id": "api/commands/trigger#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/trigger#actionability",
        "text": "Actionability",
        "level": 3
      },
      {
        "id": "api/commands/trigger#the-element-must-first-reach-actionability",
        "text": "The element must first reach actionability",
        "level": 4
      },
      {
        "id": "api/commands/trigger#events",
        "text": "Events",
        "level": 3
      },
      {
        "id": "api/commands/trigger#what-event-should-i-fire",
        "text": "What event should I fire?",
        "level": 4
      },
      {
        "id": "api/commands/trigger#why-should-i-manually-set-the-event-type",
        "text": "Why should I manually set the event type?",
        "level": 4
      },
      {
        "id": "api/commands/trigger#differences",
        "text": "Differences",
        "level": 3
      },
      {
        "id": "api/commands/trigger#whats-the-difference-between-triggering-and-event-and-calling-the-corresponding-cypress-command",
        "text": "What's the difference between triggering and event and calling the corresponding cypress command?",
        "level": 4
      },
      {
        "id": "api/commands/trigger#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/trigger#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/trigger#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/trigger#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/trigger#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/trigger#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/trigger#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/trigger#syntax",
      "doc_id": "api/commands/trigger",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\n.trigger(eventName).trigger(eventName, position).trigger(eventName, options).trigger(eventName, x, y).trigger(eventName, position, options).trigger(eventName, x, y, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.get('a').trigger('mousedown') // Trigger mousedown event on link\n```\n\n**Incorrect Usage**\n\n```\ncy.trigger('touchstart') // Errors, cannot be chained off 'cy'cy.clock().trigger('mouseleave') // Errors, 'clock' does not yield DOM elements\n```\n\n### Arguments\n\n**eventName _(String)_**\n\nThe name of the `event` to be triggered on the DOM element.\n\n**position _(String)_**\n\nThe position where the event should be triggered. The `center` position is the default position. Valid positions are `topLeft`, `top`, `topRight`, `left`, `center`, `right`, `bottomLeft`, `bottom`, and `bottomRight`.\n\n**x _(Number)_**\n\nThe distance in pixels from element's left to trigger the event.\n\n**y _(Number)_**\n\nThe distance in pixels from element's top to trigger the event.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.trigger()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `animationDistanceThreshold` | [`animationDistanceThreshold`](/llm/markdown/app/references/configuration.md#Actionability) | The distance in pixels an element must exceed over time to be [considered animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations). |\n| `bubbles` | `true` | Whether the event bubbles |\n| `cancelable` | `true` | Whether the event is cancelable |\n| `eventConstructor` | `Event` | The constructor for creating the event object (e.g. `MouseEvent`, `KeyboardEvent`) |\n| `force` | `false` | Forces the action, disables [waiting for actionability](#Assertions) |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `scrollBehavior` | [`scrollBehavior`](/llm/markdown/app/references/configuration.md#Actionability) | Viewport position to where an element [should be scrolled](/llm/markdown/app/core-concepts/interacting-with-elements.md#Scrolling) before executing the command |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.trigger()` to resolve before [timing out](#Timeouts) |\n| `waitForAnimations` | [`waitForAnimations`](/llm/markdown/app/references/configuration.md#Actionability) | Whether to wait for elements to [finish animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations) before executing the command. |\n\nYou can also include arbitrary event properties (e.g. `clientX`, `shiftKey`) and they will be attached to the event. Passing in coordinate arguments (`clientX`, `pageX`, etc) will override the position coordinates.\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `.trigger()` yields the same subject it was given.\n*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.trigger()`.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 457
    },
    {
      "id": "api/commands/trigger#usage",
      "doc_id": "api/commands/trigger",
      "heading": "Usage",
      "heading_level": 3,
      "content_markdown": "### Usage\n\n**Correct Usage**\n\n```\ncy.get('a').trigger('mousedown') // Trigger mousedown event on link\n```\n\n**Incorrect Usage**\n\n```\ncy.trigger('touchstart') // Errors, cannot be chained off 'cy'cy.clock().trigger('mouseleave') // Errors, 'clock' does not yield DOM elements\n```\n",
      "section": "api",
      "anchors": [
        "usage"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 44
    },
    {
      "id": "api/commands/trigger#arguments",
      "doc_id": "api/commands/trigger",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**eventName _(String)_**\n\nThe name of the `event` to be triggered on the DOM element.\n\n**position _(String)_**\n\nThe position where the event should be triggered. The `center` position is the default position. Valid positions are `topLeft`, `top`, `topRight`, `left`, `center`, `right`, `bottomLeft`, `bottom`, and `bottomRight`.\n\n**x _(Number)_**\n\nThe distance in pixels from element's left to trigger the event.\n\n**y _(Number)_**\n\nThe distance in pixels from element's top to trigger the event.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `.trigger()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `animationDistanceThreshold` | [`animationDistanceThreshold`](/llm/markdown/app/references/configuration.md#Actionability) | The distance in pixels an element must exceed over time to be [considered animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations). |\n| `bubbles` | `true` | Whether the event bubbles |\n| `cancelable` | `true` | Whether the event is cancelable |\n| `eventConstructor` | `Event` | The constructor for creating the event object (e.g. `MouseEvent`, `KeyboardEvent`) |\n| `force` | `false` | Forces the action, disables [waiting for actionability](#Assertions) |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `scrollBehavior` | [`scrollBehavior`](/llm/markdown/app/references/configuration.md#Actionability) | Viewport position to where an element [should be scrolled](/llm/markdown/app/core-concepts/interacting-with-elements.md#Scrolling) before executing the command |\n| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.trigger()` to resolve before [timing out](#Timeouts) |\n| `waitForAnimations` | [`waitForAnimations`](/llm/markdown/app/references/configuration.md#Actionability) | Whether to wait for elements to [finish animating](/llm/markdown/app/core-concepts/interacting-with-elements.md#Animations) before executing the command. |\n\nYou can also include arbitrary event properties (e.g. `clientX`, `shiftKey`) and they will be attached to the event. Passing in coordinate arguments (`clientX`, `pageX`, etc) will override the position coordinates.\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 355
    },
    {
      "id": "api/commands/trigger#yields-learn-about-subject-management",
      "doc_id": "api/commands/trigger",
      "heading": "Yields Learn about subject management",
      "heading_level": 3,
      "content_markdown": "### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `.trigger()` yields the same subject it was given.\n*   It is [unsafe](/llm/markdown/app/core-concepts/retry-ability.md#Only-queries-are-retried) to chain further commands that rely on the subject after `.trigger()`.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 40
    },
    {
      "id": "api/commands/trigger#examples",
      "doc_id": "api/commands/trigger",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Mouse Events\n\n#### Trigger a `mouseover` on the button\n\nThe DOM element must be in an \"interactable\" state prior to the triggered event happening (it must be visible and not disabled).\n\n```\ncy.get('button').trigger('mouseover') // yields 'button'\n```\n\n#### Simulate a \"long press\" event\n\n```\ncy.get('.target').trigger('mousedown')cy.wait(1000)cy.get('.target').trigger('mouseup')\n```\n\n#### Trigger a `mousedown` from a specific mouse button\n\n```\n// Main button pressed (usually the left button)cy.get('.target').trigger('mousedown', { button: 0 })// Auxiliary button pressed (usually the middle button)cy.get('.target').trigger('mousedown', { button: 1 })//Secondary button pressed (usually the right button)cy.get('.target').trigger('mousedown', { button: 2 })\n```\n\n#### jQuery UI Sortable\n\nTo simulate drag and drop using jQuery UI sortable requires `pageX` and `pageY` properties along with `which:1`.\n\n```\ncy.get('[data-cy=draggable]').trigger('mousedown', {  which: 1,  pageX: 600,  pageY: 100,})cy.get('[data-cy=draggable]').trigger('mousemove', {  which: 1,  pageX: 600,  pageY: 600,})cy.get('[data-cy=draggable]').trigger('mouseup')\n```\n\n#### Drag and Drop\n\n[Check out our example recipe triggering mouse and drag events to test drag and drop](/llm/markdown/app/references/recipes.md#Testing-the-DOM)\n\n### Change Event\n\n#### Interact with a range input (slider)\n\nTo interact with a range input (slider), we need to set its value and then trigger the appropriate event to signal it has changed.\n\nBelow we invoke jQuery's `val()` method to set the value, then trigger the `change` event.\n\nNote that some implementations may rely on the `input` event instead, which is fired as a user moves the slider, but is not supported by some browsers.\n\n```\ncy.get('input[type=range]').as('range').invoke('val', 25).trigger('change')cy.get('@range').siblings('p').should('have.text', '25')\n```\n\n### Position\n\n#### Trigger a `mousedown` on the top right of a button\n\n```\ncy.get('button').trigger('mousedown', 'topRight')\n```\n\n### Coordinates\n\n#### Specify explicit coordinates relative to the top left corner\n\n```\ncy.get('button').trigger('mouseup', 15, 40)\n```\n\n### Options\n\n#### Specify that the event should not bubble\n\nBy default, the event will bubble up the DOM tree. This will prevent the event from bubbling.\n\n```\ncy.get('button').trigger('mouseover', { bubbles: false })\n```\n\n#### Specify the exact `clientX` and `clientY` the event should have\n\nThis overrides the default auto-positioning based on the element itself. Useful for events like `mousemove` where you need the position to be outside the element itself.\n\n```\ncy.get('button').trigger('mousemove', { clientX: 200, clientY: 300 })\n```\n\n### Fire other Event types.\n\nBy default, `cy.trigger()` fires [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). But you may want to trigger other events like `MouseEvent` or `KeyboardEvent`.\n\nIn that case, use the `eventConstructor` option.\n\n```\ncy.get('button').trigger('mouseover', { eventConstructor: 'MouseEvent' })\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 508
    },
    {
      "id": "api/commands/trigger#mouse-events",
      "doc_id": "api/commands/trigger",
      "heading": "Mouse Events",
      "heading_level": 3,
      "content_markdown": "### Mouse Events\n\n#### Trigger a `mouseover` on the button\n\nThe DOM element must be in an \"interactable\" state prior to the triggered event happening (it must be visible and not disabled).\n\n```\ncy.get('button').trigger('mouseover') // yields 'button'\n```\n\n#### Simulate a \"long press\" event\n\n```\ncy.get('.target').trigger('mousedown')cy.wait(1000)cy.get('.target').trigger('mouseup')\n```\n\n#### Trigger a `mousedown` from a specific mouse button\n\n```\n// Main button pressed (usually the left button)cy.get('.target').trigger('mousedown', { button: 0 })// Auxiliary button pressed (usually the middle button)cy.get('.target').trigger('mousedown', { button: 1 })//Secondary button pressed (usually the right button)cy.get('.target').trigger('mousedown', { button: 2 })\n```\n\n#### jQuery UI Sortable\n\nTo simulate drag and drop using jQuery UI sortable requires `pageX` and `pageY` properties along with `which:1`.\n\n```\ncy.get('[data-cy=draggable]').trigger('mousedown', {  which: 1,  pageX: 600,  pageY: 100,})cy.get('[data-cy=draggable]').trigger('mousemove', {  which: 1,  pageX: 600,  pageY: 600,})cy.get('[data-cy=draggable]').trigger('mouseup')\n```\n\n#### Drag and Drop\n\n[Check out our example recipe triggering mouse and drag events to test drag and drop](/llm/markdown/app/references/recipes.md#Testing-the-DOM)\n",
      "section": "api",
      "anchors": [
        "mouse-events"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 197
    },
    {
      "id": "api/commands/trigger#trigger-a-mouseover-on-the-button",
      "doc_id": "api/commands/trigger",
      "heading": "Trigger a mouseover on the button",
      "heading_level": 4,
      "content_markdown": "#### Trigger a `mouseover` on the button\n\nThe DOM element must be in an \"interactable\" state prior to the triggered event happening (it must be visible and not disabled).\n\n```\ncy.get('button').trigger('mouseover') // yields 'button'\n```\n",
      "section": "api",
      "anchors": [
        "trigger-a-mouseover-on-the-button"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 47
    },
    {
      "id": "api/commands/trigger#trigger-a-mousedown-from-a-specific-mouse-button",
      "doc_id": "api/commands/trigger",
      "heading": "Trigger a mousedown from a specific mouse button",
      "heading_level": 4,
      "content_markdown": "#### Trigger a `mousedown` from a specific mouse button\n\n```\n// Main button pressed (usually the left button)cy.get('.target').trigger('mousedown', { button: 0 })// Auxiliary button pressed (usually the middle button)cy.get('.target').trigger('mousedown', { button: 1 })//Secondary button pressed (usually the right button)cy.get('.target').trigger('mousedown', { button: 2 })\n```\n",
      "section": "api",
      "anchors": [
        "trigger-a-mousedown-from-a-specific-mouse-button"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 59
    },
    {
      "id": "api/commands/trigger#jquery-ui-sortable",
      "doc_id": "api/commands/trigger",
      "heading": "jQuery UI Sortable",
      "heading_level": 4,
      "content_markdown": "#### jQuery UI Sortable\n\nTo simulate drag and drop using jQuery UI sortable requires `pageX` and `pageY` properties along with `which:1`.\n\n```\ncy.get('[data-cy=draggable]').trigger('mousedown', {  which: 1,  pageX: 600,  pageY: 100,})cy.get('[data-cy=draggable]').trigger('mousemove', {  which: 1,  pageX: 600,  pageY: 600,})cy.get('[data-cy=draggable]').trigger('mouseup')\n```\n",
      "section": "api",
      "anchors": [
        "jquery-ui-sortable"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 51
    },
    {
      "id": "api/commands/trigger#change-event",
      "doc_id": "api/commands/trigger",
      "heading": "Change Event",
      "heading_level": 3,
      "content_markdown": "### Change Event\n\n#### Interact with a range input (slider)\n\nTo interact with a range input (slider), we need to set its value and then trigger the appropriate event to signal it has changed.\n\nBelow we invoke jQuery's `val()` method to set the value, then trigger the `change` event.\n\nNote that some implementations may rely on the `input` event instead, which is fired as a user moves the slider, but is not supported by some browsers.\n\n```\ncy.get('input[type=range]').as('range').invoke('val', 25).trigger('change')cy.get('@range').siblings('p').should('have.text', '25')\n```\n",
      "section": "api",
      "anchors": [
        "change-event"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 108
    },
    {
      "id": "api/commands/trigger#interact-with-a-range-input-slider",
      "doc_id": "api/commands/trigger",
      "heading": "Interact with a range input (slider)",
      "heading_level": 4,
      "content_markdown": "#### Interact with a range input (slider)\n\nTo interact with a range input (slider), we need to set its value and then trigger the appropriate event to signal it has changed.\n\nBelow we invoke jQuery's `val()` method to set the value, then trigger the `change` event.\n\nNote that some implementations may rely on the `input` event instead, which is fired as a user moves the slider, but is not supported by some browsers.\n\n```\ncy.get('input[type=range]').as('range').invoke('val', 25).trigger('change')cy.get('@range').siblings('p').should('have.text', '25')\n```\n",
      "section": "api",
      "anchors": [
        "interact-with-a-range-input-slider"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 104
    },
    {
      "id": "api/commands/trigger#options",
      "doc_id": "api/commands/trigger",
      "heading": "Options",
      "heading_level": 3,
      "content_markdown": "### Options\n\n#### Specify that the event should not bubble\n\nBy default, the event will bubble up the DOM tree. This will prevent the event from bubbling.\n\n```\ncy.get('button').trigger('mouseover', { bubbles: false })\n```\n\n#### Specify the exact `clientX` and `clientY` the event should have\n\nThis overrides the default auto-positioning based on the element itself. Useful for events like `mousemove` where you need the position to be outside the element itself.\n\n```\ncy.get('button').trigger('mousemove', { clientX: 200, clientY: 300 })\n```\n",
      "section": "api",
      "anchors": [
        "options"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 107
    },
    {
      "id": "api/commands/trigger#specify-that-the-event-should-not-bubble",
      "doc_id": "api/commands/trigger",
      "heading": "Specify that the event should not bubble",
      "heading_level": 4,
      "content_markdown": "#### Specify that the event should not bubble\n\nBy default, the event will bubble up the DOM tree. This will prevent the event from bubbling.\n\n```\ncy.get('button').trigger('mouseover', { bubbles: false })\n```\n",
      "section": "api",
      "anchors": [
        "specify-that-the-event-should-not-bubble"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 43
    },
    {
      "id": "api/commands/trigger#specify-the-exact-clientx-and-clienty-the-event-should-have",
      "doc_id": "api/commands/trigger",
      "heading": "Specify the exact clientX and clientY the event should have",
      "heading_level": 4,
      "content_markdown": "#### Specify the exact `clientX` and `clientY` the event should have\n\nThis overrides the default auto-positioning based on the element itself. Useful for events like `mousemove` where you need the position to be outside the element itself.\n\n```\ncy.get('button').trigger('mousemove', { clientX: 200, clientY: 300 })\n```\n",
      "section": "api",
      "anchors": [
        "specify-the-exact-clientx-and-clienty-the-event-should-have"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 61
    },
    {
      "id": "api/commands/trigger#fire-other-event-types",
      "doc_id": "api/commands/trigger",
      "heading": "Fire other Event types.",
      "heading_level": 3,
      "content_markdown": "### Fire other Event types.\n\nBy default, `cy.trigger()` fires [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event). But you may want to trigger other events like `MouseEvent` or `KeyboardEvent`.\n\nIn that case, use the `eventConstructor` option.\n\n```\ncy.get('button').trigger('mouseover', { eventConstructor: 'MouseEvent' })\n```\n",
      "section": "api",
      "anchors": [
        "fire-other-event-types"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 48
    },
    {
      "id": "api/commands/trigger#notes",
      "doc_id": "api/commands/trigger",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### Actionability\n\n#### The element must first reach actionability\n\n`.trigger()` is an \"action command\" that follows all the rules of [Actionability](/llm/markdown/app/core-concepts/interacting-with-elements.md).\n\n### Events\n\n#### What event should I fire?\n\n`cy.trigger()` is meant to be a low-level utility that makes triggering events easier than manually constructing and dispatching them. Since any arbitrary event can be triggered, Cypress tries not to make any assumptions about how it should be triggered. This means you'll need to know the implementation details (which may be in a 3rd party library) of the event handler(s) receiving the event and provide the necessary properties.\n\n#### Why should I manually set the event type?\n\nAs you can see the documentation of [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent), most properties of event class instances are read-only. Because of that, it's sometimes impossible to set the value of some properties like `pageX`, `pageY`. This can be problematic in when testing some situations.\n\n### Differences\n\n#### What's the difference between triggering and event and calling the corresponding cypress command?\n\nIn other words, what's the difference between:\n\n```\ncy.get('button').trigger('focus')cy.get('button').focus()// ... or ...cy.get('button').trigger('click')cy.get('button').click()\n```\n\nBoth types commands will first verify element actionability, but only the \"true\" action commands will implement all of the default actions of the browser, and additionally perform low level actions to fulfill what's defined in the spec.\n\n`.trigger()` will _only_ fire the corresponding event and do nothing else.\n\nThat means that your event listener callbacks will be invoked, but don't expect the browser to actually \"do\" anything for these events. For the most part, it shouldn't matter, which is why `.trigger()` is an excellent stop-gap if the command / event you're looking for hasn't been implemented yet.\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 367
    },
    {
      "id": "api/commands/trigger#events",
      "doc_id": "api/commands/trigger",
      "heading": "Events",
      "heading_level": 3,
      "content_markdown": "### Events\n\n#### What event should I fire?\n\n`cy.trigger()` is meant to be a low-level utility that makes triggering events easier than manually constructing and dispatching them. Since any arbitrary event can be triggered, Cypress tries not to make any assumptions about how it should be triggered. This means you'll need to know the implementation details (which may be in a 3rd party library) of the event handler(s) receiving the event and provide the necessary properties.\n\n#### Why should I manually set the event type?\n\nAs you can see the documentation of [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent), most properties of event class instances are read-only. Because of that, it's sometimes impossible to set the value of some properties like `pageX`, `pageY`. This can be problematic in when testing some situations.\n",
      "section": "api",
      "anchors": [
        "events"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 168
    },
    {
      "id": "api/commands/trigger#what-event-should-i-fire",
      "doc_id": "api/commands/trigger",
      "heading": "What event should I fire?",
      "heading_level": 4,
      "content_markdown": "#### What event should I fire?\n\n`cy.trigger()` is meant to be a low-level utility that makes triggering events easier than manually constructing and dispatching them. Since any arbitrary event can be triggered, Cypress tries not to make any assumptions about how it should be triggered. This means you'll need to know the implementation details (which may be in a 3rd party library) of the event handler(s) receiving the event and provide the necessary properties.\n",
      "section": "api",
      "anchors": [
        "what-event-should-i-fire"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 99
    },
    {
      "id": "api/commands/trigger#why-should-i-manually-set-the-event-type",
      "doc_id": "api/commands/trigger",
      "heading": "Why should I manually set the event type?",
      "heading_level": 4,
      "content_markdown": "#### Why should I manually set the event type?\n\nAs you can see the documentation of [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent), most properties of event class instances are read-only. Because of that, it's sometimes impossible to set the value of some properties like `pageX`, `pageY`. This can be problematic in when testing some situations.\n",
      "section": "api",
      "anchors": [
        "why-should-i-manually-set-the-event-type"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 67
    },
    {
      "id": "api/commands/trigger#differences",
      "doc_id": "api/commands/trigger",
      "heading": "Differences",
      "heading_level": 3,
      "content_markdown": "### Differences\n\n#### What's the difference between triggering and event and calling the corresponding cypress command?\n\nIn other words, what's the difference between:\n\n```\ncy.get('button').trigger('focus')cy.get('button').focus()// ... or ...cy.get('button').trigger('click')cy.get('button').click()\n```\n\nBoth types commands will first verify element actionability, but only the \"true\" action commands will implement all of the default actions of the browser, and additionally perform low level actions to fulfill what's defined in the spec.\n\n`.trigger()` will _only_ fire the corresponding event and do nothing else.\n\nThat means that your event listener callbacks will be invoked, but don't expect the browser to actually \"do\" anything for these events. For the most part, it shouldn't matter, which is why `.trigger()` is an excellent stop-gap if the command / event you're looking for hasn't been implemented yet.\n",
      "section": "api",
      "anchors": [
        "differences"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 168
    },
    {
      "id": "api/commands/trigger#whats-the-difference-between-triggering-and-event-and-calling-the-corresponding-cypress-command",
      "doc_id": "api/commands/trigger",
      "heading": "What's the difference between triggering and event and calling the corresponding cypress command?",
      "heading_level": 4,
      "content_markdown": "#### What's the difference between triggering and event and calling the corresponding cypress command?\n\nIn other words, what's the difference between:\n\n```\ncy.get('button').trigger('focus')cy.get('button').focus()// ... or ...cy.get('button').trigger('click')cy.get('button').click()\n```\n\nBoth types commands will first verify element actionability, but only the \"true\" action commands will implement all of the default actions of the browser, and additionally perform low level actions to fulfill what's defined in the spec.\n\n`.trigger()` will _only_ fire the corresponding event and do nothing else.\n\nThat means that your event listener callbacks will be invoked, but don't expect the browser to actually \"do\" anything for these events. For the most part, it shouldn't matter, which is why `.trigger()` is an excellent stop-gap if the command / event you're looking for hasn't been implemented yet.\n",
      "section": "api",
      "anchors": [
        "whats-the-difference-between-triggering-and-event-and-calling-the-corresponding-cypress-command"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 165
    },
    {
      "id": "api/commands/trigger#rules",
      "doc_id": "api/commands/trigger",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)\n\n*   `.trigger()` requires being chained off a command that yields DOM element(s).\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `.trigger()` will automatically wait for the element to reach an [actionable state](/llm/markdown/app/core-concepts/interacting-with-elements.md).\n*   `.trigger()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed.\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `.trigger()` can time out waiting for the element to reach an [actionable state](/llm/markdown/app/core-concepts/interacting-with-elements.md).\n*   `.trigger()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 107
    },
    {
      "id": "api/commands/trigger#timeouts-learn-about-timeouts",
      "doc_id": "api/commands/trigger",
      "heading": "Timeouts Learn about timeouts",
      "heading_level": 3,
      "content_markdown": "### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `.trigger()` can time out waiting for the element to reach an [actionable state](/llm/markdown/app/core-concepts/interacting-with-elements.md).\n*   `.trigger()` can time out waiting for assertions you've added to pass.\n",
      "section": "api",
      "anchors": [
        "timeouts-learn-about-timeouts"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 41
    },
    {
      "id": "api/commands/trigger#command-log",
      "doc_id": "api/commands/trigger",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Trigger a `change` event on input type='range'_**\n\n```\ncy.get('.trigger-input-range').invoke('val', 25).trigger('change')\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on `trigger` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 49
    },
    {
      "id": "api/commands/trigger#history",
      "doc_id": "api/commands/trigger",
      "heading": "History",
      "heading_level": 2,
      "content_markdown": "## History\n\n| Version | Changes |\n| --- | --- |\n| [6.1.0](/llm/markdown/app/references/changelog.md#6-1-0) | Added option `scrollBehavior` |\n| [3.5.0](/llm/markdown/app/references/changelog.md#3-5-0) | Added `screenX` and `screenY` properties to events |\n| [0.20.0](/llm/markdown/app/references/changelog.md#0-20-0) | `.trigger()` command added |\n",
      "section": "api",
      "anchors": [
        "history"
      ],
      "path": "/llm/json/chunked/api/commands/trigger.json",
      "token_estimate": 49
    }
  ]
}