Skip to content

Commit ffbf252

Browse files
committed
Adding fixes to service test.
1 parent cb1d4be commit ffbf252

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

examples/javascript/test/drivers/service.spec.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
const fs = require('fs');
2+
const os = require('os');
3+
const path = require('path');
14
const Chrome = require('selenium-webdriver/chrome');
25
const {Browser, Builder} = require("selenium-webdriver");
36
const {getBinaryPaths} = require("selenium-webdriver/common/driverFinder");
4-
const options = new Chrome.Options();
57

68
describe('Service Test', function () {
79
it('Default service', async function () {
@@ -26,7 +28,10 @@ describe('Service Test', function () {
2628
let browserPath = paths.browserPath;
2729

2830
options.setChromeBinaryPath(browserPath)
29-
options.addArguments('--enable-logging', '--v=1');
31+
const userDataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'chrome-profile-'));
32+
options.addArguments(`--user-data-dir=${userDataDir}`);
33+
options.addArguments('--no-sandbox');
34+
options.addArguments('--disable-dev-shm-usage');
3035

3136
let service = new Chrome.ServiceBuilder(driverPath)
3237

@@ -38,6 +43,8 @@ describe('Service Test', function () {
3843

3944
await driver.get('https://www.selenium.dev/selenium/web/blank.html');
4045
await driver.quit();
46+
// 👉 Cleanup user data dir
47+
fs.rmSync(userDataDir, { recursive: true, force: true });
4148
});
4249

4350
it('Set port', async function () {

0 commit comments

Comments
 (0)