Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": [
"packages/*"
],
"version": "8.47.0",
"version": "8.47.1",
"command": {
"bootstrap": {
"npmClientArgs": [
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/wdio-browserstack-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wdio/browserstack-service",
"version": "8.47.0",
"version": "8.47.1",
"description": "WebdriverIO service for better Browserstack integration",
"author": "Adam Bjerstedt <abjerstedt@gmail.com>",
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-browserstack-service",
Expand Down
3 changes: 2 additions & 1 deletion packages/wdio-browserstack-service/src/cli/cliUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ export class CLIUtils {
sdk_language: this.getSdkLanguage(),
}
if (!isNullOrEmpty(existingCliPath)) {
queryParams.cli_version = await this.runShellCommand(`${existingCliPath} version`)
const nullDevice = platform() === 'win32' ? 'NUL' : '/dev/null'
queryParams.cli_version = await this.runShellCommand(`${existingCliPath} version 2>${nullDevice}`)
}
const response = await this.requestToUpdateCLI(queryParams, config)
if (nestedKeyValue(response, ['updated_cli_version'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default class AccessibilityModule extends BaseModule {
static MODULE_NAME = 'AccessibilityModule'
accessibilityMap: Map<number, boolean>
LOG_DISABLED_SHOWN: Map<number, boolean>
centralAuthA11yConfig: Record<string, unknown> = {}
centralAuthConfigFetched: boolean = false

constructor(accessibilityConfig: Accessibility, isNonBstackA11y: boolean) {
super()
Expand Down Expand Up @@ -245,7 +247,7 @@ export default class AccessibilityModule extends BaseModule {
'thBuildUuid': process.env.BROWSERSTACK_TESTHUB_UUID,
'thJwtToken': process.env.BROWSERSTACK_TESTHUB_JWT
}
const driverExecuteParams = await this.getDriverExecuteParams()
const driverExecuteParams = await this.getDriverExecuteParams('saveResults')
dataForExtension = { ...dataForExtension, ...driverExecuteParams }

// final scan and saving the results
Expand Down Expand Up @@ -307,13 +309,26 @@ export default class AccessibilityModule extends BaseModule {
PERFORMANCE_SDK_EVENTS.A11Y_EVENTS.PERFORM_SCAN,
async () => {
try {
// Fetch central auth accessibility configuration
const centralAuthConfig = await this.fetchCentralAuthA11yConfig('scan')
if (!this.accessibility) {
this.logger.debug('Not an Accessibility Automation session.')
return
}
if (this.isAppAccessibility) {
// Get app accessibility params and merge with central auth config
const appAccessibilityParams = _getParamsForAppAccessibility(commandName)

// Merge with central auth config
const mergedParams: Record<string, any> = { ...appAccessibilityParams, ...centralAuthConfig }

// Use centralAuthToken if available
if (centralAuthConfig.centralAuthToken) {
// Set the auth header with the token value
mergedParams.centralAuthHeader = centralAuthConfig.centralAuthToken
}
const results: unknown = await (browser as WebdriverIO.Browser).execute(
formatString(this.scriptInstance.performScan, JSON.stringify(_getParamsForAppAccessibility(commandName))) as string,
formatString(this.scriptInstance.performScan, JSON.stringify(mergedParams)) as string,
{}
)
BStackLogger.debug(util.format(results as string))
Expand Down Expand Up @@ -399,10 +414,10 @@ export default class AccessibilityModule extends BaseModule {
)()
}

async getDriverExecuteParams() {
async getDriverExecuteParams(scriptName: string) {
const payload: Omit<FetchDriverExecuteParamsEventRequest, 'binSessionId'> = {
product: 'accessibility',
scriptName: 'saveResults'
scriptName: scriptName
}
const response: FetchDriverExecuteParamsEventResponse = await GrpcClient.getInstance().fetchDriverExecuteParamsEvent(payload)
if (response.success) {
Expand All @@ -412,4 +427,25 @@ export default class AccessibilityModule extends BaseModule {
return {}
}

/**
* Fetch central auth accessibility configuration for the given script name.
* Returns cached config if already fetched, otherwise loads and caches it.
*
* @param scriptName - Name of the script to fetch config for
* @returns Configuration object, empty object if error occurs
*/
async fetchCentralAuthA11yConfig(scriptName: string): Promise<Record<string, unknown>> {
try {
if (this.centralAuthConfigFetched) {
return this.centralAuthA11yConfig
}
this.centralAuthA11yConfig = await this.getDriverExecuteParams(scriptName)
this.centralAuthConfigFetched = true
return this.centralAuthA11yConfig
} catch (error) {
this.logger.error(`fetchCentralAuthA11yConfig: Failed to fetch driver execute params for ${scriptName}: ${util.format(error)}`)
return {}
}
}

}
Loading