Compare commits

...

15 Commits

Author SHA1 Message Date
c38f338f8e 1.0.27 2021-08-17 17:51:50 +02:00
103c7eb11e fix(core): update 2021-08-17 17:51:50 +02:00
0190f1bb77 1.0.26 2021-08-17 15:22:10 +02:00
87d7460183 fix(core): update 2021-08-17 15:22:10 +02:00
ed1522062e 1.0.25 2021-08-17 12:20:54 +02:00
116f700d5c fix(core): update 2021-08-17 12:20:54 +02:00
366a033904 1.0.24 2021-08-17 02:53:34 +02:00
5f1f4b3c53 fix(core): update 2021-08-17 02:53:34 +02:00
255bd7046e 1.0.23 2021-08-17 02:51:24 +02:00
bb82845f27 1.0.22 2021-08-17 02:50:49 +02:00
8ec23ba414 fix(core): update 2021-08-17 02:50:49 +02:00
937605f8c1 1.0.21 2021-01-12 14:41:45 +00:00
f05c2226c5 fix(core): update 2021-01-12 14:41:44 +00:00
1d2eca0991 1.0.20 2021-01-12 14:24:22 +00:00
c91f77a0d4 fix(core): update 2021-01-12 14:24:21 +00:00
6 changed files with 17941 additions and 3393 deletions

21295
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartpuppeteer",
"version": "1.0.19",
"version": "1.0.27",
"private": false,
"description": "simplified access to puppeteer",
"main": "dist_ts/index.js",
@@ -13,18 +13,18 @@
"format": "(gitzone format)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.14.20",
"@gitzone/tsbuild": "^2.1.26",
"@gitzone/tstest": "^1.0.54",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.6.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartenv": "^4.0.16",
"@types/puppeteer": "^5.4.2",
"puppeteer": "^5.5.0"
"puppeteer": "^10.2.0",
"tree-kill": "^1.2.2"
},
"files": [
"ts/**/*",

View File

@@ -5,7 +5,15 @@ tap.test('first test', async (tools) => {
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: true,
});
const page = await headlessBrowser.newPage();
await headlessBrowser.close();
});
tap.test('should get and stop an Incognito browser', async () => {
const incognitoInstance = new smartpuppeteer.IncognitoBrowser();
await incognitoInstance.start();
const page = await incognitoInstance.browser.newPage();
await incognitoInstance.stop();
})
tap.start();

View File

@@ -13,7 +13,7 @@ export class IncognitoBrowser {
public async start() {
this.status = 'started';
this.browser = await getEnvAwareBrowserInstance();
this.browser.addListener('disconnected', async (eventArg) => {
this.browser.on('disconnected', async (eventArg) => {
try {
this.browser.removeAllListeners();
} catch (err) {}
@@ -28,9 +28,18 @@ export class IncognitoBrowser {
*/
public async stop() {
this.status = 'stopped';
plugins.treeKill(this.browser.process().pid, 'SIGKILL');
await this.browser.close();
}
/**
* rotate
*/
public async rotateBrowser () {
this.browser.close().catch();
this.browser = await getEnvAwareBrowserInstance();
}
public async getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext> {
if (this.browser) {
return this.browser.createIncognitoBrowserContext();

View File

@@ -25,6 +25,7 @@ export const getEnvAwareBrowserInstance = async (
console.log(chromeArgs);
headlessBrowser = await plugins.puppeteer.launch({
args: chromeArgs,
pipe: true
});
return headlessBrowser;

View File

@@ -11,5 +11,6 @@ export { smartdelay, smartenv };
// third party scope
import puppeteer from 'puppeteer';
import treeKill from 'tree-kill';
export { puppeteer };
export { puppeteer, treeKill };