1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "browser.start": "https://www.wikipedia.org",
12 "browser.engine": "chromium",
13 "browser.library": "playwright",
14 "script":
15
16
17
18 context => async ({page, tools: {sleep, expect, waitForPage}} = context) => {
19
20 page.setDefaultNavigationTimeout(90 * 1000);
21
22 await page.goto('https://www.wikipedia.org/', {waitUntil: 'domcontentloaded'});
23 await page.getByRole('button', { name: 'Read Wikipedia in your' }).click();
24 await page.getByRole('searchbox', { name: 'Search Wikipedia' }).click();
25 await page.getByRole('searchbox', { name: 'Search Wikipedia' }).fill('hello world');
26 await page.getByRole('searchbox', { name: 'Search Wikipedia' }).press('ArrowDown');
27 await page.getByRole('searchbox', { name: 'Search Wikipedia' }).press('Enter');
28 await page.getByRole('link', { name: 'View history' }).click();
29 await page.getByRole('button', { name: 'Compare selected revisions' }).first().click();
30 await page.getByRole('switch', { name: 'Inline' }).click();
31 await page.getByRole('button', { name: 'Visual' }).click();
32 await page.getByRole('button', { name: 'Tools' }).check();
33 await page.getByRole('link', { name: 'Edit', exact: true }).click();
34
35 await page.goto('https://apify.com/store/', {waitUntil: 'domcontentloaded'});
36 await page.getByRole('combobox').click();
37 await page.locator('[data-test="actor-store-search"]').click();
38 await page.locator('[data-test="actor-store-search"]').fill('chrome extensions');
39 await page.locator('[data-test="actor-store-search"]').press('ArrowDown');
40 await page.locator('[data-test="actor-store-search"]').press('ArrowDown');
41 await page.locator('[data-test="actor-store-search"]').press('ArrowUp');
42 await page.locator('[data-test="actor-store-search"]').press('ArrowUp');
43 await page.locator('[data-test="actor-store-search"]').press('Enter');
44 await page.locator('[data-test="store-filter-category"]').click();
45 await page.locator('[data-test="store-filter-category"]').press('Tab');
46 await page.locator('[data-test="store-filter-pricing"]').press('Tab');
47 await page.locator('[data-test="store-filter-managedBy"]').press('ArrowDown');
48 await page.getByRole('option', { name: 'All developers' }).press('ArrowDown');
49 await page.getByRole('option', { name: 'Maintained by Apify' }).press('ArrowDown');
50 await page.getByRole('option', { name: 'Maintained by Community' }).press('Enter');
51 await page.getByRole('link', { name: 'Chrome Extensions avatar' }).click();
52 await page.getByRole('tab', { name: 'Input' }).click();
53 await page.getByRole('tab', { name: 'API' }).click();
54 await page.getByRole('tab', { name: 'Reviews' }).click();
55 await page.getByRole('link', { name: 'Vasek Codey Vlcek Vasek Codey' }).click();
56 await page.locator('div').filter({ hasText: 'Vasek Codey' }).nth(2).click();
57
58
59 return {
60 example: true,
61 success: true,
62 };
63 };
64
65
66
67 ,
68 "proxy": {
69 "useApifyProxy": false
70 }
71};
72
73
74const run = await client.actor("cyberfly/apify-agent").call(input);
75
76
77console.log('Results from dataset');
78console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
79const { items } = await client.dataset(run.defaultDatasetId).listItems();
80items.forEach((item) => {
81 console.dir(item);
82});
83
84