Giter Site home page Giter Site logo

schickling / chromeless Goto Github PK

View Code? Open in Web Editor NEW
13.2K 234.0 581.0 1.06 MB

πŸ–₯ Chrome automation made simple. Runs locally or headless on AWS Lambda.

Home Page: https://chromeless.netlify.com

License: MIT License

TypeScript 76.15% HTML 23.85%
serverless integration-testing headless-chrome headless graphcool nightmarejs selenium chrome

chromeless's People

Contributors

adieuadieu avatar anttiviljami avatar berzniz avatar clebert avatar criticalbh avatar elisherer avatar felixfbecker avatar greenkeeper[bot] avatar janza avatar joelgriffith avatar joeyvandijk avatar koleok avatar liady avatar mido3ds avatar mmkal avatar nylen avatar okeeffed avatar pklingem avatar ranger2959 avatar remixz avatar schickling avatar seangransee avatar skiloop avatar timsuchanek avatar toddwprice avatar torbs avatar vladgolubev avatar yazzyyaz avatar zaaack avatar zol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chromeless's Issues

.evaluate should return values


const evalRes = await chromeless
  .goto('https://www.graph.cool')
  .evaluate(() => {
      return new Promise((resolve) => {
          setTimeout(() => {
              resolve('ok');
          }, 10);
      });
  })

console.log(evalRes)

await chromeless.end()

It's possible to return even async stuff as well: https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#method-evaluate. There's a param called awaitPromise to indicate it's async. You can also "assume" it's async by default even if it's not and just return the value immediately.

.size API

Would be nice to have a size method for changing the browser window size (helpful for screenshots and stuff where users want to capture responsive sites)

Finish chromeless-playground

Revisit screenshot handling

Currently we're uploading to our own Graphcool project - maybe we just want to return the b64 string so people can save it with fs.writeFile on their own

Implement non-promise eval.code

Currently it's not a nice experience when you want to evaluate code, but continue with the method chain. This is an example of tests that I implemented with chromeless. Here it gets pretty clear, that we should have a variant of eval.code that returns the Chromeless instance. One possibility would be to call it directly .code()

export default async (cookies: any[]): Promise<any> => {

  const chromeless = new Chromeless({
    runRemote,
    waitTimeout,
    viewport,
  })

  await chromeless
    .cookies.set(cookies)
    .goto(CONSOLE_URL)
    .wait(3200)
    .wait('a[data-test="sidenav-databrowser"]')
    .click('a[data-test="sidenav-databrowser"]')
    .wait(2200)
    .wait('a[data-test="sidenav-databrowser-model-Post"]')
    .click('a[data-test="sidenav-databrowser-model-Post"]')
    .wait(2200)
    .click('div[class^="NewRowInactive__add"]')
    .type('test url')
    .eval.code(() => document.querySelector('div[data-test="new-row-cell-imageUrl"] input').blur())

  await chromeless
    .click('div[data-test="new-row-cell-description"] > div > div')
    .wait(400)
    .wait('div[data-test="new-row-cell-description"] input')
    .type('some description', 'div[data-test="new-row-cell-description"] input')
    .eval.code(() => document.querySelector('div[data-test="new-row-cell-description"] input').blur())

  await chromeless
    .wait(700)
    .click('button[data-test="add-node"]')
    .wait(300)
    .click('div[data-test="edit-field-imageUrl"]')
    .click('div[data-test="cell-imageUrl"]')
    .type('123')
    .eval.code(() => document.querySelector('input').focus())

  return chromeless
    .press(13)
    .wait(400)
    .click('div[data-test="checkbox-row-0"]')
    .wait(400)
    .click('div[data-test="delete-button"]')
    .wait(400)
    .click('div.button.warning')
    .end()
}

If you're interested in more test examples, here are our console tests: https://github.com/graphcool/console/tree/dev/integration-tests/src/tests

Add integration test use case to Examples section in README

Since running integration tests in parallel is one of the great benefits of the project it'd be good to have a small example showing how it can be done. The examples available right now enlighten the uses in automation and scraping, but not so much on tests.

.coverage API

Chrome exposes a mechanism in which to get coverage for scripts. This type of information is crucial to front-end devs as it exposes unused code-paths. Would love to see an API for this

Missing Fonts

I tried demo page to get Taiwan google homepage screenshot, but the content have encoding problem.

screenshot

show console.log of evaluate

how can i get console.log from .evaluate() ?
i try to write this code, and i got 'undefined'
what's wrong with my code.

const { Chromeless } = require('chromeless');

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

  const login = await chromeless
    .cookiesClearAll()
    .goto('http://localhost/project/')
    .type('admin, 'input[id="username"]')
    .type('admin', 'input[id="password"]')
    .click('#submit')
    .wait('#last-loaded')
    .click('#last-loaded')
    .wait('#menu-sidebar')
    .evaluate(() => {
      const Links = [].map.call(
        document.querySelector('.main-nav').querySelectorAll('a'),
        a => a.href
      )
      return JSON.stringify(Links)
    })

  console.log(login)

  await chromeless.end()
}

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

Scripts that trigger pageloads fail

Not seeing a wait-like API for pageload. Might be nice to have chromeless "pause" execution if a pageload happens or retry failed actions when a pageload occurs

Automatically "wait" for elements to cut down on script noise

If you're writing a test that does a lot of interactive JS, there's going to be a lot of wait-type calls inside of scripts. It might be nice to automatically wait for elements as opposed to having to tell chromeless every time to wait for something.

Scroll to click position

When clicking on an element that is not in the screen, chromeless should scroll to that position

Take screenshot of an element

The screenshot() method returns the full-page screenshot, is there any way to get the screenshot of a DIV or any other element?

.visible API

Ensures that's elements are visible (which is a hard thing to implement in a .evaluate as there's a whole host of things that can make something invisible).

better solution for click

As the Input.dispatchMouseEvent didn't work for all cases, we added the artificial element.click().
This should have a cleaner solution

Please add a license

It is unclear what terms this tool is distributed under. Without a license it defaults to being proprietary (All Rights Reserved). Can you please clarify by adding a LICENSE file?

Replace Ably with AWS IoT

Ideally the entire AWS IoT setup would be contained in the serverless.yml file of the remote serverless stack.

viewport is broken. Change documentation or fix documented solution

HTTPS error on Win7

Hi guys,

Just FYI: the demo playground may not work on some Win7 machines because the Root Cisco Cert you're using to sign your certificate with is not known.

certificate problem on win7

I tried opening the same website on a Virtual Ubuntu on the same machine Β­- all works perfectly. Not sure that you want to support all dinosaur-age operating systems, but still letting you know :Β­-)

More "helper" methods like `attr` and `text`

Evaluate is a good hook for consumers to do what they wish for DOM stuff, but it's probably a good idea to have some sugar methods like attr, text, and html so that folks can write scrapers more easily.

Chromeless docker container

It would be great to quickly spin up a farm of chromeless images to run a test suite in parallel.
Using containers would remove the AWS requirement for scalability.
I'm not a docker expert, just started to evaluate docker-based solution as our test suite has grown significantly in the last couple of months, and we need a more elastic approach.

Release TODOs

  • Finish readme #13
  • process.end() on chrome instance. kill chrome each time for now to avoid zombies
  • chrome-plugin option to select which functions to wrap

Optional

  • refactor the on.message -> filter topic -> message.toString() stuff into a wrapper, like ably with channels, with builtin topic scopes
  • optimise what’s included in the deployment package

Garbage urls in `goto` hang

Probably want to fail quickly if goto gets a bad URL (also might want it to return a value for the resolved URL in case of redirects)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.