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

This file was deleted.

4 changes: 2 additions & 2 deletions flutter-finder/wdio-flutter-by-service/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 flutter-finder/wdio-flutter-by-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wdio-flutter-by-service",
"version": "1.2.0",
"version": "1.3.0",
"description": "",
"scripts": {
"build": "rimraf build && tsc -b"
Expand Down
3 changes: 2 additions & 1 deletion flutter-finder/wdio-flutter-by-service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ declare global {
// @ts-ignore
type Locator = {
using: string;
value: string;
value?: string;
selector?: any;
};

// @ts-ignore
Expand Down
19 changes: 17 additions & 2 deletions flutter-finder/wdio-flutter-by-service/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function flutterLongPress(
export async function flutterScrollTillVisible(
this: WebdriverIO.Browser,
options: {
finder: WebdriverIO.Element;
finder: WebdriverIO.Element | Flutter.Locator;
scrollView?: WebdriverIO.Element;
scrollDirection?: 'up' | 'right' | 'down' | 'left';
delta?: number;
Expand All @@ -61,8 +61,23 @@ export async function flutterScrollTillVisible(
dragDuration?: number;
},
): Promise<WebdriverIO.Element | null> {
// Convert the finder to the proper format for the server
let finderForServer;
if (options.finder && typeof options.finder === 'object' && 'using' in options.finder) {
// It's a locator object (like from flutterByDescendant)
finderForServer = options.finder;
} else {
// It's an element, extract the locator
finderForServer = options.finder;
}

const serverOptions = {
...options,
finder: finderForServer,
};

const response = await browser.executeScript('flutter: scrollTillVisible', [
options,
serverOptions,
]);
return await w3cElementToWdioElement(this, response);
}
Expand Down
17 changes: 13 additions & 4 deletions flutter-finder/wdio-flutter-by-service/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,19 @@ export function registerLocators(locatorConfig: Array<LocatorConfig>) {
registerCustomMethod(
`${methodName}`,
(value: any) => {
return {
using: config.stategy,
value: typeof value !== 'string' ? JSON.stringify(value) : value,
};
// For complex finders (descendant, ancestor), use 'selector' property
// For simple finders, use 'value' property
if (config.name === 'flutterByDescendant' || config.name === 'flutterByAncestor') {
return {
using: config.stategy,
selector: typeof value !== 'string' ? value : JSON.parse(value),
};
} else {
return {
using: config.stategy,
value: typeof value !== 'string' ? JSON.stringify(value) : value,
};
}
},
{
attachToBrowser: true,
Expand Down
2 changes: 1 addition & 1 deletion test/specs/test.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('My Login application', () => {
expect(await childElement.getText()).toEqual('Child 2');
});

it.skip('Scroll until visible with Descendant', async () => {
it('Scroll until visible with Descendant', async () => {
await performLogin();
await openScreen('Nested Scroll');
const childElement = await browser.flutterScrollTillVisible({
Expand Down