Skip to content

Commit 92e3445

Browse files
Merge pull request #36 from germanbisogno/develop
Develop
2 parents 5c6a7e7 + 7e2c8f7 commit 92e3445

13 files changed

Lines changed: 49 additions & 49 deletions

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following example shows how to use the Tracing class with Selenium Webdriver
2626

2727
```js
2828

29-
import { CDPSession, Tracing } from "cdp-utils";
29+
import { CDPClient, Tracing } from "cdp-utils";
3030

3131
test('Test tracing', async () => {
3232
const options = new chrome.Options();
@@ -40,11 +40,11 @@ test('Test tracing', async () => {
4040
const googlePage = new GooglePage(driver);
4141

4242
// Initializes the CDP client connection
43-
const cdpSession = new CDPSession();
44-
await cdpSession.init(port);
43+
const cdpClient = new CDPClient();
44+
await cdpClient.init(port);
4545

4646
// Instantiates the class and produces a file as result of the trace
47-
const tracing = new Tracing(cdpSession, 'tracing.json');
47+
const tracing = new Tracing(cdpClient, 'tracing.json');
4848

4949
// start tracing
5050
await tracing.startTrace();
@@ -57,7 +57,7 @@ test('Test tracing', async () => {
5757
// do whatever with trace
5858

5959
// Close the CDP client connection
60-
await cdpSession.close()
60+
await cdpClient.close()
6161

6262
await driver.quit();
6363

@@ -71,7 +71,7 @@ An example using the Performance class with Selenium Webdriver.
7171
7272
```js
7373

74-
import { CDPSession, Performance } from "cdp-utils";
74+
import { CDPClient, Performance } from "cdp-utils";
7575

