Skip to content

Commit 7434875

Browse files
asambstackfrancisf
authored andcommitted
chore: add comments for syncing with docs
1 parent ab65a44 commit 7434875

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

duckduckgo_search.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ const puppeteer = require('puppeteer');
44
const expect = require('chai').expect;
55
(async () => {
66
const caps = {
7-
'browser': 'chrome',
8-
'browser_version': 'latest',
7+
'browser': 'chrome', // You can choose `chrome`, `edge` or `firefox` in this capability
8+
'browser_version': 'latest', // We support v83 and above. You can choose `latest`, `latest-beta`, `latest-1`, `latest-2` and so on, in this capability
99
'os': 'os x',
1010
'os_version': 'big sur',
1111
'build': 'puppeteer-build-1',
12-
'name': 'My first Puppeteer test',
12+
'name': 'My first Puppeteer test', // The name of your test and build. See browserstack.com/docs/automate/puppeteer/organize tests for more details
1313
'browserstack.username': process.env.BROWSERSTACK_USERNAME || 'YOUR_USERNAME',
1414
'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY || 'YOUR_ACCESS_KEY'
1515
};
1616
const browser = await puppeteer.connect({
1717
browserWSEndpoint:
18-
`wss://cdp.browserstack.com/puppeteer?caps=${encodeURIComponent(JSON.stringify(caps))}`,
18+
`wss://cdp.browserstack.com/puppeteer?caps=${encodeURIComponent(JSON.stringify(caps))}`, // The BrowserStack CDP endpoint gives you a `browser` instance based on the `caps` that you specified
1919
});
2020

2121
/*
22-
* BrowserStack specific code ends here
22+
* The BrowserStack specific code ends here. Following this line is your test script.
23+
* Here, we have a simple script that opens google.com, searches for the word BrowserStack and asserts the result.
2324
*/
2425
const page = await browser.newPage();
2526
await page.goto('https://www.duckduckgo.com');
@@ -36,5 +37,5 @@ const expect = require('chai').expect;
3637
} catch {
3738
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'failed',reason: 'Title did not match'}})}`);
3839
}
39-
await browser.close();
40+
await browser.close(); // At the end of each of your tests, you must close the browser so that BrowserStack knows when to end the session.
4041
})();

parallel_test.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ const main = async (cap) => {
77
cap['browserstack.accessKey'] = process.env.BROWSERSTACK_ACCESS_KEY || 'YOUR_ACCESS_KEY';
88

99
const browser = await puppeteer.connect({
10-
browserWSEndpoint:`wss://cdp.browserstack.com/puppeteer?caps=${encodeURIComponent(JSON.stringify(cap))}`,
10+
browserWSEndpoint:`wss://cdp.browserstack.com/puppeteer?caps=${encodeURIComponent(JSON.stringify(cap))}`, // The BrowserStack CDP endpoint gives you a `browser` instance based on the `caps` that you specified
1111
});
12-
12+
/*
13+
* The BrowserStack specific code ends here. Following this line is your test script.
14+
* Here, we have a simple script that opens google.com, searches for the word BrowserStack and asserts the result.
15+
*/
1316
const page = await browser.newPage();
1417
await page.goto('https://www.duckduckgo.com');
1518
const element = await page.$('[name="q"]');
@@ -32,23 +35,23 @@ const main = async (cap) => {
3235
const capabilities = [
3336
{
3437
'browser': 'chrome',
35-
'browser_version': 'latest',
38+
'browser_version': 'latest', // We support chrome v72 and above. You can choose `latest`, `latest-beta`, `latest-1`, `latest-2` and so on, in this capability
3639
'os': 'osx',
3740
'os_version': 'catalina',
38-
'name': 'Chrome latest on Catalina',
41+
'name': 'Chrome latest on Catalina', // The name of your test and build. See browserstack.com/docs/automate/puppeteer/organize-tests for more details
3942
'build': 'puppeteer-build-2'
4043
},
4144
{
4245
'browser': 'firefox',
43-
'browser_version': 'latest',
46+
'browser_version': 'latest', // We support firefox v86 and above. You can choose `latest`, `latest-beta`, `latest-1`, `latest-2` and so on, in this capability
4447
'os': 'osx',
4548
'os_version': 'catalina',
4649
'name': 'Firefox latest on Catalina',
4750
'build': 'puppeteer-build-2'
4851
},
4952
{
5053
'browser': 'edge',
51-
'browser_version': 'latest',
54+
'browser_version': 'latest', // We support edge v80 and above. You can choose `latest`, `latest-beta`, `latest-1`, `latest-2` and so on, in this capability
5255
'os': 'osx',
5356
'os_version': 'catalina',
5457
'name': 'Edge latest on Catalina',
@@ -79,7 +82,7 @@ const capabilities = [
7982
'build': 'puppeteer-build-2'
8083
}]
8184

82-
// The following code loops through the capabilities array defined above and runs your code against each environment that you have specified
85+
// The following code loops through the capabilities array defined above and runs your code against each environment that you have specified in parallel
8386
capabilities.forEach(async (cap) => {
8487
await main(cap);
8588
});

0 commit comments

Comments
 (0)