Skip to content
Merged
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
10 changes: 7 additions & 3 deletions src/commands/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import type { AppiumFlutterDriver } from '../driver';

export const ELEMENT_CACHE = new Map();

function constructFindElementPayload(
export function constructFindElementPayload(
strategy: string,
selector: string,
context: string,
proxyDriver: XCUITestDriver | AndroidUiautomator2Driver | Mac2Driver,
context?: any,
proxyDriver?: XCUITestDriver | AndroidUiautomator2Driver | Mac2Driver,
) {
if (!strategy || !selector) {
return undefined;
}
const isFlutterLocator =
strategy.startsWith('-flutter') || FLUTTER_LOCATORS.includes(strategy);

Expand All @@ -31,6 +34,7 @@ function constructFindElementPayload(
// If user is looking for Native IOS/Mac locator
if (
!isFlutterLocator &&
proxyDriver &&
(proxyDriver instanceof XCUITestDriver ||
proxyDriver instanceof Mac2Driver)
) {
Expand Down
21 changes: 17 additions & 4 deletions src/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
clear,
ELEMENT_CACHE,
getElementRect,
constructFindElementPayload,
} from './commands/element';
import {
attachAppLaunchArguments,
Expand Down Expand Up @@ -362,7 +363,10 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
'POST',
{
element,
locator,
locator: constructFindElementPayload(
locator?.using,
locator?.value,
),
timeout,
},
);
Expand All @@ -378,7 +382,10 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
'POST',
{
element,
locator,
locator: constructFindElementPayload(
locator?.using,
locator?.value,
),
timeout,
},
);
Expand All @@ -391,7 +398,10 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
{
origin,
offset,
locator,
locator: constructFindElementPayload(
locator?.using,
locator?.value,
),
},
);
}
Expand Down Expand Up @@ -420,7 +430,10 @@ export class AppiumFlutterDriver extends BaseDriver<FlutterDriverConstraints> {
`/session/:sessionId/appium/gestures/scroll_till_visible`,
'POST',
{
finder,
finder: constructFindElementPayload(
finder.using || finder.strategy,
finder.value || finder.selector,
),
scrollView,
delta,
maxScrolls,
Expand Down
Loading