Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions puppeteer/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'use scrict'

import puppeteer from 'puppeteer-core';
import assert from 'assert';

// ws address
const browserAddress = process.env.BROWSER_ADDRESS ? process.env.BROWSER_ADDRESS : 'ws://127.0.0.1:9222';
Expand All @@ -35,6 +36,29 @@ await page.goto('http://127.0.0.1:1234', {waitUntil: 'load'});

await page.click("a[href='campfire-commerce/']");

assert.strictEqual(page.url(), 'http://127.0.0.1:1234/campfire-commerce/', 'The new page URL is not as expected.');

// ensure product's details is loaded
const price = parseFloat(await page.evaluate(() => { return document.querySelector('#product-price').textContent.substring(1); }));
if (price != 244.99) {
console.log(res);
throw new Error("invalid product price");
}

// ensure reviews are loaded
const reviews = await page.evaluate(() => {
return Array.from(document.querySelectorAll('#product-reviews > div')).map(row => {
return {
name: row.querySelector('h4').textContent,
text: row.querySelector('p').textContent,
};
});
});
if (reviews.length != 3) {
console.log(res);
throw new Error("invalid reviews length");
}

await page.close();
await context.close();
await browser.disconnect();
1 change: 1 addition & 0 deletions runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) error {
{Bin: "node", Args: []string{"puppeteer/cdp.js"}, Env: []string{"RUNS=10"}},
{Bin: "node", Args: []string{"puppeteer/dump.js"}, Env: []string{"URL=http://127.0.0.1:1234/campfire-commerce/"}},
{Bin: "node", Args: []string{"puppeteer/links.js"}, Env: []string{"URL=http://127.0.0.1:1234/campfire-commerce/"}},
{Bin: "node", Args: []string{"puppeteer/click.js"}},
{Bin: "node", Args: []string{"playwright/connect.js"}},
{Bin: "node", Args: []string{"playwright/cdp.js"}, Env: []string{"RUNS=2"}},
{Bin: "go", Args: []string{"run", "fetch/main.go", "http://127.0.0.1:1234/"}, Dir: "chromedp"},
Expand Down