I want to test the amount of properties that get displayed in the left block of this link changing cities in the city name input. The properties all have an item with the class name .unit-address--show-name (you can do document.getElementsByClassName to make sure what items I am talking about). Good.
The first time the test is run, the selector.count works fine. However, when the test changes the city and waits, the selector seems to stop working, and no error message is shown for a long period of time. After a while I get a TyperError: Cannot read property '0' of null from the replicator package under node_modules. (sometimes it gets to the third, but most of the time it fails in the second one)
The test goes normally, and if in case the selector does not exist, make it explicit what the problem is.
//myTest.ts
fixture(`Consumer Portal`)
.page(`https://rentalbeast.com/apartments/for_rent/`)
.beforeEach(async t => {
await t.resizeWindow(1168, 750);
});
test.only('Test search by city', async t => {
const cities = ['Miami', 'Boston', 'Chicago'];
for (let j = 0; j < cities.length; j++) {
const city = cities[j];
await t
.click('.main-search-input--desktop') // selects the input
.pressKey('ctrl+a delete') // deletes whatever was there before
.typeText('.main-search-input--desktop', city) // types the new city
.wait(3000) // waits for three seconds
.click('.search-by-location--button') // clicks on the "search" button
.wait(6000); // waits 6 secs to get the properties
console.log('getting matches...'); //second time it gets only until here
const selector = Selector('.unit-address--show-name'); // The properties selectors.
const exists = await selector.exists;
console.log('exists', exists); // First time this is true, second time it doesn't get here
const count = await selector.count;
console.log('count', count);// Gets here only the first time
}
});
Your website URL (or attach your complete example):
So if you run this test you'll see this on the console.

As you can see, it never gets to the third (sometimes even to the second) cycle, and I don't understand what the error is about. I checked and the elements exist.
testcafe firefox myTest.tstestcafe firefox myTest.tsHi @madroneropaulo
Thank you for the detailed information. I've reproduced the problem.
I cannot reproduce the issue on the latest commit (https://github.com/DevExpress/testcafe/commit/437fbb4ce4a97425b4e6d74ccf8ed51546d526ec)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.
Most helpful comment
Hi @madroneropaulo
Thank you for the detailed information. I've reproduced the problem.