I need to compare if two different elements contain the same text. Case: I have 5 different buttons time periods lets assume they are "Day, Week, Month, Year, Decade" Every time when I click on some particular button I want to compare if the value in the second element on the chart below is changed as well and is the same.
My code is:
isAgregationBarChoosenValuePresent() {
const selectors = ['button[data-testid="period-button-DAY"]',
'button[data-testid="period-button-WEEK"]',
'button[data-testid="period-button-MONTH"]',
'button[data-testid="period-button-YEAR"]',
'button[data-testid="period-button-DECADE"]']
selectors.forEach(($selector) => {
cy.get($selector, { timeout: 10000 }).eq(0).click().then($assertion => {
const assertionText = $assertion.text()
return assertionText === cy.get('Second element).text()
})
I assume that I can't use cy.get('Second element).text(). I tried to used another then and create a const with secondElement.text() this is not working as well.
If you have any ideas, let me know.
Thanks