Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

fix to work with new amazon design #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dietbald
Copy link

No description provided.

@@ -7,16 +7,18 @@ const puppeteer = require('puppeteer')
const screenshot = 'amazon_nyan_cat_pullover.png'
try {
(async () => {
const browser = await puppeteer.launch()
const browser = await puppeteer.launch({ headless: false})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to have { headless: true } here

const page = await browser.newPage()
await page.setViewport({ width: 1280, height: 800 })
await page.goto('https://www.amazon.com')
await page.type('#twotabsearchtextbox', 'nyan cat pullover')
await page.click('input.nav-input')
await page.waitForSelector('#resultsCol')
await page.waitFor(3000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an anti-pattern. waitFor(3000) or any wait period that does not wait for an explicit element is bound to break. Please wait for a specific element.

await page.click('#pagnNextString')
await page.waitForSelector('#resultsCol')
await page.click('li[class="a-last"] > a')
await page.waitFor(3000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on waitFor() above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants