|
| 1 | +// Copyright 2023-2025 Lightpanda (Selecy SAS) |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | +'use scrict' |
| 15 | + |
| 16 | +import puppeteer from 'puppeteer-core'; |
| 17 | + |
| 18 | +const browserAddress = process.env.BROWSER_ADDRESS ? process.env.BROWSER_ADDRESS : 'ws://127.0.0.1:9222'; |
| 19 | +const baseURL = process.env.URL ? process.env.URL : 'http://127.0.0.1:1234' |
| 20 | + |
| 21 | +// use browserWSEndpoint to pass the Lightpanda's CDP server address. |
| 22 | +const browser = await puppeteer.connect({ |
| 23 | + browserWSEndpoint: browserAddress, |
| 24 | +}); |
| 25 | + |
| 26 | +// The rest of your script remains the same. |
| 27 | +const context = await browser.createBrowserContext(); |
| 28 | +const page = await context.newPage(); |
| 29 | + |
| 30 | +await page.goto('https://github.com/lightpanda-io/browser', {waitUtil: 'networkidle0'}); |
| 31 | + |
| 32 | +await page.waitForFunction(() => { |
| 33 | + return document.getElementById('folders-and-files') != null; |
| 34 | +}, {timeout: 1000}); |
| 35 | + |
| 36 | +const files = await page.evaluate(() => { |
| 37 | + return Array.from(document.querySelectorAll('[id^="folder-row"] div.react-directory-filename-cell')).map(row => { |
| 38 | + return row.textContent; |
| 39 | + }); |
| 40 | +}); |
| 41 | + |
| 42 | +await page.close(); |
| 43 | +await context.close(); |
| 44 | +await browser.disconnect(); |
| 45 | +console.log(files); |
| 46 | + |
| 47 | +for (expected of ['.github', 'src', 'build.zig', 'README.md', '.gitignore', 'LICENSING.md']) { |
| 48 | + if (!files.includes(expected)) { |
| 49 | + console.log(`Failed to find expected ${expected} entry in: `, files); |
| 50 | + } |
| 51 | +} |
0 commit comments