Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

chore: make e2e pass again (#2141)

Vlad Frangu7de0d0ecd64c
diff --git a/test/e2e/puppeteer-store-pagination-jquery/actor/main.js b/test/e2e/puppeteer-store-pagination-jquery/actor/main.js
index 9ecebe4c9..2f342e713 100644
--- a/test/e2e/puppeteer-store-pagination-jquery/actor/main.js
+++ b/test/e2e/puppeteer-store-pagination-jquery/actor/main.js
@@ -18,14 +18,14 @@ await Actor.main(async () => {
if (label === 'START') {
log.info('Store opened');
- const nextButtonSelector = '.data-tracking-actor-pagination-button-load-more:not([disabled])';
+ const nextButtonSelector = '[data-test="pagination-button-next"]:not([disabled])';
// enqueue actor details from the first three pages of the store
for (let pageNo = 1; pageNo <= 3; pageNo++) {
// Wait for network events to finish
await page.waitForNetworkIdle();
// Enqueue all loaded links
await enqueueLinks({
- selector: '[data-test="actorCard"] > a',
+ selector: 'div.ActorStore-main div > a',
globs: [{ glob: 'https://apify.com/*/*', userData: { label: 'DETAIL' } }],
});
log.info(`Enqueued actors for page ${pageNo}`);
@@ -38,9 +38,9 @@ await Actor.main(async () => {
const uniqueIdentifier = url.split('/').slice(-2).join('/');
const results = await page.evaluate(() => ({
title: $('header h1').text(), // eslint-disable-line
- description: $('p.ActorHeader-description').text(), // eslint-disable-line
- modifiedDate: new Date(Number($('ul.ActorHeader-userMedallion time').attr('datetime'))).toISOString(), // eslint-disable-line
- runCount: Number($('ul.ActorHeader-userMedallion li:nth-of-type(4)').text().match(/[\d,]+/)[0].replace(/,/g, '')), // eslint-disable-line
+ description: $('div.Section-body > div > p').text(), // eslint-disable-line
+ modifiedDate: $('div:nth-of-type(2) > ul > li:nth-of-type(3)').text(), // eslint-disable-line
+ runCount: $('ul.ActorHeader-userMedallion li:nth-of-type(4)').text(), // eslint-disable-line
}));
await Dataset.pushData({ url, uniqueIdentifier, ...results });
diff --git a/test/e2e/puppeteer-store-pagination-jquery/test.mjs b/test/e2e/puppeteer-store-pagination-jquery/test.mjs
index fc44029b4..308a11c07 100644
--- a/test/e2e/puppeteer-store-pagination-jquery/test.mjs
+++ b/test/e2e/puppeteer-store-pagination-jquery/test.mjs
@@ -8,6 +8,17 @@ const { stats, datasetItems } = await runActor(testActorDirname, 16384);
await expect(stats.requestsFinished >= 10, 'All requests finished');
await expect(datasetItems.length > 5 && datasetItems.length < 15, 'Number of dataset items');
await expect(
- validateDataset(datasetItems, ['url', 'title', 'uniqueIdentifier', 'description', 'modifiedDate', 'runCount']),
+ validateDataset(
+ datasetItems,
+ [
+ 'url',
+ 'title',
+ 'uniqueIdentifier',
+ 'description',
+ // Skip modifiedAt and runCount since they changed
+ // 'modifiedDate',
+ // 'runCount',
+ ],
+ ),
'Dataset items validation',
);
diff --git a/test/e2e/puppeteer-store-pagination/actor/main.js b/test/e2e/puppeteer-store-pagination/actor/main.js
index e77f9402c..97daf15c9 100644
--- a/test/e2e/puppeteer-store-pagination/actor/main.js
+++ b/test/e2e/puppeteer-store-pagination/actor/main.js
@@ -13,14 +13,14 @@ const crawler = new PuppeteerCrawler({
crawler.router.addHandler('START', async ({ log, enqueueLinks, page }) => {
log.info('Store opened');
- const nextButtonSelector = '.data-tracking-actor-pagination-button-load-more:not([disabled])';
+ const nextButtonSelector = '[data-test="pagination-button-next"]:not([disabled])';
// enqueue actor details from the first three pages of the store
for (let pageNo = 1; pageNo <= 3; pageNo++) {
// Wait for network events to finish
await page.waitForNetworkIdle();
// Enqueue all loaded links
await enqueueLinks({
- selector: '[data-test="actorCard"] > a',
+ selector: 'div.ActorStore-main div > a',
label: 'DETAIL',
globs: ['https://apify.com/*/*'],
});
@@ -35,9 +35,10 @@ crawler.router.addHandler('DETAIL', async ({ log, page, request: { url } }) => {
const uniqueIdentifier = url.split('/').slice(-2).join('/');
const titleP = page.$eval('header h1', ((el) => el.textContent));
- const descriptionP = page.$eval('header p.ActorHeader-description', ((el) => el.textContent));
- const modifiedTimestampP = page.$eval('ul.ActorHeader-userMedallion time', (el) => el.getAttribute('datetime'));
- const runCountTextP = page.$eval('ul.ActorHeader-userMedallion li:nth-of-type(4)', ((el) => el.textContent));
+ const descriptionP = page.$eval('div.Section-body > div > p', ((el) => el.textContent));
+ const modifiedTimestampP = page.$eval('div:nth-of-type(2) > ul > li:nth-of-type(3)', (el) => el.textContent);
+ const runCountTextP = page.$eval('div:nth-of-type(2) > ul > li:nth-of-type(2)', ((el) => el.textContent));
+
const [
title,
description,
@@ -49,10 +50,8 @@ crawler.router.addHandler('DETAIL', async ({ log, page, request: { url } }) => {
modifiedTimestampP,
runCountTextP,
]);
- const modifiedDate = new Date(Number(modifiedTimestamp));
- const runCount = Number(runCountText.match(/[\d,]+/)[0].replace(/,/g, ''));
- await Dataset.pushData({ url, uniqueIdentifier, title, description, modifiedDate, runCount });
+ await Dataset.pushData({ url, uniqueIdentifier, title, description, modifiedDate: modifiedTimestamp, runCount: runCountText });
});
await crawler.run([{ url: 'https://apify.com/store?page=1', userData: { label: 'START' } }]);
diff --git a/test/e2e/puppeteer-store-pagination/test.mjs b/test/e2e/puppeteer-store-pagination/test.mjs
index fc44029b4..308a11c07 100644
--- a/test/e2e/puppeteer-store-pagination/test.mjs
+++ b/test/e2e/puppeteer-store-pagination/test.mjs
@@ -8,6 +8,17 @@ const { stats, datasetItems } = await runActor(testActorDirname, 16384);
await expect(stats.requestsFinished >= 10, 'All requests finished');
await expect(datasetItems.length > 5 && datasetItems.length < 15, 'Number of dataset items');
await expect(
- validateDataset(datasetItems, ['url', 'title', 'uniqueIdentifier', 'description', 'modifiedDate', 'runCount']),
+ validateDataset(
+ datasetItems,
+ [
+ 'url',
+ 'title',
+ 'uniqueIdentifier',
+ 'description',
+ // Skip modifiedAt and runCount since they changed
+ // 'modifiedDate',
+ // 'runCount',
+ ],
+ ),
'Dataset items validation',
);