I'm working with cypress version 12 doing a simple test that I grab a tab and click on it. I'm getting the same error over and over again. My first thought was that this happens because the element is not fully loaded yet so I have to wait for the page to load completely. But even though I have tried a timeout or a wait for the cy.get() the error is still there.
Any hints?
HomePage.js
export default class HomePage {
static open() {
cy.visit('https://phptravels.net/');
}
static productsSearchBar() {
return cy.get('button[data-bs-target="#tab-flights"]', {
timeout: 50000,
});
}
}
test.cy.js
import HomePage from '../page-objects/pages/HomePage';
describe('Regression Test', () => {
beforeEach(() => {
// Before each test, visit the homepage and wait for the page to load
HomePage.open();
});
it('should search for a product', () => {
HomePage.flightButton();
});
});
This is the element I'm trying to catch with the attribute that I selected for that:
The error I'm getting:



If you open up the dev-tools, go to console you will see the error message reproduced there.
The message contains a link to the spot that causes the error. If you click the link, the dev-tools will switch to the elements pane and show you the script that is failing:
If you then press ctrl-f to search for the id
multi-tripthere is only one reference to that string, and it occurs in the above script, which means there is no such element.Compare to searching for
round-trip, it will find the element with that id.It seems logical that
multi-tripoption would be next toround-tripoption in the above block, but maybe it is a feature that's not yet implemented.If so, you can ignore the error by using this at the top of the test:
or if it's a regression that you need to catch, add this after the
cy.visit()call