Skip to content

Commit

Permalink
[javascript] Removing service parameter from getPath
Browse files Browse the repository at this point in the history
Not used anymore.

Adjusting tests to use SM.
  • Loading branch information
diemol committed Jul 21, 2023
1 parent ecd6d6b commit 1c72078
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/chromium.js
Expand Up @@ -686,7 +686,7 @@ class Driver extends webdriver.WebDriver {
} else {
let service = opt_serviceExecutor || this.getDefaultService()
if (!service.getExecutable()) {
service.setExecutable(getPath(service, caps))
service.setExecutable(getPath(caps))
}
onQuit = () => service.kill()
executor = createExecutor(service.start(), this.VENDOR_COMMAND_PREFIX)
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/common/driverFinder.js
Expand Up @@ -27,7 +27,7 @@ const { driverLocation } = require('./seleniumManager')
* Determines the path of the correct Selenium Manager binary
* @returns {string}
*/
function getPath(service, capabilities) {
function getPath(capabilities) {
try {
return driverLocation(capabilities)
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions javascript/node/selenium-webdriver/firefox.js
Expand Up @@ -588,14 +588,14 @@ class Driver extends webdriver.WebDriver {
configureExecutor(executor)
} else if (opt_executor instanceof remote.DriverService) {
if (!opt_executor.getExecutable()) {
opt_executor.setExecutable(getPath(opt_executor, opt_config))
opt_executor.setExecutable(getPath(opt_config))
}
executor = createExecutor(opt_executor.start())
onQuit = () => opt_executor.kill()
} else {
let service = new ServiceBuilder().build()
if (!service.getExecutable()) {
service.setExecutable(getPath(service, opt_config))
service.setExecutable(getPath(opt_config))
}
executor = createExecutor(service.start())
onQuit = () => service.kill()
Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/ie.js
Expand Up @@ -455,7 +455,7 @@ class Driver extends webdriver.WebDriver {
service = createServiceFromCapabilities(options)
}
if (!service.getExecutable()) {
service.setExecutable(getPath(service, options))
service.setExecutable(getPath(options))
}

let client = service.start().then((url) => new http.HttpClient(url))
Expand Down
Expand Up @@ -35,7 +35,7 @@ test.suite(
it('can be started on a custom path', function () {
service = new chrome.ServiceBuilder().setPath('/foo/bar/baz').build()
if (!service.getExecutable()) {
service.setExecutable(getPath(service, new chrome.Options()))
service.setExecutable(getPath(new chrome.Options()))
}
return service.start().then(function (url) {
assert.ok(url.endsWith('/foo/bar/baz'), 'unexpected url: ' + url)
Expand Down
Expand Up @@ -35,7 +35,7 @@ test.suite(

it('can start msedgedriver', async function () {
service = new edge.ServiceBuilder().build()
service.setExecutable(getPath(service, new edge.Options()))
service.setExecutable(getPath(new edge.Options()))
let url = await service.start()
assert(/127\.0\.0\.1/.test(url), `unexpected url: ${url}`)
})
Expand Down
16 changes: 9 additions & 7 deletions javascript/node/selenium-webdriver/testing/index.js
Expand Up @@ -41,6 +41,7 @@ const remote = require('../remote')
const safari = require('../safari')
const { Browser } = require('../lib/capabilities')
const { Builder } = require('../index')
const { getPath } = require('../common/driverFinder')

/**
* Describes a browser targeted by a {@linkplain suite test suite}.
Expand Down Expand Up @@ -116,20 +117,21 @@ function getBrowsersToTestFromEnv() {
function getAvailableBrowsers() {
info(`Searching for WebDriver executables installed on the current system...`)

getPath(safari.Options)
let targets = [
[chrome.locateSynchronously, Browser.CHROME],
[edge.locateSynchronously, Browser.EDGE],
[firefox.locateSynchronously, Browser.FIREFOX],
[ie.locateSynchronously, Browser.INTERNET_EXPLORER],
[safari.locateSynchronously, Browser.SAFARI],
[getPath(chrome.Options), Browser.CHROME],
[getPath(edge.Options), Browser.EDGE],
[getPath(firefox.Options), Browser.FIREFOX],
[getPath(ie.Options), Browser.INTERNET_EXPLORER],
[getPath(safari.Options), Browser.SAFARI],
]

let availableBrowsers = []
for (let pair of targets) {
const fn = pair[0]
const driverPath = pair[0]
const name = pair[1]
const capabilities = pair[2]
if (fn()) {
if (driverPath.length > 0) {
info(`... located ${name}`)
availableBrowsers.push({ name, capabilities })
}
Expand Down

0 comments on commit 1c72078

Please sign in to comment.