Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import {
import accessibilityScripts from './scripts/accessibility-scripts.js'
import PerformanceTester from './instrumentation/performance/performance-tester.js'
import * as PERFORMANCE_SDK_EVENTS from './instrumentation/performance/constants.js'
import { ACCESSIBILITY_WRAP_EXCLUDED_COMMANDS } from './constants.js'

import { BStackLogger } from './bstackLogger.js'

Expand Down Expand Up @@ -254,6 +255,10 @@ class _AccessibilityHandler {

accessibilityScripts.commandsToWrap
.filter((command) => command.name && command.class)
// Skip synchronous chainable commands (e.g. `action`) — the async
// wrapper would turn their return value into a Promise and break
// chaining. See SDK-6265.
.filter((command) => !ACCESSIBILITY_WRAP_EXCLUDED_COMMANDS.includes(command.name))
.forEach((command) => {
const browser = this._browser as WebdriverIO.Browser
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { Command } from '../../scripts/accessibility-scripts.js'
import accessibilityScripts from '../../scripts/accessibility-scripts.js'
import { _getParamsForAppAccessibility, formatString, getAppA11yResults, getAppA11yResultsSummary, shouldScanTestForAccessibility, validateCapsWithA11y, validateCapsWithAppA11y, isBrowserstackSession } from '../../util.js'
import { AutomationFrameworkConstants } from '../frameworks/constants/automationFrameworkConstants.js'
import { ACCESSIBILITY_WRAP_EXCLUDED_COMMANDS } from '../../constants.js'
import util from 'node:util'
import type { Accessibility } from '@browserstack/wdio-browserstack-service'
import PerformanceTester from '../../instrumentation/performance/performance-tester.js'
Expand Down Expand Up @@ -138,6 +139,10 @@ export default class AccessibilityModule extends BaseModule {
if (this.scriptInstance.commandsToWrap && this.scriptInstance.commandsToWrap.length > 0) {
this.scriptInstance.commandsToWrap
.filter((command) => command.name && command.class)
// Skip synchronous chainable commands (e.g. `action`) — the async
// wrapper would turn their return value into a Promise and break
// chaining. See SDK-6265.
.filter((command) => !ACCESSIBILITY_WRAP_EXCLUDED_COMMANDS.includes(command.name))
.forEach((command) => {
browser.overwriteCommand(
// @ts-expect-error fix type
Expand Down
10 changes: 10 additions & 0 deletions packages/wdio-browserstack-service/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ export const PERCY_DOM_CHANGING_COMMANDS_ENDPOINTS = [
'/session/:sessionId/appium/device/shake'
]

/**
* Commands that synchronously return a chainable builder (rather than a Promise)
* and therefore must NOT be wrapped by the accessibility command wrapper. The
* wrapper is async, so wrapping a synchronous command converts its return value
* into a Promise and breaks chaining (e.g. `browser.action('pointer').move(...)`
* fails with "move is not a function" because `action` now resolves to a Promise).
* See SDK-6265.
*/
export const ACCESSIBILITY_WRAP_EXCLUDED_COMMANDS = ['action']

export const CAPTURE_MODES = ['click', 'auto', 'screenshot', 'manual', 'testcase']
export const LOG_KIND_USAGE_MAP = {
'TEST_LOG': 'log',
Expand Down
Loading