Skip to content

Commit

Permalink
[ Add ] Many useful methods which are easy to implement
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Apr 6, 2018
1 parent de61a22 commit bf104bc
Show file tree
Hide file tree
Showing 13 changed files with 1,241 additions and 66 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Expand Up @@ -2,6 +2,7 @@
"env": {
"es6": true,
"node": true,
"browser": true,
"mocha": true
},
"parserOptions": {
Expand Down
25 changes: 2 additions & 23 deletions README.md
@@ -1,35 +1,14 @@
# Puppeteer for Firefox

I needed to run some tests against both Chrome and Firefox. Because I am lazy, I only wanted to write the harness code once.

So I took [Foxdriver](https://github.com/saucelabs/foxdriver), written by the wonderful folks at [Sauce Labs](https://saucelabs.com/), and wrapped the [Puppeteer API](https://github.com/GoogleChrome/puppeteer/) around it.

Well, just a tiny bit of it... enough to:

* Launch Firefox
* Open a URL
* Evaluate JS in the console of the page

I'll probably add more as I hit more functionality that I need.

Happy to accept PRs if you find this useful and want to add more API coverage.
Headless Firefox NodeJS API based on [FoxDriver](https://github.com/saucelabs/foxdriver/) (written by the wonderful folks at [Sauce Labs](https://saucelabs.com/)), which is compatible with [Puppeteer API](https://github.com/GoogleChrome/puppeteer/).

[![NPM](https://nodei.co/npm/puppeteer-fx.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/puppeteer-fx/)



## Supported APIs

* puppeteer
* launch()
* headless
* userDataDir
* browser
* newPage()
* close()
* page
* goto()
* evaluate()
Execute `npm run help` for details.



Expand Down
44 changes: 44 additions & 0 deletions docs/Browser.html
Expand Up @@ -31,12 +31,24 @@ <h3>Classes</h3>
<ul class='methods'>
<li data-type='method'><a href="Browser.html#close">close</a></li>
<li data-type='method'><a href="Browser.html#newPage">newPage</a></li>
<li data-type='method'><a href="Browser.html#userAgent">userAgent</a></li>
</ul>
</li>
<li><a href="Page.html">Page</a>
<ul class='methods'>
<li data-type='method'><a href="Page.html#$">$</a></li>
<li data-type='method'><a href="Page.html#$$">$$</a></li>
<li data-type='method'><a href="Page.html#addScriptTag">addScriptTag</a></li>
<li data-type='method'><a href="Page.html#addStyleTag">addStyleTag</a></li>
<li data-type='method'><a href="Page.html#content">content</a></li>
<li data-type='method'><a href="Page.html#evaluate">evaluate</a></li>
<li data-type='method'><a href="Page.html#focus">focus</a></li>
<li data-type='method'><a href="Page.html#goBack">goBack</a></li>
<li data-type='method'><a href="Page.html#goFoward">goFoward</a></li>
<li data-type='method'><a href="Page.html#goto">goto</a></li>
<li data-type='method'><a href="Page.html#reload">reload</a></li>
<li data-type='method'><a href="Page.html#setContent">setContent</a></li>
<li data-type='method'><a href="Page.html#title">title</a></li>
</ul>
</li>
<li><a href="Puppeteer.html">Puppeteer</a>
Expand Down Expand Up @@ -157,6 +169,38 @@ <h5>Returns:</h5>
</dd>
</dl>

<h4 class="name" id="userAgent"><span class="type-signature"></span>userAgent<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="global.html#Promise">Promise</a>.&lt;string>}</span></h4>

<dl class="details">

<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="Browser.js.html">Browser.js</a>, <a href="Browser.js.html#line46">line 46</a>
</li>
</ul>
</dd>

</dl>

<h5>Returns:</h5>

<div class="param-desc">
<p>Promise which resolves to the browser's original user agent</p>
</div>

<dl class="param-type">
<dt>
Type
</dt>
<dd>

<span class="param-type"><a href="global.html#Promise">Promise</a>.&lt;string></span>

</dd>
</dl>

</article>

</section>
Expand Down
24 changes: 22 additions & 2 deletions docs/Browser.js.html
Expand Up @@ -31,12 +31,24 @@ <h3>Classes</h3>
<ul class='methods'>
<li data-type='method'><a href="Browser.html#close">close</a></li>
<li data-type='method'><a href="Browser.html#newPage">newPage</a></li>
<li data-type='method'><a href="Browser.html#userAgent">userAgent</a></li>
</ul>
</li>
<li><a href="Page.html">Page</a>
<ul class='methods'>
<li data-type='method'><a href="Page.html#$">$</a></li>
<li data-type='method'><a href="Page.html#$$">$$</a></li>
<li data-type='method'><a href="Page.html#addScriptTag">addScriptTag</a></li>
<li data-type='method'><a href="Page.html#addStyleTag">addStyleTag</a></li>
<li data-type='method'><a href="Page.html#content">content</a></li>
<li data-type='method'><a href="Page.html#evaluate">evaluate</a></li>
<li data-type='method'><a href="Page.html#focus">focus</a></li>
<li data-type='method'><a href="Page.html#goBack">goBack</a></li>
<li data-type='method'><a href="Page.html#goFoward">goFoward</a></li>
<li data-type='method'><a href="Page.html#goto">goto</a></li>
<li data-type='method'><a href="Page.html#reload">reload</a></li>
<li data-type='method'><a href="Page.html#setContent">setContent</a></li>
<li data-type='method'><a href="Page.html#title">title</a></li>
</ul>
</li>
<li><a href="Puppeteer.html">Puppeteer</a>
Expand Down Expand Up @@ -69,7 +81,7 @@ <h1 class="page-title">Browser.js</h1>

constructor({browser, tab}) {

super();
super()._page = [ ];

this._browser = browser;

Expand All @@ -81,7 +93,7 @@ <h1 class="page-title">Browser.js</h1>
*/
newPage() {

return new Page({tab: this._tab});
return this._page[this._page.push(new Page({tab: this._tab})) - 1];
}

/**
Expand All @@ -95,6 +107,14 @@ <h1 class="page-title">Browser.js</h1>

return this._browser.close();
}

/**
* @return {Promise&lt;string>} Promise which resolves to the browser's original user agent
*/
userAgent() {

return this._page[0].evaluate('navigator.userAgent');
}
}

module.exports = Browser;
Expand Down

0 comments on commit bf104bc

Please sign in to comment.