Skip to content

Commit

Permalink
update changelog and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gsouf committed Aug 28, 2018
1 parent 3a08fd2 commit 01e2604
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 10 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@

## 0.2.2

> *20xx-xx-xx* (not released)
> Added input controls
> *2018-08-28*
* Features:
* Added mouse api (move, click)
* Page info are now in sync with the browser
* Added a shortcut to get current page url: ``Page::getCurrentUrl``
* Added ability to get and set cookies from a page: ``Page.setCookies``, ``Page.readCookies`` , ``Page.readAllCookies``
* improved some error reporting
* fixed a bug with directory creation for screenshots
* added ability to set custom user agent: ``Page::setUserAgent`` or via factory option ``userAgent``
* Bug fixes:
* none

Expand Down
83 changes: 76 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,15 @@ API

Here are the options available for the browser factory:

| Option name | Default | Description |
|--------------------|-----------------------|---------------------------------------------------------------------------------|
| connectionDelay | 0 | Delay to apply between each operation for debugging purposes |
| Option name | Default | Description |
|--------------------|-----------------------|-----------------------------------------------------------------------------------|
| connectionDelay | 0 | Delay to apply between each operation for debugging purposes |
| debugLogger | null | A string (e.g "php://stdout"), or resource, or PSR-3 logger instance to print debug messages |
| enableImages | true | Toggles loading of images |
| headless | true | Enable or disable headless mode |
| userDataDir | none | chrome user data dir (default: a new empty dir is generated temporarily) |
| startupTimeout | 30 | Maximum time in seconds to wait for chrome to start |
| enableImages | true | Toggles loading of images |
| headless | true | Enable or disable headless mode |
| userAgent | none | User agent to use for the whole browser (see page api for alternative) |
| userDataDir | none | chrome user data dir (default: a new empty dir is generated temporarily) |
| startupTimeout | 30 | Maximum time in seconds to wait for chrome to start |
| windowSize | - | Size of the window. usage: ``[$width, $height]`` - see also Page::setViewportSize |

### Browser API
Expand Down Expand Up @@ -299,6 +300,74 @@ The mouse API is dependent on the page instance and allows you to control the mo
$page->waitForReload();
```

### Cookie API

You can set and get cookies for a page:

#### Set Cookie

```php
use HeadlessChromium\Cookies\Cookie;

$page = $browser->createPage();

// example 1: set cookies for a given domain

$page->setCookies([
Cookie::create('name', 'value', [
'domain' => 'example.com',
'expires' => time() + 3600 // expires in 1 day
])
])->await();


// example 2: set cookies for the current page

$page->navigate('http://example.com')->waitForNavigation();

$page->setCookies([
Cookie::create('name', 'value', ['expires'])
])->await();

```

#### Get Cookies

```php
use HeadlessChromium\Cookies\Cookie;

$page = $browser->createPage();

// example 1: get all cookies for the browser

$cookies = $page->getAllCookies();

// example 2: get cookies for the current page

$page->navigate('http://example.com')->waitForNavigation();
$cookies = $page->getCookies();

// filter cookies with name == 'foo'
$cookiesFoo = $cookies->filterBy('name', 'foo');

// find first cookie with name == 'bar'
$cookieBar = $cookies->findOneBy('name', 'bar');
if ($cookieBar) {
// do something
}

```

### Set user agent

You can set an user agent per page :

```php
$page->setUserAgent('my user agent');
```

See also BrowserFactory option ``userAgent`` to set it for the whole browser.


------------------------------------------------------------------------------------------------------------------------

Expand Down

0 comments on commit 01e2604

Please sign in to comment.