I am using Cypress automation, at the moment I am testing/writing tests for Analytics. With Google Analytics I was easily able to write my tests using cy.intercept() function and was successfully able to assert Google Analytics. But... with Adobe Analtics the cy.intercept() function doesn't see Adobe Analytics. I been researching solutions with no luck, 1. there is very little info 2. their solutions suggest to use cy.interept(). Here is what I have so far:
The prior steps are to login the website and turn on Adobe Analytics. Then I am supposed to assert that Adobe Analytics are up and running. I am using this:
cy.intercept('POST', 'your_website', { statusCode: 200 }).as('adobe-analytics')
cy.wait(5000)
cy.log('**Step 6**')
cy.waitForStableDOM({timeout: 55000})
cy.wait(5000)
cy.wait('@adobe-analytics').get('@adobe-analytics')
.then((xhr) =>{
console.log("Adobe-Analytics Response:", xhr)
})
Solved! Go to Solution.
Views
Replies
Total Likes
THANK YOU!!! . What it was was the long website name I added in the cy.intercept()
example:
Views
Replies
Total Likes
This worked for me:
describe('detect Adobe Analytics request', () => {
it('visits a webpage', () => {
// specify the intercept first
cy.intercept(
'/b/ss/**',
).as('adobeAnalyticsRequest');
// then load the web page to be tested
cy.visit('https://www.website.com');
// then check for the AA request
cy.get('@adobeAnalyticsRequest').then((req) => {
console.log('adobeAnalyticsRequest', req);
});
});
});
Strangely, if I call cy.visit() before cy.intercept(), then the AA request does not get intercepted. But this also happens with other network requests, so it's not an AA-specific issue.
THANK YOU!!! . What it was was the long website name I added in the cy.intercept()
example:
Views
Replies
Total Likes
You're welcome!
But actually, I want to thank you too for "introducing" Cypress to me (although an introduction wasn't your post's intention). I had been looking for an automation tool that works like Selenium but better, and now thanks to your post, I've found it!