Checking CSS of images with dynamic environments

In order to do this, we have to make a call-back to the constants.json within the scenario itself. This will not work if that’s done in the beforeEach().

  const constants = getConstants();
  const baseURL = constants.baseURL;
    cy.get('[class="banner"]')
      .eq(0)
      .within(() => {
        cy.get('[class="banner-background"]').should(
          'have.css',
          'background', 
          'rgba(0, 0, 0, 0)' + ' ' + 
          'url("' + 
          `${baseURL}` + '/static/media/horse-in-stall.0cb74904.jpeg")'
          + ' ' 
          + 'no-repeat scroll 50% 50% / 100% padding-box border-box'
        );
Previous
Previous

Selecting elements using if, else

Next
Next

Comparing two text values, stripping out text and saving