Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to automate check button enabled in Flutter ?? #693

Closed
pornpawit08 opened this issue May 28, 2024 · 2 comments
Closed

how to automate check button enabled in Flutter ?? #693

pornpawit08 opened this issue May 28, 2024 · 2 comments
Labels
question Further information is requested

Comments

@pornpawit08
Copy link

pornpawit08 commented May 28, 2024

I need fucntion to check status button enabled or disable (Python)

@KazuCocoa KazuCocoa added the question Further information is requested label Jun 1, 2024
@Tegardoa
Copy link

Tegardoa commented Jun 3, 2024

I usually declare ValueKey in different state in my .dart file for example:
ElevatedButton( key: isDisabled ? ValueKey('disabled-button') : ValueKey('enabled-button') )

In my automation for example in js:

try { 
    button_state = 'disabled';
    await driver.execute('flutter:waitFor', finder.byValueKey('disabled-button'), 3000);
} catch (e) {
    try {
        button_state = 'enabled';
        await driver.execute('flutter:waitFor', finder.byValueKey('enabled-button'), 3000);
    } catch (innerE) {
        button_state = null;
        throw new Error('Button is not found');
    }
}

Maybe you can write like this in python:

try:
    button_state = 'disabled'
    driver.execute_script('flutter:waitFor', finder.byValueKey('disabled-button'), 3000)
except TimeoutException as e:
    try:
        button_state = 'enabled'
        driver.execute_script('flutter:waitFor', finder.byValueKey('enabled-button'), 3000)
    except TimeoutException as innerE:
        button_state = None
        raise Exception('Button is not found')

After all that, you can compare the button_state data as desired

@KazuCocoa
Copy link
Member

Created #703 to define a command which does the waitFor behind that as part of this driver. Maybe it could be a workaround right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants