Using cy.get().click() not working on html button
See original GitHub issueCurrent behavior:
I started from scratch by creating an html page with a button.
When I want to click on my button using the script cy.get("...").click()
on my button. No action is taken and I receive the following error:
CypressError: Timed out retrying: this.ol_originalAddEventListener is not a function
I tried passing an xpath using the xpath plugin and I still have the same error.
Desired behavior:
Using the script cy.get("...").click()
on my button must be work.
Steps to reproduce: (app code and test code)
Step 1: Create a project from scratch, following this project:
Here is my project :
Here is the “buttons.html” source code:
<!DOCTYPE html>
<html>
<head>
<title>Titre du document</title>
</head>
<body>
<button id="test" onclick="window.location.href = 'https://fr.w3docs.com/';">Cliquez Ici</button>
</body>
</html>
The goal being to click on my button, I created a very simple test that allows me to click on this button. This is my source code:
/// <reference types="Cypress" />
context('Actions', () => {
beforeEach(() => {
cy.visit('./buttons.html')
})
it('test button html', () => {
cy.get('#test').click();
})
})
Despite this, I still have the same mistake below:
This is the log console:
Here is my package.json :
{
"name": "testing-error",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"cypress": "^3.7.0"
}
}
I use Chromium only to run my test.
The following files: the cypress.json
, cypress/support
directory and cypress/plugins
directory are “empty” by default when installing cypress.
No CSS or others references my error function.
Versions
Cypress : 3.7.0 Chromium : 74.0.3729 OS : MacOS IDE : VSCode
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
I finally figured out that my issue was related to the OneLogin Chrome extension. If I disable browser extensions when running with Chrome, it fixes the issue.
In
cypress/plugins/index.js
:I believe Cypress should disable Chrome extensions by default, but honestly find the issue template for this repo very cumbersome, so I’m just leaving this here.
@edsrzf Oof, thanks for the update.
Some people test their browser extensions in Cypress, so disabling them outright would not be the right approach unfortunately. Although, we may be able to detect in Cypress 4.0 if you are modifying the
launchOptions.extensions
and remove the--disable-extensions
flag in this case.This still leaves the cases where some people use extensions for development purposes though. So, they want the extensions in Chrome to work that help them in their devtools etc.