Cypress img elements attribute checkingHow to check empty/undefined/null string in JavaScript?How do I check if an element is hidden in jQuery?How do I check if an array includes an object in JavaScript?Setting “checked” for a checkbox with jQuery?Checking if a key exists in a JavaScript object?How to check whether a string contains a substring in JavaScript?How to check for “undefined” in JavaScript?How to check if an object is an array?How do I remove a particular element from an array in JavaScript?jQuery scroll to element

How to be diplomatic in refusing to write code that breaches the privacy of our users

Unreliable Magic - Is it worth it?

Method to test if a number is a perfect power?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Is there a korbon needed for conversion?

Is there a problem with hiding "forgot password" until it's needed?

How can a function with a hole (removable discontinuity) equal a function with no hole?

Failed to fetch jessie backports repository

Is HostGator storing my password in plaintext?

Why are there no referendums in the US?

when is out of tune ok?

Short story about space worker geeks who zone out by 'listening' to radiation from stars

Sort a list by elements of another list

Why not increase contact surface when reentering the atmosphere?

Is oxalic acid dihydrate considered a primary acid standard in analytical chemistry?

Is this apparent Class Action settlement a spam message?

How to safely derail a train during transit?

Is `x >> pure y` equivalent to `liftM (const y) x`

Is expanding the research of a group into machine learning as a PhD student risky?

Crossing the line between justified force and brutality

Where does the Z80 processor start executing from?

How does buying out courses with grant money work?

Was Spock the First Vulcan in Starfleet?

Opposite of a diet



Cypress img elements attribute checking


How to check empty/undefined/null string in JavaScript?How do I check if an element is hidden in jQuery?How do I check if an array includes an object in JavaScript?Setting “checked” for a checkbox with jQuery?Checking if a key exists in a JavaScript object?How to check whether a string contains a substring in JavaScript?How to check for “undefined” in JavaScript?How to check if an object is an array?How do I remove a particular element from an array in JavaScript?jQuery scroll to element













1















I need to check if all images on my page have the Alt attribute. I thought doing the following would do that but it doesn't check things correctly and just gives me an everything is good when I know it's not.

cy.get('img').should('have.attr',
'alt' );



Is there an easy solution other than many go through the page and build a selector for every image?










share|improve this question


























    1















    I need to check if all images on my page have the Alt attribute. I thought doing the following would do that but it doesn't check things correctly and just gives me an everything is good when I know it's not.

    cy.get('img').should('have.attr',
    'alt' );



    Is there an easy solution other than many go through the page and build a selector for every image?










    share|improve this question
























      1












      1








      1








      I need to check if all images on my page have the Alt attribute. I thought doing the following would do that but it doesn't check things correctly and just gives me an everything is good when I know it's not.

      cy.get('img').should('have.attr',
      'alt' );



      Is there an easy solution other than many go through the page and build a selector for every image?










      share|improve this question














      I need to check if all images on my page have the Alt attribute. I thought doing the following would do that but it doesn't check things correctly and just gives me an everything is good when I know it's not.

      cy.get('img').should('have.attr',
      'alt' );



      Is there an easy solution other than many go through the page and build a selector for every image?







      javascript cypress






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 12:47









      nigelnigel

      538




      538






















          1 Answer
          1






          active

          oldest

          votes


















          4














          To check each element, you can use .each:



          cy.get('img').each($el => 
          cy.wrap($el).should('have.attr', 'alt')






          share|improve this answer























          • Thanks this works. I tried the same kinda thing before but used get instead of wrap

            – nigel
            Mar 7 at 13:33










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044172%2fcypress-img-elements-attribute-checking%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          To check each element, you can use .each:



          cy.get('img').each($el => 
          cy.wrap($el).should('have.attr', 'alt')






          share|improve this answer























          • Thanks this works. I tried the same kinda thing before but used get instead of wrap

            – nigel
            Mar 7 at 13:33















          4














          To check each element, you can use .each:



          cy.get('img').each($el => 
          cy.wrap($el).should('have.attr', 'alt')






          share|improve this answer























          • Thanks this works. I tried the same kinda thing before but used get instead of wrap

            – nigel
            Mar 7 at 13:33













          4












          4








          4







          To check each element, you can use .each:



          cy.get('img').each($el => 
          cy.wrap($el).should('have.attr', 'alt')






          share|improve this answer













          To check each element, you can use .each:



          cy.get('img').each($el => 
          cy.wrap($el).should('have.attr', 'alt')







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 13:10









          bkucerabkucera

          1,904520




          1,904520












          • Thanks this works. I tried the same kinda thing before but used get instead of wrap

            – nigel
            Mar 7 at 13:33

















          • Thanks this works. I tried the same kinda thing before but used get instead of wrap

            – nigel
            Mar 7 at 13:33
















          Thanks this works. I tried the same kinda thing before but used get instead of wrap

          – nigel
          Mar 7 at 13:33





          Thanks this works. I tried the same kinda thing before but used get instead of wrap

          – nigel
          Mar 7 at 13:33



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55044172%2fcypress-img-elements-attribute-checking%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved