Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e5e838c

Browse files
add test driven section
1 parent 6eb8b87 commit e5e838c

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
const puppeteer = require('puppeteer')
3+
const delaySecond = async (time) => await new Promise(res => setTimeout(res, 1000 * time));
4+
5+
describe('Open the website in Chrome, FireFox and Chrome-Edge', () => {
6+
test('Should open a website with FIREFOX', async () => {
7+
let FIREsettings = {
8+
headless: false,
9+
ignoreHTTPSErrors: true,
10+
acceptInsecureCerts: true,
11+
product: 'firefox',
12+
// executablePath:'/Applications/Firefox.app/Contents/MacOS/firefox',
13+
args: ['--proxy-bypass-list=*', '--disable-gpu', '--disable-dev-shm-usage', '--disable-setuid-sandbox', '--no-first-run', '--no-sandbox', '--no-zygote', '--single-process', '--ignore-certificate-errors', '--ignore-certificate-errors-spki-list', '--enable-features=NetworkService']
14+
}
15+
let browser = await puppeteer.launch(FIREsettings)
16+
let page = await browser.newPage()
17+
try {
18+
await page.goto("https://google.com")
19+
await page.screenshot({
20+
path: './Browsers/FIRE.png',
21+
fullPage: true
22+
})
23+
let img = await page.waitForSelector('#hplogo')
24+
}
25+
catch (error) {
26+
console.error(`FIRE`,error)
27+
}
28+
await delaySecond(100)
29+
await browser.close();
30+
31+
})
32+
})
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* This script should go to style
3+
*/
4+
const puppeteer = require('puppeteer')
5+
const iPhone = puppeteer.devices['iPhone 8'];
6+
7+
let settings = {
8+
9+
timeout: 0,
10+
headless: true,
11+
devtools: false,
12+
13+
defaultViewport: {
14+
width: 1080,
15+
height: 800,
16+
deviceScaleFactor: 1,
17+
}
18+
};
19+
20+
(async () => {
21+
const browser = await puppeteer.launch(settings)
22+
const page = await browser.newPage()
23+
await page.emulate(iPhone)
24+
await page.goto('https://google.com/')
25+
await page.screenshot({
26+
path: './iphone/iphone-6.png',
27+
fullPage: true
28+
})
29+
console.log(await page.title())
30+
await browser.close()
31+
})()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "bootstrap-tests",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "jest"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"jest": "^26.1.0",
14+
"mocha": "^8.0.1",
15+
"puppeteer": "^5.2.1",
16+
"puppeteer-core": "^5.2.1"
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
let settings = {
2+
timeout: 0,
3+
headless: false,
4+
devtools: false,
5+
6+
// Open with Chrome Browser
7+
// executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
8+
// userDataDir: '/Users/user/Library/Application Support/Google/Chrome/Profile 4/',
9+
10+
defaultViewport: {
11+
width: 1080,
12+
height: 800,
13+
deviceScaleFactor: 1,
14+
}
15+
};
16+
17+
exports.default = settings;
18+
exports.settings = settings;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /