Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

could specify the wait time for 'wait('div#loaded')' #208

Closed
ylscsdb opened this issue Aug 9, 2017 · 1 comment · Fixed by #212
Closed

could specify the wait time for 'wait('div#loaded')' #208

ylscsdb opened this issue Aug 9, 2017 · 1 comment · Fixed by #212
Labels

Comments

@ylscsdb
Copy link

ylscsdb commented Aug 9, 2017

const { Chromeless } = require('chromeless')

async function run() {
  const chromeless = new Chromeless()

  const screenshot = await chromeless
    .goto('https://www.google.com')
    .type('chromeless', 'input[name="q"]')
    .press(13)
    .wait('#resultStats', 2000) //could I specify the wait time, not only  the default time
    .screenshot()

  console.log(screenshot) // prints local file path or S3 url

  await chromeless.end()
}

run().catch(console.error.bind(console))

could I specify the wait time, not only the default time

@adieuadieu
Copy link
Collaborator

Hi @ylscsdb I don't entirely understand your question. Let me point out that you can do this:

const screenshot = await chromeless
    .goto('https://www.google.com')
    .type('chromeless', 'input[name="q"]')
    .press(13)
    .wait('#resultStats') // wait for #resultStats to show up in the DOM
    .wait(2000)  // wait for 2 more seconds, just because, for the fun of it
    .wait(() => { while (c < 1000000000) { c += 1 } })  // wait until we've counted to a billion cuz why not?
    .screenshot()

  console.log(screenshot) // prints local file path or S3 url

  await chromeless.end()

janza added a commit to janza/chromeless that referenced this issue Aug 9, 2017
janza added a commit to janza/chromeless that referenced this issue Aug 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants