gentle-mechanic-42608
10/16/2022, 2:11 PMhtml
<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>
gentle-mechanic-42608
10/16/2022, 2:11 PMtypescript
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) ?gentle-mechanic-42608
10/16/2022, 3:04 PMts
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
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:
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');
mysterious-belgium-25713
10/16/2022, 3:38 PMgentle-mechanic-42608
10/16/2022, 4:04 PMgentle-mechanic-42608
10/16/2022, 4:04 PMimportant-lawyer-45208
10/16/2022, 9:13 PMmysterious-belgium-25713
10/16/2022, 9:42 PMjs
cy.contains('p','Neue Position',{timeout:5000}).should('have.text','Neue Position')
happy-megabyte-98400
10/17/2022, 2:45 AMit
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.fresh-doctor-14925
10/17/2022, 8:15 AMthis
. 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:
cy.wrap('text')
.as('alias')
.then(function() {
const cyAlias = this.alias;
})
But this will not:
cy.wrap('text')
.as('alias')
.then(() => {
const cyAlias = this.alias;
})
It's a subtle distinction that often caught me outbetter-engineer-26463
10/17/2022, 8:38 AMfresh-doctor-14925
10/17/2022, 8:51 AMswift-terabyte-73667
10/17/2022, 9:44 AMswift-terabyte-73667
10/17/2022, 9:45 AMacceptable-hamburger-48790
10/17/2022, 9:46 AMswift-terabyte-73667
10/17/2022, 9:46 AMmysterious-motherboard-13344
10/17/2022, 9:57 AMexperimentalWebKitSupport: true
But when I open cypress it is unable to connect to firefoxswift-terabyte-73667
10/17/2022, 10:06 AMgray-kilobyte-89541
10/17/2022, 10:38 AMswift-terabyte-73667
10/17/2022, 10:40 AMhappy-megabyte-98400
10/17/2022, 11:16 AMnutritious-zoo-35798
10/17/2022, 12:32 PMfresh-doctor-14925
10/17/2022, 12:58 PMnutritious-zoo-35798
10/17/2022, 1:01 PMfresh-doctor-14925
10/17/2022, 1:02 PMacceptable-apple-19490
10/17/2022, 1:08 PMfresh-doctor-14925
10/17/2022, 1:10 PMacceptable-apple-19490
10/17/2022, 1:10 PMacceptable-apple-19490
10/17/2022, 1:10 PMbetter-engineer-26463
10/17/2022, 1:51 PM