Skip to content

Commit

Permalink
[js] Add service example (#1848)
Browse files Browse the repository at this point in the history
Co-authored-by: Sri Harsha <[email protected]>
  • Loading branch information
pujagani and harsha509 committed Aug 12, 2024
1 parent c94b5a5 commit 5ed0e4f
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions examples/javascript/test/drivers/service.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const Chrome = require('selenium-webdriver/chrome');
const {Browser, Builder} = require("selenium-webdriver");
const {getBinaryPaths} = require("selenium-webdriver/common/driverFinder");
const options = new Chrome.Options();

describe('Service Test', function () {
it('Default service', async function () {
let service = new Chrome.ServiceBuilder()

let driver = new Builder()
.forBrowser(Browser.CHROME)
.setChromeService(service)
.build();

await driver.get('https://www.selenium.dev/selenium/web/blank.html');
await driver.quit();
});

it('Set Driver Location', async function () {

let options = new Chrome.Options();
options.setBrowserVersion("stable")

let paths = getBinaryPaths(options)
let driverPath = paths.driverPath;
let browserPath = paths.browserPath;

options.setChromeBinaryPath(browserPath)

let service = new Chrome.ServiceBuilder().setPath(driverPath)

let driver = new Builder()
.forBrowser(Browser.CHROME)
.setChromeOptions(options)
.setChromeService(service)
.build();

await driver.get('https://www.selenium.dev/selenium/web/blank.html');
await driver.quit();
});

it('Set port', async function () {
let service = new Chrome.ServiceBuilder().setPort(1234)

let driver = new Builder()
.forBrowser(Browser.CHROME)
.setChromeService(service)
.build();

await driver.get('https://www.selenium.dev/selenium/web/blank.html');
await driver.quit();
});
});

0 comments on commit 5ed0e4f

Please sign in to comment.