Open darosior opened 10 months ago
There is potential work to be done on this by passing list of messages in the update flow, it will help to test state logic but not view logic as buttons may be displayed according to context. In order everything with a full automated test we could use something like: https://stackoverflow.com/questions/73174957/rust-how-to-interact-with-a-window
@edouardparis Could it be possible to start the Iced application inside a unit test, and send signals to it to simulate a user clicking on a button? This would save us a great amount of time.
Related to #712.
I heard about PyAutoGUI for that kind purpose, maybe it worth have a try... edit: using in combination with opencv + tesseract it appears to be not so hard to build a feature for detecting button positions given the button name
That seems potentially useful, could be interesting to explore further. One thing i'm skeptical of is the maintainability. How about waiting times? Can it detect that a button isn't available just yet before pressing it would it need to rely on fixed timeouts?
i'll try to play with that when i got some time, i've some way in mind how to use it.
maybe we can also have a look to a combination of these 3 crates:
I had a check today about this, detect buttons/labels positions by their text is doable using:
xwininfo
to detect the window position by its namerusty-tesseract
for OCRautopilot
for screenshot + interaction (key/mouse press/ mouse scroll / keyboard input/ moving cursor) here some result of window detection + screenshot + OCR detection:
i think if we want do something like this we should add some features to GUI:
you can have a look there on the (RUST) test framework prototype i've made
work a bit on this today, i was getting some bad result doing directly OCR w/ tesseract on the raw screenshot so i changed a bit the flow:
this binary output JSON data that will be quite easy to parse:
Here notes from discord for record:
idea it's call liana w/ a ENV VAR to set the custom theme (custom theme use a different color for each different kind of widget (Primary buttons, Secondary buttons, menu buttons, selected menu buttons, text inputs, check boxes, etc...) then control liana by by a programatic way, (maybe also control a bitcoind regtest) something like:
let mut screen = Screeenshot::new();
assert_eq!(screen.selected_menu, "Send");
assert!(screen.text_inputs.contains("Address");
screen.text_inputs.select("Address");
screen.keyboard_input("bc1................");
screen.text_inputs.select("Payment label");
screen.keyboard_input("Maria paycheck");
screen.text_inputs.select("0.001 (in BTC)");
screen.keyboard_input("Maria paycheck");
screen.text_inputs.select("42 (in sats/vbyte)");
screen.keyboard_input("100");
screen.buttons.click("Next");
sleep(2.0);
let mut screen = Screenshot::new();
assert_eq!(screen.buttons.contains("Sign");
screen.buttons.click("Sign");
// etc....
What Screenshot::new() should do under the hood:
having a lot issues getting a good OCR result using tesseract
on cropped images, i give a try to ocrs, that give very good result (even spaces
, special chars
and case
are very well detected), also looks faster then tesseract and it is built in rust.
note to myself:
I think what's worth automating is the "trivial" tests. Usually when a release comes out we extensively test the new features but we gloss over the existing trivialities. If we could consistently test them in an automated manner it would greatly improve our Q&A.
Already just with the send panel you've got a lot of trivial tests to automate:
I can send to any type of addresses;
I can send to one or multiple outputs;
I can spend one or more coins;
If none are selected, coins get automatically selected;
I can't set an insane feerate;
I can send my whole balance;
I can send my remaining balance in one of the outputs;
If i don't a change output is created;
All of the above combined, lol
@edouardparis Could it be possible to start the Iced application inside a unit test, and send signals to it to simulate a user clicking on a button? This would save us a great amount of time.
Related to #712.