File tree Expand file tree Collapse file tree
flutter-finder/wdio-flutter-by-service/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,7 +141,8 @@ declare global {
141141 // @ts -ignore
142142 type Locator = {
143143 using : string ;
144- value : string ;
144+ value ?: string ;
145+ selector ?: any ;
145146 } ;
146147
147148 // @ts -ignore
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export async function flutterLongPress(
5252export async function flutterScrollTillVisible (
5353 this : WebdriverIO . Browser ,
5454 options : {
55- finder : WebdriverIO . Element ;
55+ finder : WebdriverIO . Element | Flutter . Locator ;
5656 scrollView ?: WebdriverIO . Element ;
5757 scrollDirection ?: 'up' | 'right' | 'down' | 'left' ;
5858 delta ?: number ;
@@ -61,8 +61,23 @@ export async function flutterScrollTillVisible(
6161 dragDuration ?: number ;
6262 } ,
6363) : Promise < WebdriverIO . Element | null > {
64+ // Convert the finder to the proper format for the server
65+ let finderForServer ;
66+ if ( options . finder && typeof options . finder === 'object' && 'using' in options . finder ) {
67+ // It's a locator object (like from flutterByDescendant)
68+ finderForServer = options . finder ;
69+ } else {
70+ // It's an element, extract the locator
71+ finderForServer = options . finder ;
72+ }
73+
74+ const serverOptions = {
75+ ...options ,
76+ finder : finderForServer ,
77+ } ;
78+
6479 const response = await browser . executeScript ( 'flutter: scrollTillVisible' , [
65- options ,
80+ serverOptions ,
6681 ] ) ;
6782 return await w3cElementToWdioElement ( this , response ) ;
6883}
Original file line number Diff line number Diff line change @@ -121,10 +121,19 @@ export function registerLocators(locatorConfig: Array<LocatorConfig>) {
121121 registerCustomMethod (
122122 `${ methodName } ` ,
123123 ( value : any ) => {
124- return {
125- using : config . stategy ,
126- value : typeof value !== 'string' ? JSON . stringify ( value ) : value ,
127- } ;
124+ // For complex finders (descendant, ancestor), use 'selector' property
125+ // For simple finders, use 'value' property
126+ if ( config . name === 'flutterByDescendant' || config . name === 'flutterByAncestor' ) {
127+ return {
128+ using : config . stategy ,
129+ selector : typeof value !== 'string' ? value : JSON . parse ( value ) ,
130+ } ;
131+ } else {
132+ return {
133+ using : config . stategy ,
134+ value : typeof value !== 'string' ? JSON . stringify ( value ) : value ,
135+ } ;
136+ }
128137 } ,
129138 {
130139 attachToBrowser : true ,
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ describe('My Login application', () => {
127127 expect ( await childElement . getText ( ) ) . toEqual ( 'Child 2' ) ;
128128 } ) ;
129129
130- it . skip ( 'Scroll until visible with Descendant' , async ( ) => {
130+ it ( 'Scroll until visible with Descendant' , async ( ) => {
131131 await performLogin ( ) ;
132132 await openScreen ( 'Nested Scroll' ) ;
133133 const childElement = await browser . flutterScrollTillVisible ( {
You can’t perform that action at this time.
0 commit comments