Skip to content

Commit

Permalink
[js] fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Sep 16, 2023
1 parent da4eaa1 commit 34e03ad
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 25 deletions.
7 changes: 6 additions & 1 deletion javascript/node/selenium-webdriver/chrome.js
Expand Up @@ -221,7 +221,12 @@ class Driver extends chromium.Driver {
static createSession(opt_config, opt_serviceExecutor) {
let caps = opt_config || new Options()
return /** @type {!Driver} */ (
super.createSession(caps, opt_serviceExecutor, 'goog', CHROME_CAPABILITY_KEY)
super.createSession(
caps,
opt_serviceExecutor,
'goog',
CHROME_CAPABILITY_KEY
)
)
}

Expand Down
12 changes: 8 additions & 4 deletions javascript/node/selenium-webdriver/chromium.js
Expand Up @@ -679,8 +679,12 @@ class Driver extends webdriver.WebDriver {
* @param vendorCapabilityKey Either 'goog:chromeOptions' or 'ms:edgeOptions'
* @return {!Driver} A new driver instance.
*/
static createSession(caps, opt_serviceExecutor,
vendorPrefix = '', vendorCapabilityKey = '') {
static createSession(
caps,
opt_serviceExecutor,
vendorPrefix = '',
vendorCapabilityKey = ''
) {
let executor
let onQuit
if (opt_serviceExecutor instanceof http.Executor) {
Expand All @@ -689,14 +693,14 @@ class Driver extends webdriver.WebDriver {
} else {
let service = opt_serviceExecutor || this.getDefaultService()
if (!service.getExecutable()) {
const {driverPath, browserPath} = getPath(caps)
const { driverPath, browserPath } = getPath(caps)
service.setExecutable(driverPath)
const vendorOptions = caps.get(vendorCapabilityKey)
if (vendorOptions) {
vendorOptions['binary'] = browserPath
caps.set(vendorCapabilityKey, vendorOptions)
} else {
caps.set(vendorCapabilityKey, {binary: browserPath})
caps.set(vendorCapabilityKey, { binary: browserPath })
}
}
onQuit = () => service.kill()
Expand Down
22 changes: 10 additions & 12 deletions javascript/node/selenium-webdriver/common/seleniumManager.js
Expand Up @@ -27,7 +27,7 @@ const fs = require('fs')
const spawnSync = require('child_process').spawnSync
const { Capability } = require('../lib/capabilities')

let debugMessagePrinted = false;
let debugMessagePrinted = false

/**
* Determines the path of the correct Selenium Manager binary
Expand All @@ -49,12 +49,12 @@ function getBinary() {
const filePath = path.join(seleniumManagerBasePath, directory, file)

if (!fs.existsSync(filePath)) {
throw new Error(`Unable to obtain Selenium Manager`)
throw new Error(`Unable to obtain Selenium Manager at ${filePath}`)
}

if (!debugMessagePrinted) {
console.debug(`Selenium Manager binary found at ${filePath}`)
debugMessagePrinted = true; // Set the flag to true after printing the debug message
debugMessagePrinted = true // Set the flag to true after printing the debug message
}

return filePath
Expand Down Expand Up @@ -82,19 +82,17 @@ function driverLocation(options) {
args.push('--browser-path', path.resolve(vendorOptions.binary))
}

const proxyOptions = options.getProxy();
const proxyOptions = options.getProxy()

// Check if proxyOptions exists and has properties
if (proxyOptions && Object.keys(proxyOptions).length > 0) {
const httpProxy = proxyOptions['httpProxy'];
const sslProxy = proxyOptions['sslProxy'];
const httpProxy = proxyOptions['httpProxy']
const sslProxy = proxyOptions['sslProxy']

if (httpProxy !== undefined) {
args.push('--proxy', httpProxy);
}

else if (sslProxy !== undefined) {
args.push('--proxy', sslProxy);
args.push('--proxy', httpProxy)
} else if (sslProxy !== undefined) {
args.push('--proxy', sslProxy)
}
}

Expand Down Expand Up @@ -139,7 +137,7 @@ function driverLocation(options) {
}
}

function logOutput (output) {
function logOutput(output) {
for (const key in output.logs) {
if (output.logs[key].level === 'WARN') {
console.warn(`${output.logs[key].message}`)
Expand Down
6 changes: 3 additions & 3 deletions javascript/node/selenium-webdriver/firefox.js
Expand Up @@ -591,7 +591,7 @@ class Driver extends webdriver.WebDriver {
configureExecutor(executor)
} else if (opt_executor instanceof remote.DriverService) {
if (!opt_executor.getExecutable()) {
const {driverPath, browserPath} = getPath(caps)
const { driverPath, browserPath } = getPath(caps)
opt_executor.setExecutable(driverPath)
firefoxBrowserPath = browserPath
}
Expand All @@ -600,7 +600,7 @@ class Driver extends webdriver.WebDriver {
} else {
let service = new ServiceBuilder().build()
if (!service.getExecutable()) {
const {driverPath, browserPath} = getPath(caps)
const { driverPath, browserPath } = getPath(caps)
service.setExecutable(driverPath)
firefoxBrowserPath = browserPath
}
Expand All @@ -614,7 +614,7 @@ class Driver extends webdriver.WebDriver {
vendorOptions['binary'] = firefoxBrowserPath
caps.set(FIREFOX_CAPABILITY_KEY, vendorOptions)
} else {
caps.set(FIREFOX_CAPABILITY_KEY, {binary: firefoxBrowserPath})
caps.set(FIREFOX_CAPABILITY_KEY, { binary: firefoxBrowserPath })
}
}

Expand Down
6 changes: 5 additions & 1 deletion javascript/node/selenium-webdriver/lib/by.js
Expand Up @@ -396,7 +396,11 @@ class RelativeBy {
* strategy.
*/
function check(locator) {
if (locator instanceof By || locator instanceof RelativeBy || typeof locator === 'function') {
if (
locator instanceof By ||
locator instanceof RelativeBy ||
typeof locator === 'function'
) {
return locator
}

Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/lib/test/fileserver.js
Expand Up @@ -264,7 +264,7 @@ function handleUpload(request, response) {
.contentType('html')
.send(
files.join('\n') +
'\n<script>window.top.window.onUploadDone();</script>'
'\n<script>window.top.window.onUploadDone();</script>'
)
}
})
Expand Down
6 changes: 5 additions & 1 deletion javascript/node/selenium-webdriver/remote/util.js
Expand Up @@ -37,7 +37,11 @@ function getJavaPath() {
function isSelenium3x(seleniumStandalonePath) {
const javaPath = getJavaPath()

const execRes = cp.execFileSync(javaPath, ['-jar', seleniumStandalonePath, '--version'])
const execRes = cp.execFileSync(javaPath, [
'-jar',
seleniumStandalonePath,
'--version',
])

return execRes.toString().trim().startsWith('Selenium server version: 3')
}
Expand Down
4 changes: 2 additions & 2 deletions javascript/node/selenium-webdriver/test/upload_test.js
Expand Up @@ -29,7 +29,7 @@ const Pages = test.Pages
test.suite(function (env) {
var LOREM_IPSUM_TEXT = 'lorem ipsum dolor sit amet'
var FILE_HTML = '<!DOCTYPE html><div>' + LOREM_IPSUM_TEXT + '</div>'
var FILE_HTML_2 = '<!DOCTYPE html><div>' + "I love sausages too" + '</div>'
var FILE_HTML_2 = '<!DOCTYPE html><div>' + 'I love sausages too' + '</div>'

var _fp
before(function () {
Expand Down Expand Up @@ -109,7 +109,7 @@ test.suite(function (env) {

var frame = await driver.findElement(By.id('upload_target'))
await driver.switchTo().frame(frame)
const txt = await driver.findElement(By.css('body')).getText();
const txt = await driver.findElement(By.css('body')).getText()
assert.strictEqual(
txt,
fp.split('/').pop(),
Expand Down

0 comments on commit 34e03ad

Please sign in to comment.