Skip to content

Commit 0b1e993

Browse files
committed
Update package version to 1.0.7, add reload action to step executor, and modify basic usage example to include reload functionality. Adjusted action types in types.ts to accommodate new reload action.
1 parent 7e3199d commit 0b1e993

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

examples/basic-usage.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ async function basicExample() {
2424
key: 'title',
2525
data_type: 'text'
2626
},
27+
{
28+
id: "reload",
29+
action: 'reload',
30+
value: 'load',
31+
wait: 2000
32+
},
2733
{
2834
id: 'get_description',
2935
action: 'data',
@@ -40,7 +46,7 @@ async function basicExample() {
4046
console.log('🚀 Starting scraper...');
4147
const results = await runScraper(templates, {
4248
browser: {
43-
headless: true,
49+
headless: false,
4450
args: [
4551
'--no-sandbox',
4652
'--disable-setuid-sandbox',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "stepwright",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "A powerful web scraping library built with Playwright",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/step-executor.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,19 @@ export async function executeStep(
394394
await page.evaluate((y: number) => window.scrollBy(0, y), offset);
395395
break;
396396
}
397+
case 'reload': {
398+
// Reload the current page
399+
try {
400+
const waitUntil = (step.value as 'load' | 'domcontentloaded' | 'networkidle' | 'commit') || 'networkidle';
401+
const timeout = step.wait ?? 30000;
402+
await page.reload({ waitUntil, timeout });
403+
console.log(` 🔄 Page reloaded (waitUntil: ${waitUntil})`);
404+
} catch (err: any) {
405+
console.log(` ⚠️ Reload failed: ${err.message}`);
406+
// Don't throw error, just continue
407+
}
408+
break;
409+
}
397410
case 'savePDF': {
398411
// Save the actual PDF binary from the current page or embedded viewer
399412
if (!step.value) {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface BaseStep {
1111
description?: string;
1212
object_type?: SelectorType;
1313
object?: string;
14-
action: 'navigate' | 'input' | 'click' | 'data' | 'scroll' | 'eventBaseDownload' | 'foreach' | 'open' | 'savePDF' | 'printToPDF' | 'downloadPDF' | 'downloadFile';
14+
action: 'navigate' | 'input' | 'click' | 'data' | 'scroll' | 'reload' | 'eventBaseDownload' | 'foreach' | 'open' | 'savePDF' | 'printToPDF' | 'downloadPDF' | 'downloadFile';
1515
value?: string;
1616
key?: string; // property key when collecting data
1717
data_type?: DataType;

0 commit comments

Comments
 (0)