Skip to content

[🐛 Bug]: waitforInterval and waitforTimeout not applied to browser returned by attach #14715

@Sleepytt1210

Description

@Sleepytt1210

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.19.1

Node.js Version

20.19.4

Mode

Standalone Mode

Which capabilities are you using?

What happened?

When using browser returned by the attach module, the waitforTimeout and waitforInterval options are always undefined unless manually specified in waitfor* functions's options.

    const driver = await attach({ 
       sessionId,
       capabilities: {
       },
       options: {
           port: 4723,
           waitforTimeout: 3_000,
           waitforInterval: 500,
       }
    });
    await driver.$('android.widget.Button').waitForDisplay() // Failed immediately, `timeout` and `interval` passed to the Timer is undefined.

What is your expected behavior?

The waitforTimeout and waitforInterval passed to the AttachOptions.options should be applied to the browser's top-level options. Instead of staying inside options.options. Even better if default values are provided (validateConfig is also not called when using attach).

How to reproduce the bug.

To reproduce the bug, first create a file with the following code:

async function start() {
    const opts = {
		port: 4723,
		capabilities: {
			platformName: "Android",
			"appium:automationName": "UiAutomator2",
			"appium:deviceName": "avd1",
			"appium:platformVersion": "11.0",
			"appium:noReset": true,
		},
	};

    const driver = await remote(opts);
    return driver.sessionId;
}

async function main() {
    const sessionId = await start();
    const driver = await attach({
		sessionId,
		capabilities: {
			platformName: "Android",
			"appium:automationName": "UiAutomator2",
			"appium:deviceName": "avd1",
			"appium:platformVersion": "11.0", // match your docker image
			"appium:noReset": false,
			"appium:newCommandTimeout": 0,
		},
		options: {
			port: 4723,
			waitforTimeout: 30_000,
			waitforInterval: 500,
		},
	});

        // Example: start playstore in unauthenticated state
	await driver.startActivity(
		"com.android.vending",
		"com.google.android.finsky.activities.MainActivity",
		undefined,
		"*"
	);

	const signInButton = driver.$('//android.widget.Button[@resource-id="com.android.vending:id/0_resource_name_obfuscated"]');
	await signInButton .click();

	// Wait for loading page
        const SIGN_IN_LOADER = '//android.widget.FrameLayout[@resource-id="com.google.android.gms:id/progress_bar_layout"]';
	await driver.$(SIGN_IN_LOADER).waitForDisplayed();
	await driver.$(SIGN_IN_LOADER).waitForExist({
		timeout: 60_000,
		reverse: true,
	}); // Will fail immediately, unless interval is provided here

        await driver.deleteSession()
}

Relevant log output

Error: element ("//android.widget.FrameLayout[@resource-id="com.google.android.gms:id/progress_bar_layout"]") still existing after 30000ms

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions