Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b1f058a21 | |||
| c38f338f8e | |||
| 103c7eb11e | |||
| 0190f1bb77 | |||
| 87d7460183 | |||
| ed1522062e | |||
| 116f700d5c | |||
| 366a033904 | |||
| 5f1f4b3c53 | |||
| 255bd7046e |
5966
package-lock.json
generated
5966
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpuppeteer",
|
"name": "@pushrocks/smartpuppeteer",
|
||||||
"version": "1.0.22",
|
"version": "1.0.28",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "simplified access to puppeteer",
|
"description": "simplified access to puppeteer",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.26",
|
||||||
"@gitzone/tstest": "^1.0.54",
|
"@gitzone/tstest": "^1.0.54",
|
||||||
"@pushrocks/tapbundle": "^3.2.14",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^16.6.1",
|
"@types/node": "^16.6.1",
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartenv": "^4.0.16",
|
"@pushrocks/smartenv": "^4.0.16",
|
||||||
"@types/puppeteer": "^5.4.4",
|
"puppeteer": "^10.2.0",
|
||||||
"puppeteer": "^10.2.0"
|
"tree-kill": "^1.2.2"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
|||||||
@@ -5,7 +5,15 @@ tap.test('first test', async (tools) => {
|
|||||||
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
||||||
forceNoSandbox: true,
|
forceNoSandbox: true,
|
||||||
});
|
});
|
||||||
|
const page = await headlessBrowser.newPage();
|
||||||
await headlessBrowser.close();
|
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();
|
tap.start();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export class IncognitoBrowser {
|
|||||||
public async start() {
|
public async start() {
|
||||||
this.status = 'started';
|
this.status = 'started';
|
||||||
this.browser = await getEnvAwareBrowserInstance();
|
this.browser = await getEnvAwareBrowserInstance();
|
||||||
this.browser.addListener('disconnected', async (eventArg) => {
|
this.browser.on('disconnected', async (eventArg) => {
|
||||||
try {
|
try {
|
||||||
this.browser.removeAllListeners();
|
this.browser.removeAllListeners();
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
@@ -28,6 +28,7 @@ export class IncognitoBrowser {
|
|||||||
*/
|
*/
|
||||||
public async stop() {
|
public async stop() {
|
||||||
this.status = 'stopped';
|
this.status = 'stopped';
|
||||||
|
plugins.treeKill(this.browser.process().pid, 'SIGKILL');
|
||||||
await this.browser.close();
|
await this.browser.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ export { smartdelay, smartenv };
|
|||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import puppeteer from 'puppeteer';
|
import puppeteer from 'puppeteer';
|
||||||
|
import treeKill from 'tree-kill';
|
||||||
|
|
||||||
export { puppeteer };
|
export { puppeteer, treeKill };
|
||||||
|
|||||||
Reference in New Issue
Block a user