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

    gentle-mechanic-42608

    10/16/2022, 2:11 PM
    hi, I want to check if a specific element is selected. The site looks like
    Copy code
    html
    <tr class="MuiTableRow-root Mui-selected MuiTableRow-hover css-fbvnoc-MuiTableRow-root">
        <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-152hpza-MuiTableCell-root">
            <div class="MuiBox-root css-19h3qzz">
                <h6 class="MuiTypography-root MuiTypography-subtitle2 MuiTypography-alignCenter css-1n6et4w-MuiTypography-root">---</h6>
            </div>
            <div class="MuiBox-root css-d0uhtl">
                <h6 class="MuiTypography-root MuiTypography-subtitle2 css-1ngu4zh-MuiTypography-root"></h6>
                <p class="MuiTypography-root MuiTypography-body2 css-1xsg5cg-MuiTypography-root">Neue Position</p>
            </div>
        </td>
        <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignRight MuiTableCell-sizeMedium css-3v7b63-MuiTableCell-root"><span class="css-17a5c03">neu</span></td>
    </tr>
    <tr class="MuiTableRow-root MuiTableRow-hover css-fbvnoc-MuiTableRow-root">
        <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-sizeMedium css-152hpza-MuiTableCell-root">
            <div class="MuiBox-root css-19h3qzz">
                <h6 class="MuiTypography-root MuiTypography-subtitle2 MuiTypography-alignCenter css-1n6et4w-MuiTypography-root">---</h6>
            </div>
            <div class="MuiBox-root css-d0uhtl">
                <h6 class="MuiTypography-root MuiTypography-subtitle2 css-1ngu4zh-MuiTypography-root">Test</h6>
                <p class="MuiTypography-root MuiTypography-body2 css-1xsg5cg-MuiTypography-root">Cooler Kunde</p>
            </div>
        </td>
        <td class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignRight MuiTableCell-sizeMedium css-3v7b63-MuiTableCell-root"><span class="css-17a5c03">neu</span></td>
    </tr>
  • g

    gentle-mechanic-42608

    10/16/2022, 2:11 PM
    I want to wait until the correct row is selected. For this I have the following test line
    Copy code
    typescript
            cy.waitUntil(() => {
                return cy
                    .get('tr')
                    .should('have.class', 'Mui-selected')
                    .within(() => {
                        return cy.get('p:contains("Cooler Kunde")');
                    });
            });
    But this doesn't wait. Do you know why? Is there something wrong with the should(have.class) ?
  • g

    gentle-mechanic-42608

    10/16/2022, 3:04 PM
    I have a problem with cypress and an react re render. I have a table where one row is selected (class: Mui-selected and MuiTableRow-root) . Here I want to check if there is a tag in its children, which contains the correct value. Initially the value is "Cooler Kunde". But after an animation it is "Neue Position". I'm using:
    Copy code
    ts
            cy.get('.Mui-selected.MuiTableRow-root')
                .children()
                .find('p')
                .should('have.text', 'Cooler Kunde'); // this works
            // doing some stuff which causes the new selected line
            cy.get('.Mui-selected.MuiTableRow-root')
                .children()
                .find('p')
                .should('have.text', 'Neue Position'); // this fails
    But I receive the error
    Copy code
    bash
    Timed out retrying after 4000ms: expected '<p.MuiTypography-root.MuiTypography-body2.css-1xsg5cg-MuiTypography-root>' to have text 'Cooler Kunde', but the text was 'Neue Position'
    But I can fix this issue by a wait. But I don't like to use a wait, which always delays my tests:
    Copy code
    ts
            cy.get('.Mui-selected.MuiTableRow-root')
                .children()
                .find('p')
                .should('have.text', 'Cooler Kunde');
            cy.wait(1000);
            cy.get('.Mui-selected.MuiTableRow-root')
                .children()
                .find('p')
                .should('have.text', 'Neue Position');
  • m

    mysterious-belgium-25713

    10/16/2022, 3:38 PM
    So instead of the cypress hard wait. Do you know that a network request is triggering the change of text. If so then you can just wait for the network request instead of adding a 1 second wait.
  • g

    gentle-mechanic-42608

    10/16/2022, 4:04 PM
    Nope. Its a useEffect() on a react state.
  • g

    gentle-mechanic-42608

    10/16/2022, 4:04 PM
    The network call would be executed before the ui will be updated
  • i

    important-lawyer-45208

    10/16/2022, 9:13 PM
    just bumping this for the last time...
  • m

    mysterious-belgium-25713

    10/16/2022, 9:42 PM
    And if you do your selector different and also changing the default timeout for this occasion.
    Copy code
    js
    cy.contains('p','Neue Position',{timeout:5000}).should('have.text','Neue Position')
  • h

    happy-megabyte-98400

    10/17/2022, 2:45 AM
    Is it possible to alias a text within the
    it
    block and access it after a few lines using
    this
    keyword? I tried this and failed. So, let me know if there's a correct way of doing this.
  • f

    fresh-doctor-14925

    10/17/2022, 8:15 AM
    Remember to be mindful of the context where you invoke
    this
    . Within an arrow function,
    this
    will refer to whatever is in the arrow function. However within
    function()
    ,
    this
    refers to the entire spec So this will work:
    Copy code
    cy.wrap('text')
      .as('alias')
      .then(function() {
         const cyAlias = this.alias;
      })
    But this will not:
    Copy code
    cy.wrap('text')
      .as('alias')
      .then(() => {
         const cyAlias = this.alias;
      })
    It's a subtle distinction that often caught me out
  • b

    better-engineer-26463

    10/17/2022, 8:38 AM
    HI all Been having a great time with Cypress up until this morning where it is just constantly loading on test runner .. I have uninstalled and reinstalled Cypress too. Not sure what it could be as the project stayed the same.. any tips on how to get to the root cause ?
  • f

    fresh-doctor-14925

    10/17/2022, 8:51 AM
    You don't happen to have two instances of cypress open, do you? If that happens with me, I go on a Cypress killing spree in the task manager
  • s

    swift-terabyte-73667

    10/17/2022, 9:44 AM
    I need to get the class that contains".rbc-date-cell" but not ".rbc-off-range"
  • s

    swift-terabyte-73667

    10/17/2022, 9:45 AM
    If any one can help me.
  • a

    acceptable-hamburger-48790

    10/17/2022, 9:46 AM
    Are you looking for this https://docs.cypress.io/api/commands/not
  • s

    swift-terabyte-73667

    10/17/2022, 9:46 AM
    Yes. Thanks @acceptable-hamburger-48790
  • m

    mysterious-motherboard-13344

    10/17/2022, 9:57 AM
    Hi all.. I have recently upgraded to 10.9.0 from 10.3.0 and set
    experimentalWebKitSupport: true
    But when I open cypress it is unable to connect to firefox
  • s

    swift-terabyte-73667

    10/17/2022, 10:06 AM
    But it didn't solve my problem @acceptable-hamburger-48790 . Can you please help me with the implementation from above image ??
  • g

    gray-kilobyte-89541

    10/17/2022, 10:38 AM
    https://glebbahmutov.com/cypress-examples/9.7.0/commands/querying.html#find-elements-without-a-given-class
  • s

    swift-terabyte-73667

    10/17/2022, 10:40 AM
    Thanks for sharing.
  • h

    happy-megabyte-98400

    10/17/2022, 11:16 AM
    Remember to be mindful of the context
  • n

    nutritious-zoo-35798

    10/17/2022, 12:32 PM
    Hi there, Every time i run cypress and the automated test kicks in on the browser after a while and midway through the test a facebook page of the company i am testing is kicked in!!! there isnt any code to lin the test to that page. how do i get rid of this page? so far i manually close it but isnt good enough for me
  • f

    fresh-doctor-14925

    10/17/2022, 12:58 PM
    There must be something in your app causing this, or an action in the spec that is inadvertently triggering this popup.
  • n

    nutritious-zoo-35798

    10/17/2022, 1:01 PM
    ok i will have a look. thank you.
  • f

    fresh-doctor-14925

    10/17/2022, 1:02 PM
    What I'd do is to comment out each command until you find the action that's triggering this
  • a

    acceptable-apple-19490

    10/17/2022, 1:08 PM
    i am having issues with the password reset process. I have requested the reset several times but not received the email. I have checked junk, spam, etc but still no email. please advise, thank you
  • f

    fresh-doctor-14925

    10/17/2022, 1:10 PM
    If it's the dashboard you're referring to, try emailing support@cypress.io
  • a

    acceptable-apple-19490

    10/17/2022, 1:10 PM
    yes, it is the dashboard. thank you
  • a

    acceptable-apple-19490

    10/17/2022, 1:10 PM
    will do
  • b

    better-engineer-26463

    10/17/2022, 1:51 PM
    HI @fresh-doctor-14925 Thanks for the response - it doesn't look like it no.. But I do see the CPU running at 100%..
1...177178179...252Latest