7676
test('Test performance', async () => {
7777
const options = new chrome.Options();
@@ -85,11 +85,11 @@ test('Test performance', async () => {
8585
const googlePage = new GooglePage(driver);
8686

8787
// Initializes the CDP client connection
88-
const cdpSession = new CDPSession();
89-
await cdpSession.init(port);
88+
const cdpClient = new CDPClient();
89+
await cdpClient.init(port);
9090

9191
// Instantiates the class and produces two files as result of the trace
92-
const performance = new Performance(cdpSession, 'startTrace.json', 'endTrace.json');
92+
const performance = new Performance(cdpClient, 'startTrace.json', 'endTrace.json');
9393

9494
// start tracing
9595
const perfStartResults = await performance.startTrace();
@@ -103,7 +103,7 @@ test('Test performance', async () => {
103103
// Perform assertions or do whatever with perfStartResults or perfEndResults
104104

105105
// Close the CDP client connection
106-
await cdpSession.close()
106+
await cdpClient.close()
107107

108108
await driver.quit();
109109
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gbisogno/cdp-utils",
3-
"version": "1.3.5",
3+
"version": "1.3.6",
44
"description": "A set of utilities/wrapper for Test Automation or Performance testing on top of Chrome DevTools Protocol",
55
"repository": {
66
"type": "git",

src/__tests__/network.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as chrome from "selenium-webdriver/chrome";
33
import 'chromedriver';
44
import { GooglePage } from '../pages/googlePage';
55
import { Network } from '../network';
6-
import { CDPSession } from '../cdpSession';
6+
import { CDPClient } from '../cdpClient';
77
import { config } from "../config/config";
88
import { getFreePort } from 'endpoint-utils';
99
import { Har } from "har-format";
@@ -23,10 +23,10 @@ test('Test Network', async () => {
2323

2424
const googlePage = new GooglePage(driver);
2525

26-
const cdpSession = new CDPSession();
27-
await cdpSession.init(port);
26+
const cdpClient = new CDPClient();
27+
await cdpClient.init(port);
2828

29-
const network = new Network(cdpSession, 'network.har');
29+
const network = new Network(cdpClient, 'network.har');
3030

3131
await network.startTrace();
3232

@@ -37,7 +37,7 @@ test('Test Network', async () => {
3737
const networkResults: Har = await network.stopTrace();
3838
expect(networkResults.log.entries.length).toBeGreaterThan(0);
3939

40-
await cdpSession.close();
40+
await cdpClient.close();
4141

4242
await driver.quit()
4343

src/__tests__/performance.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as chrome from "selenium-webdriver/chrome";
33
import 'chromedriver';
44
import { GooglePage } from '../pages/googlePage';
55
import { Performance } from '../performance';
6-
import { CDPSession } from '../cdpSession';
6+
import { CDPClient } from '../cdpClient';
77
import { config } from "../config/config";
88
import { getFreePort } from 'endpoint-utils';
99

@@ -22,10 +22,10 @@ test('Test Performance', async () => {
2222

2323
const googlePage = new GooglePage(driver);
2424

25-
const cdpSession = new CDPSession();
26-
await cdpSession.init(port);
25+
const cdpClient = new CDPClient();
26+
await cdpClient.init(port);
2727

28-
const performance = new Performance(cdpSession, 'startTrace.json', 'endTrace.json');
28+
const performance = new Performance(cdpClient, 'startTrace.json', 'endTrace.json');
2929

3030
const perfStartResults = await performance.startTrace();
3131

@@ -38,7 +38,7 @@ test('Test Performance', async () => {
3838
expect(perfStartResults.metrics.length).toBeGreaterThan(0);
3939
expect(perfEndResults.metrics.length).toBeGreaterThan(0);
4040

41-
await cdpSession.close();
41+
await cdpClient.close();
4242

4343
await driver.quit()
4444

src/__tests__/runtime.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as chrome from "selenium-webdriver/chrome";
33
import 'chromedriver';
44
import { GooglePage } from '../pages/googlePage';
55
import { Runtime } from '../runtime';
6-
import { CDPSession } from '../cdpSession';
6+
import { CDPClient } from '../cdpClient';
77
import { config } from "../config/config";
88
import { getFreePort } from 'endpoint-utils';
99

@@ -22,10 +22,10 @@ test('Test Runtime', async () => {
2222

2323
const googlePage = new GooglePage(driver);
2424

25-
const cdpSession = new CDPSession();
26-
await cdpSession.init(port);
25+
const cdpClient = new CDPClient();
26+
await cdpClient.init(port);
2727

28-
const runtime = new Runtime(cdpSession, 'console.json');
28+
const runtime = new Runtime(cdpClient, 'console.json');
2929

3030
await runtime.startTrace();
3131

@@ -45,7 +45,7 @@ test('Test Runtime', async () => {
4545
expect(consoleResults.find(x => x.type === 'warning')).toBeDefined();
4646
expect(consoleResults.find(x => x.type === 'log')).toBeDefined();
4747

48-
await cdpSession.close();
48+
await cdpClient.close();
4949

5050
await driver.quit()
5151

src/__tests__/tracing.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Builder } from "selenium-webdriver";
22
import * as chrome from "selenium-webdriver/chrome";
33
import 'chromedriver';
4-
import { CDPSession } from '../cdpSession';
4+
import { CDPClient } from '../cdpClient';
55
import { GooglePage } from '../pages/googlePage';
66
import { Tracing } from '../tracing';
77
import { config } from "../config/config";
@@ -22,10 +22,10 @@ test('Test Tracing', async () => {
2222

2323
const googlePage = new GooglePage(driver);
2424

25-
const cdpSession = new CDPSession();
26-
await cdpSession.init(port);
25+
const cdpClient = new CDPClient();
26+
await cdpClient.init(port);
2727

28-
const tracing = new Tracing(cdpSession, 'tracing.json');
28+
const tracing = new Tracing(cdpClient, 'tracing.json');
2929

3030
await driver.get("https://www.google.com");
3131

@@ -37,7 +37,7 @@ test('Test Tracing', async () => {
3737

3838
expect(tracingResults.length).toBeGreaterThan(0);
3939

40-
await cdpSession.close();
40+
await cdpClient.close();
4141

4242
await driver.quit();
4343
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import CDP from "chrome-remote-interface";
22
import { logger } from "./utils/logger";
33

4-
export class CDPSession{
4+
export class CDPClient {
55
private _client: CDP.Client;
66

77
/**
@@ -23,7 +23,7 @@ export class CDPSession{
2323
/**
2424
* Gets the CDP client connection
2525
*/
26-
public get client(): CDP.Client {
26+
public get(): CDP.Client {
2727
return this._client;
2828
}
2929

src/geoLocation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import * as CDP from 'chrome-remote-interface';
2-
import { CDPSession } from './cdpSession';
2+
import { CDPClient } from './cdpClient';
33

44
import { Coordinates } from './interfaces/coordinates'
55
import { logger } from "./utils/logger";
66

77
export class GeoLocation {
88
private _client: CDP.Client;
99

10-
constructor(cdpSession: CDPSession) {
11-
this._client = cdpSession.client;
10+
constructor(cdpClient: CDPClient) {
11+
this._client = cdpClient.get();
1212
}
1313
/**
1414
* Emulates a geo location by coordinates

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export { Lighthouse } from './lighthouse';
55
export { Tracing } from './tracing';
66
export { Runtime } from './runtime';
77
export { GeoLocation } from './geoLocation';
8-
export { CDPSession } from './cdpSession';
8+
export { CDPClient } from './cdpClient';
99
export { config } from './config/config';

src/network.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TraceOperations } from './traceOperations'
44
import { logger } from "./utils/logger";
55
import { NetworkConditions } from './interfaces/networkConditions';
66
import { Har } from 'har-format';
7-
import { CDPSession } from './cdpSession';
7+
import { CDPClient } from './cdpClient';
88
import CDP from 'chrome-remote-interface';
99

1010
// event types to observe
@@ -79,9 +79,9 @@ export class Network extends TraceOperations {
7979
protected _events: any[] = [];
8080
private _client: CDP.Client;
8181

82-
constructor(cdpSession: CDPSession, traceFileName: string = '') {
82+
constructor(cdpClient: CDPClient, traceFileName: string = '') {
8383
super();
84-
this._client = cdpSession.client;
84+
this._client = cdpClient.get();
8585
this._traceFileName = traceFileName;
8686
}
8787

0 commit comments

Comments
 (0)