Login  Register

Re: Chrome DevTools Protocol and Pharo

Posted by Torsten Bergmann on May 19, 2017; 8:38pm
URL: https://forum.world.st/Chrome-DevTools-Protocol-and-Pharo-tp4947589p4947679.html

Hi Alistair,

cant look right now but two things:

  - there are also events in the protocol - if we could hook Pharo into them
    this would solve the problem without abusing delay (because then you will
    get informed when the page loading is finished)

  - you can write "5 seconds wait" in Pharo

Bye
T.


> Gesendet: Freitag, 19. Mai 2017 um 17:51 Uhr
> Von: "Alistair Grant" <[hidden email]>
> An: [hidden email]
> Betreff: Re: [Pharo-dev] Chrome DevTools Protocol and Pharo
>
> On Fri, May 19, 2017 at 01:50:28PM +0200, Torsten Bergmann wrote:
> > Alistair Grant wrote
> >
> > > This looks really interesting, thanks for making it available.  I'm on
> > > linux, so I guess it will need some porting.
> >
> > I added support for Linux and tried on Ubuntu with Chromium. Works - see screenshot
>
> Fantastic, thanks!
>
> I did have to change your script for it to work on my laptop:
>
> 1. isInDebugMode is false by default, which meant that chrome wasn't
> launched with remote debugging enabled.
>
> 2. Retrieving the remotes in GoogleChrome class>>tabPages failed because
> the browser hadn't had time to start up.  I'll submit a pull request
> which adds a retry with delay.
>
> 3. I initially got a white image.  This appears to be because the script
> doesn't wait for the navigation to complete before taking the
> screenshot.  I just added an ugly delay, but I'm not yet sure what the best
> solution here is.
>
>
> | chrome page |
>
> chrome := GoogleChrome new
> debugOn;
> open;
> yourself.
> page := chrome tabPages first.
> page navigateTo: 'http://www.pharo.org'.
> (Delay forSeconds: 5) wait.
> page captureScreenshot scaledToSize: 200@300.
>
>
> > You need to load my OSLinux package (instead of OSOSX) from catalog. Or start
> > Chrom manually in debug mode.
> >
> > In the Pharo settings browser you can set the path to the chrome executable
> > and the debug port to use.
>
> I doubt that the chrome executable is in that many different places.
> Would you be open accepting a pull request which adds (what I assume is)
> the Ubuntu 16.04 default location?
>
>
> > Will add Windows support as well (using my OSWindows package)
> >
> > > Do you know how the DevTools protocol relates to headless chome, which
> > > will be available in Chrome 59?
> > > See https://developers.google.com/web/updates/2017/04/headless-chrome
> >
> > Dont know - just try it.
> >
> > > In particular, is it possible to dump the DOM with your package?
> >
> > I've seen that Brackets editor as well as Netbeans open Chrome to
> > display webpages when editing and refresh when typing. Wanted
> > to find out how it was done.
> >
> > I have not implemented the full protocol. Only what was needed to show
> > that it is possible and to do things like grabbing screenshots from websites
> > using Pharo.
>
> I've found a page that describes accessing the DOM, so it looks like it
> should be possible.  I'll see what I can do...
>
> > There is a DOM domain that one could wrap - basically it is just
> > sending JSON around, see
> > https://chromedevtools.github.io/devtools-protocol
> >
> > With
> >
> >  chrome := GoogleChrome open.
> >  chrome jsProtocolJSON.
> >  chrome browseProtocolJSON
> >
> > you can now even retrieve the Protocol as JSON for the specific browser.
> > With a little bit more work it should be possible to even generate
> > the wrapper classes/methods from such a protocol spec.
>
> Thanks again,
> Alistair
>
>
>
>