Example #1
0
 /**
  * @param string $type
  *
  * @return string
  *
  * @throws InvalidArgumentException
  */
 private function endpoint($type)
 {
     if ($type == 'list') {
         return sprintf('/session/%s/page', $this->session->id());
     }
     if ($type == 'view') {
         return sprintf('/session/%s/page/%s', $this->session->id(), $this->id);
     }
     $actions = ['zoom', 'resize', 'scroll', 'capture', 'run', 'visit', 'wait'];
     if (in_array($type, $actions)) {
         return sprintf('/session/%s/page/%s/%s', $this->session->id(), $this->id, $type);
     }
     throw new InvalidArgumentException(sprintf('"%s" is not supported', $type));
 }
<?php

require __DIR__ . '/../vendor/autoload.php';
use Undemanding\Client\Page;
use Undemanding\Client\Session;
$client = new GuzzleHttp\Client(['base_uri' => 'http://localhost:4321']);
$session = Session::create($client);
$page = Page::create($client, $session);
$page->visit('http://localhost:5432')->run('document.body.innerHTML = "hello chris"')->resize(1024, 768)->zoom(2)->preview();
Example #3
0
 /**
  * @param Client $client
  *
  * @return Session
  */
 private function createUndemandingSession(Client $client)
 {
     return Session::create($client);
 }