cold-cat-63632
02/27/2023, 7:01 PMdazzling-thailand-9844
02/27/2023, 9:18 PMexport const getMsgSubject = () => {
cy.get(elements.MSGS.MSGS_TABLE_CELL)
.first()
.invoke('text')
.as('custToEmpMessageSubject')
}
Then in the second file, you can import the function and use it to get the value of the alias:
import { getMsgSubject } from './file1'
it('Test Case', () => {
getMsgSubject()
cy.get('@custToEmpMessageSubject').then((text) => {
// Use the value of the alias here
})
})dazzling-thailand-9844
02/27/2023, 9:31 PMgetMsgSubject() {
cy.get(elements.MSGS.MSGS_TABLE_CELL)
.first()
.then(($element) => {
cy.window().its('messageSubject', $element.text())
})
}
In the second file:
it('Test Case', () => {
cy.window().then((win) => {
const messageSubject = win.messageSubject
// Use the value of the variable here
})
})dazzling-thailand-9844
02/27/2023, 9:38 PMwin.localStorage.getItem in the second. Or use Cypress.env() in the same way...cold-cat-63632
02/28/2023, 4:42 PM