https://cypress.io logo
Join Discord
Powered by
# help
  • g

    gentle-accountant-4760

    06/16/2022, 12:12 PM
    Apprecaite it! will look at it now
  • g

    gentle-accountant-4760

    06/16/2022, 12:18 PM
    I couldnt find an example of doing something like:
    Copy code
    ts
    cy
      .get('.selenium-custom-test')
      .contains('custom')
      .then((initial) => {
        initial.get('.selenium-value').invoke('text')
      });
  • h

    happy-rose-36850

    06/16/2022, 12:23 PM
    out of shear interest, recordings made in a ci test, can they be exported to cloud storage?
  • n

    nutritious-honey-65632

    06/16/2022, 12:45 PM
    wow, tnx, you are the best. I think I tried something similar but unsuccessfully. I will try once more
  • g

    gentle-accountant-4760

    06/16/2022, 12:48 PM
    I need any suggestions on what I need to do to be able to get the numbers from this HTML:
    Copy code
    html
    <section class="selenium-Worktop">
       <div class="selenium-worktop-header">
          <div><span class="h3 selenium-section-title">Worktop</span></div>
       </div>
       <div class="selenium--content">
          <div class="selenium-section-info">
             <div class="selenium-section-wrapper">
                <section class="selenium-item-component-12345">
                   <div class="itemList-item-firstBlock">
                      <div class="selenium-article-data">
                         <div class="selenium-item-info"><span class="selenium-item-name lead-paragraph">THRILL</span> <span class="selenium-item-desc ">custom walnut</span></div>
                      </div>
                   </div>
                   <div class="itemList-item-columns">
                      <div class="itemList-number">903.475.58</div>
                   </div>
             </div>
             </section>
             <section class="selenium-item-component-67890">
                <div class="itemList-item-firstBlock">
                   <div class="selenium-article-data">
                      <div class="selenium-item-info"><span class="selenium-item-name lead-paragraph">THRILLOFIT</span> <span class="selenium-item-desc ">custom orange</span></div>
                   </div>
                </div>
                <
                <div class="itemList-item-columns">
                   <div class="itemList-number">134.124.31</div>
                </div>
          </div>
          </section>
       </div>
       </div>
       </div>
    </section>
    What I need to do first is to check if
    selenium-item-desc
    contains the word custom and if it does, then I want the
    itemList-number
    text - any suggestions on what I sohuld do to be able to do it?``ยด
  • g

    gray-kilobyte-89541

    06/16/2022, 12:55 PM
    well, the "initial" argument you get from Cypress querying commands is a jQuery object, so you get its value right away synchronously
  • g

    gray-kilobyte-89541

    06/16/2022, 12:56 PM
    conditional testing, you can get the parent element, which yields the jQuery, then check its text, then get the number if
    custom
    is present
  • g

    gentle-accountant-4760

    06/16/2022, 12:57 PM
    So which way should I start by? do I want to use sort of loop to check first for each section? basically each item-compnent first?
  • g

    gentle-accountant-4760

    06/16/2022, 12:58 PM
    e.g. something like cy.get(.item-compnent).each((.....) ?
  • g

    gray-kilobyte-89541

    06/16/2022, 12:59 PM
    sure
  • g

    gentle-accountant-4760

    06/16/2022, 1:01 PM
    and then whats the next step? e.g. something like
    Copy code
    cy.get(.item-compnent).each((
        cy.get(item-name).contains('custom').then(($found) => (
          cy.get(itemList-Number)
       )
    )
  • g

    gentle-accountant-4760

    06/16/2022, 1:01 PM
    something like that way? or can I somehow use the .find instead perhaps?
  • g

    gray-kilobyte-89541

    06/16/2022, 1:57 PM
    ๐Ÿ™‚ look up
    cy.each
    syntax (it takes a callback) and find its examples using https://cypress.tips/search You can probably even find all elements with custom right away using
    :has
    and
    :contains
    selectors, see https://glebbahmutov.com/cypress-examples/9.7.0/recipes/find-elements-with-subelements.html
  • g

    gentle-accountant-4760

    06/16/2022, 2:14 PM
    I think I managed to do it by doing something like:
    Copy code
    ts
          cy.get('.selenium-Worktop:has(.selenium-item-desc:contains("custom"))').each((art) => {
            art.find('.itemList-number');
            cy.log('in here');
          });
    but it looks like the
    art.find('.itemList-number');
    is just being skipped in my tests for some reason which is odd, however it does print out "cy.log('in here')" - weird...
  • g

    gentle-accountant-4760

    06/16/2022, 2:15 PM
    I believe I am able to do the art.find or perhaps I need to do art.get?
  • n

    nutritious-honey-65632

    06/16/2022, 2:21 PM
    this works, tnx, I was targeting wrong div
  • q

    quaint-elephant-51746

    06/16/2022, 2:22 PM
    Can anyone please help. I want to automate E Commerce website but stuck in Payment through Credit Card #763105090679865354 . There is a single iframe in which there is credit card number, expiry date and CVV
  • n

    nutritious-honey-65632

    06/16/2022, 2:31 PM
    you could log
    art
    element and see is
    .itemList-number
    is descendant of art. art.find() should works fine, this is a jquery find() but cy.get(el).find() should work exactly the same
  • g

    gentle-accountant-4760

    06/16/2022, 2:32 PM
    but am I doing wrong query for .find perhaps? not sure if you can use css selectors in find?
  • g

    gentle-accountant-4760

    06/16/2022, 2:33 PM
    I do believe the problem is that when I do the first query regarding the
    cy.get('.selenium-Worktop:has(.selenium-item-desc:contains("custom"))').each((art) => {
    - I believe this goes into selenium-item-desc which means its in the wrong "section" in the html, and I believe I need to go back a few levels to reach the itemList
  • n

    nutritious-honey-65632

    06/16/2022, 2:35 PM
    it could be the case, if you want do console.log(art) and see how html looks like. If you are not sure feel free to paste me in DM
  • g

    gentle-accountant-4760

    06/16/2022, 2:35 PM
    Will give it a try first ๐Ÿ˜„
  • g

    gray-kilobyte-89541

    06/16/2022, 2:37 PM
    art
    is a jQuery object, so
    art.find(...)
    synchronously gives you the number element. You want to get its text
    .text()
    then convert it to a number and maybe call
    cy.log('number', x)
    to see it
  • g

    gentle-accountant-4760

    06/16/2022, 2:41 PM
    Apprecaite it, I think im kidna overcomplicating stuff at this moment and it should be easier than I think
  • m

    melodic-hydrogen-41542

    06/16/2022, 3:25 PM
    Does anyone have any suggestions for debugging spec files that take an extremely long time (up to 2 minutes!) to load/compile and often lock up my machine during initial loading? I think the root cause is too many JS imports AND/OR a suspicious helper class that's full of interdependent functions and re-used variable names. Spec files with fewer imports (that also happen to not import the suspicious helper class) load very quickly and don't cause machine lockups. If it helps, sometimes these slow-compiling spec fails fail quickly with a maximum call stack size exceeded error (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Too_much_recursion) .
    • 1
    • 3
  • i

    icy-camera-47315

    06/16/2022, 3:36 PM
    I am practicing cypress 10 version and i dont know what to put into cypress.config.ts file as i am getting an error stating that this file is empty
  • s

    swift-kitchen-62493

    06/16/2022, 3:39 PM
    Hi, i have a problem: when I try to run 'npx cypress open' cypress window pop up for 0.1 sec and then closing, i have only this in terminal, any idea what i can do?
  • p

    proud-breakfast-29892

    06/16/2022, 3:46 PM
    Hello. I have a spec file with two contexts, each context has its own
    beforeEach
    . Outside of the contexts, there is a global
    beforeEach
    as well, as follows:
    Copy code
    js
        beforeEach(() => {
                cy.log('Setup');
    
                // Sets up my application...
            });
    
    
        context('First Context', () => {
            beforeEach(() => {
                // Do specific setups for this context...            
    
                cy.visit('MyUrl');
            });
            
            it('My test', () => {
                // My test occours here
            });
    
            it('Another test', () => {
                // Another test occours here..
            });
        });
    
        context('Second Context', () => {
            beforeEach(() => {
                // Do specific setups for this context...            
    
                cy.visit('MyUrl');
            });
            
            it('My Second test', () => {
                // My test occours here
            });
        });
    If a test in the first context passes, Cypress will go to the next context without issue. However, if the test in the first context FAILS, Cypress will not run the tests in the second context, and it will show the message "No commands were issued in this test." I have no idea what's the cause for this issue, I'm clueless. I'm using version 9.6.1
  • m

    melodic-hydrogen-41542

    06/16/2022, 3:48 PM
    You can find a few solutions to this issue here: https://stackoverflow.com/questions/72401421/npm-warn-config-global-global-local-are-deprecated-use-location-glo Basically you can manually edit a few config files as per the answers at the above link, or you could try upgrading or reinstalling Node/npm.
  • s

    swift-kitchen-62493

    06/16/2022, 3:49 PM
    okey now i don't have this error but still cypress window pop up for 0.1 sec and then closing
1...878889...252Latest