Closed pornpawit08 closed 2 weeks ago
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
Created https://github.com/appium/appium-flutter-driver/issues/703 to define a command which does the waitFor
behind that as part of this driver. Maybe it could be a workaround right now.
I need fucntion to check status button enabled or disable (Python)