Skip to content

Commit 236fc71

Browse files
asambstackfrancisf
authored andcommitted
chore: use duckduckgo instead of google search
1 parent ecf2f49 commit 236fc71

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ You need BrowserStack credentials to be able to run Puppeteer tests. You have to
1717

1818
1. Clone this repository
1919
2. Install the dependencies using `npm install`
20-
3. Replace `YOUR_USERNAME` and `YOUR_ACCESS_KEY` in `google_search.js` with your BrowserStack credentials
21-
3. Run the sample script using `node google_search.js`
20+
3. Replace `YOUR_USERNAME` and `YOUR_ACCESS_KEY` in `duckduckgo_search.js` with your BrowserStack credentials
21+
3. Run the sample script using `node duckduckgo_search.js`
2222

2323
## Test across multiple browser and OS versions in parallel
2424

google_search.js renamed to duckduckgo_search.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ const expect = require('chai').expect;
2222
* BrowserStack specific code ends here
2323
*/
2424
const page = await browser.newPage();
25-
await page.goto('https://www.google.com/ncr');
26-
const element = await page.$('[aria-label="Search"]');
25+
await page.goto('https://www.duckduckgo.com');
26+
const element = await page.$('[name="q"]');
2727
await element.click();
2828
await element.type('BrowserStack');
29-
await element.press('Enter');
29+
await Promise.all([element.press('Enter'), page.waitForNavigation()]);
3030
const title = await page.title('');
3131
console.log(title);
3232
try {
33-
expect(title).to.equal("BrowserStack - Google Search", 'Expected page title is incorrect!');
33+
expect(title).to.equal("BrowserStack at DuckDuckGo", 'Expected page title is incorrect!');
3434
// following line of code is responsible for marking the status of the test on BrowserStack as 'passed'. You can use this code in your after hook after each test
3535
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Title matched'}})}`);
3636
} catch {

google_search_with_proxy.js renamed to duckduckgo_search_with_proxy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ bootstrap();
2929
* BrowserStack specific code ends here
3030
*/
3131
const page = await browser.newPage();
32-
await page.goto('https://www.google.com/ncr');
33-
const element = await page.$('[aria-label="Search"]');
32+
await page.goto('https://www.duckduckgo.com');
33+
const element = await page.$('[name="q"]');
3434
await element.click();
3535
await element.type('BrowserStack');
36-
await element.press('Enter');
36+
await Promise.all([element.press('Enter'), page.waitForNavigation()]);
3737
const title = await page.title('');
3838
console.log(title);
3939
try {
40-
expect(title).to.equal("BrowserStack - Google Search", 'Expected page title is incorrect!');
40+
expect(title).to.equal("BrowserStack at DuckDuckGo", 'Expected page title is incorrect!');
4141
// following line of code is responsible for marking the status of the test on BrowserStack as 'passed'. You can use this code in your after hook after each test
4242
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Title matched'}})}`);
4343
} catch {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"scripts": {
99
"test": "npm run single && npm run local && npm run parallel",
10-
"single": "node google_search.js",
10+
"single": "node duckduckgo_search.js",
1111
"local": "node local_test_using_bindings.js",
1212
"parallel": "node parallel_test.js",
1313
"session_details": "node sample_session_details_API.js"

parallel_test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ const main = async (cap) => {
1111
});
1212

1313
const page = await browser.newPage();
14-
await page.goto('https://www.google.com/ncr');
15-
const element = await page.$('[aria-label="Search"]');
14+
await page.goto('https://www.duckduckgo.com');
15+
const element = await page.$('[name="q"]');
1616
await element.click();
1717
await element.type('BrowserStack');
18-
await element.press('Enter');
18+
await Promise.all([element.press('Enter'), page.waitForNavigation()]);
1919
const title = await page.title('');
2020
console.log(title);
2121
try {
22-
expect(title).to.equal("BrowserStack - Google Search", 'Expected page title is incorrect!');
22+
expect(title).to.equal("BrowserStack at DuckDuckGo", 'Expected page title is incorrect!');
2323
// following line of code is responsible for marking the status of the test on BrowserStack as 'passed'. You can use this code in your after hook after each test
2424
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Title matched'}})}`);
2525
} catch {

puppeteer-jest/google.test.js renamed to puppeteer-jest/duckduckgo.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
const { Browser } = require("puppeteer");
44

5-
describe("Google", () => {
5+
describe("DuckDuckGo", () => {
66
beforeAll(async () => {
7-
await page.goto('https://google.com')
7+
await page.goto('https://www.duckduckgo.com')
88
})
9-
it('title should match BrowserStack - Google Search', async () => {
10-
const element = await page.$('[aria-label="Search"]');
9+
it('title should match BrowserStack at DuckDuckGo', async () => {
10+
const element = await page.$('[name="q"]');
1111
await element.click();
1212
await element.type('BrowserStack');
13-
await element.press('Enter');
13+
await Promise.all([element.press('Enter'), page.waitForNavigation()]);
1414
try {
15-
expect(await page.title()).toBe('BrowserStack - Google Search');
15+
expect(await page.title()).toBe('BrowserStack at DuckDuckGo');
1616
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Test assertion passed'}})}`);
1717
} catch {
1818
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'failed',reason: 'Test assertion failed'}})}`);

sample_session_details_API.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ const expect = require('chai').expect;
2222
* BrowserStack specific code ends here
2323
*/
2424
const page = await browser.newPage();
25-
await page.goto('https://www.google.com/ncr');
26-
const element = await page.$('[aria-label="Search"]');
25+
await page.goto('https://www.duckduckgo.com');
26+
const element = await page.$('[name="q"]');
2727
await element.click();
2828
await element.type('BrowserStack');
29-
await element.press('Enter');
29+
await Promise.all([element.press('Enter'), page.waitForNavigation()]);
3030
const title = await page.title('');
3131
console.log(title);
3232
try {
33-
expect(title).to.equal("BrowserStack - Google Search", 'Expected page title is incorrect!');
33+
expect(title).to.equal("BrowserStack at DuckDuckGo", 'Expected page title is incorrect!');
3434
// following line of code is responsible for marking the status of the test on BrowserStack as 'passed'. You can use this code in your after hook after each test
3535
await page.evaluate(_ => {}, `browserstack_executor: ${JSON.stringify({action: 'setSessionStatus',arguments: {status: 'passed',reason: 'Title matched'}})}`);
3636
} catch {

0 commit comments

Comments
 (0)