@@ -22,8 +22,8 @@ The key and secret can be obtained from [TestingBot](https://testingbot.com/memb
2222const TestingBot = require (' testingbot-api' );
2323
2424const tb = new TestingBot ({
25- api_key: " your-tb-key " ,
26- api_secret: " your-tb-secret "
25+ api_key: process . env . TESTINGBOT_KEY ,
26+ api_secret: process . env . TESTINGBOT_SECRET
2727});
2828```
2929
@@ -34,7 +34,7 @@ Gets a list of browsers you can test on
3434
3535``` javascript
3636// Callback style
37- tb .getBrowsers (function (error , browsers ) {});
37+ tb .getBrowsers (type, function (error , browsers ) {});
3838
3939// Async/await style
4040const browsers = await tb .getBrowsers ();
@@ -76,6 +76,34 @@ tb.getDevice(deviceId, function(error, deviceDetails) {});
7676const deviceDetails = await tb .getDevice (deviceId);
7777```
7878
79+ ### createSession
80+ Creates a remote browser on TestingBot and returns its CDP URL, which can be used to interface with the remote browser.
81+
82+ ``` javascript
83+ const options = {
84+ capabilities: {
85+ browserName: ' chrome' ,
86+ browserVersion: ' latest' ,
87+ platform: ' WIN11'
88+ }
89+ };
90+
91+ // Callback style
92+ tb .createSession (options, function (error , data ) {});
93+
94+ // Async/await style
95+ const session = await tb .createSession (options);
96+ ```
97+
98+ This will return a response with this structure:
99+ ``` json
100+ {
101+ "session_id" : " cb8aaba38ddb-88fd98fca537-a0070d8f1815-175888519321-14646637" ,
102+ "cdp_url" : " wss://cloud.testingbot.com/session/cb8aaba38ddb-88fd98fca537-a0070d8f1815-175888519321-14646637"
103+ }
104+ ```
105+
106+ You can now connect to the ` cdp_url ` with a CDP client to instruct the remote browser.
79107
80108### getUserInfo
81109Gets your user information
@@ -104,7 +132,7 @@ Gets list of your latest tests
104132
105133``` javascript
106134// Callback style
107- tb .getTests (function (error , tests ) {}, offset, limit );
135+ tb .getTests (offset, limit, function (error , tests ) {});
108136
109137// Async/await style
110138const tests = await tb .getTests ();
@@ -186,7 +214,7 @@ Retrieves the latest builds
186214
187215``` javascript
188216// Callback style
189- tb .getBuilds (function (error , builds ) {}, offset, limit );
217+ tb .getBuilds (offset, limit, function (error , builds ) {});
190218
191219// Async/await style
192220const builds = await tb .getBuilds ();
@@ -255,7 +283,7 @@ Retrieve list of previously uploaded files
255283
256284``` javascript
257285// Callback style
258- tb .getStorageFiles (function (error , fileDetails ) {}, offset, limit );
286+ tb .getStorageFiles (offset, limit, function (error , fileDetails ) {});
259287
260288// Async/await style
261289const fileDetails = await tb .getStorageFiles ();
@@ -289,18 +317,19 @@ Takes screenshots for the specific browsers
289317
290318``` javascript
291319// Callback style
292- tb .takeScreenshot (function ( error , screenshots ) {}, url, browsers, waitTime, resolution, fullPage, callbackURL);
320+ tb .takeScreenshot (url, browsers, waitTime, resolution, fullPage, callbackURL, function ( error , screenshots ) {} );
293321
294322// Async/await style
295323const screenshots = await tb .takeScreenshot (
296- ' https://example.com' , // url
297- [' chrome' , ' firefox ' ], // browsers
298- 5000 , // waitTime (ms)
299- ' 1920x1080 ' , // resolution
300- true , // fullPage
301- ' https://your-callback.com' // callbackURL
324+ ' https://example.com' , // url - required
325+ [{ browserName : ' chrome' , version : ' latest ' , os : ' WIN11 ' } ], // browsers - required
326+ ' 1920x1080 ' , // resolution - required
327+ 5000 , // waitTime (ms) - optional
328+ true , // fullPage - optional
329+ ' https://your-callback.com' // callbackURL - optional
302330);
303331```
332+ Once a screenshot job is running, you can use ` retrieveScreenshots ` to poll for the results.
304333
305334### retrieveScreenshots
306335Retrieves screenshots for a specific ` takeScreenshot ` call
@@ -318,7 +347,7 @@ Retrieves all screenshots previously generated with your account
318347
319348``` javascript
320349// Callback style
321- tb .getScreenshotList (function (error , screenshots ) {}, offset, limit );
350+ tb .getScreenshotList (offset, limit, function (error , screenshots ) {});
322351
323352// Async/await style
324353const screenshots = await tb .getScreenshotList ();
@@ -328,7 +357,7 @@ const screenshots = await tb.getScreenshotList(10, 20); // offset: 10, limit: 20
328357```
329358
330359### getTeam
331- Retrieves team information
360+ Retrieves team settings
332361
333362``` javascript
334363// Callback style
0 commit comments