Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compare two aliases which derive value from two different contexts. #2907

Closed
Shailth opened this issue Dec 6, 2018 · 2 comments
Closed

compare two aliases which derive value from two different contexts. #2907

Shailth opened this issue Dec 6, 2018 · 2 comments

Comments

@Shailth
Copy link

Shailth commented Dec 6, 2018

I have a two containers inside a section.
Both hit different end points to derive some a values, post that they compare these values and decide either to render. (thats how the app works).
i have written a cypress test to cover the same, wherein i have two aliases calculating the two values:

.getByAutomationId('wipIssue')
.within(() => {
cy.get('section').within(() => {
      cy.getByAutomationId(‘balance’)
         .first()
         .invoke('text')
         .as(‘balance’);
});
     cy.getByAutomationId('lotCardGroup')
      .within(() => {
        cy.get('div').within(() => {
          cy.getByAutomationId('lot-CH10312823')
            .click()
            .find(‘sfb’)
           .invoke(‘text’)
            .as(‘sfbVal’);
        });
      });
});

//Assert a condition
if(@balance <= @sfbVal){
 // provide an outcome or reason
}

help me compare the two values ('balance' against 'sfbVal') to complete my cypress test.

@Shailth
Copy link
Author

Shailth commented Dec 6, 2018

the issue is while comparing the latter says undefined(@balance).

@jennifer-shehane
Copy link
Member

Ensure when comparing later that you are within a .then(() => {}) command so the values are defined when they are called.

In the future, we recommend questions relating to how to use Cypress be asked in our community chat. Issues in our GitHub repo are reserved for potential bugs or feature requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants