RaiMan / SikuliX-2014

SikuliX version 1.1.2 (until February 2018)
http://sikulix.com
805 stars 235 forks source link

Control throws FinFailed when action screen.click #300

Closed nguyendinhthuan789 closed 6 years ago

nguyendinhthuan789 commented 6 years ago

Hi RaiMan,

Can you help me control using throws FinFailed when action screen.click (sikuliapi 1.1.1 sikuli core 1.2.0) because i see if case failed this case always passed. so I don't want using throw FindFailed in function, how can please help me. :( thanks

screenshot at jan 16 21-46-35 screenshot at jan 16 21-49-30
RaiMan commented 6 years ago

the final image path is not correct!

.../windows10//selectlanguage ...

BTW: sikuli core 1.2.0 has nothing to do with SikuliX.

nguyendinhthuan789 commented 6 years ago

HI Thanks RaiMan for your support Can you look at in the case this FAILED (missing path image) the console is ERROR but results tree at the left bottom is PASSED this is sikuli try catch(FindFailed) , in case i think results tree at the left corner displayed FAILED Thanks

RaiMan commented 6 years ago

If you are talking about unit testing, you have to use assert to control failed/passed of a test.

nguyendinhthuan789 commented 6 years ago

Hi RaiMan Thanks for your support Yes, I'm doing sikuli for testing Application on Desktop Windows, and using testNG FW assert, Currently I have using assert to control case PASSED or FAILED I see if using throw Exception the case is FAILED but using FindFailed case PASSED

screenshot_1 screenshot_2

RaiMan commented 6 years ago

Since you catch the FindFailed without any action, the information is lost for the rest of your code.

Screenshots of code are not very helpful, since it is not possible to copy&paste for suggestions. so only some meta-code:

try {
    click(...)
    return new Mainpage(sikulix)
} catch (...)
    return null
}

... and then in the test:

assert null != selectLanguage....
nguyendinhthuan789 commented 6 years ago

Hi @RaiMan Thanks for your support I think you were wrong for me. I think when using catch (FindFailed ) if case false it will redirect to catch and this case is Failed just now. Not to avoid to crash the app.

public MainPage selectEnglish() { try { waitU.sleep(2500); String english = path_image_os + "/selectlanguage/english.png"; --example this failed path sikulix.click(english); } catch (FindFailed failed) { failed.printStackTrace(); } return new MainPage(sikulix); }

public String getImageEnglish() { return path_image_os + "/selectlanguage/english.png"; }


@Test(description = "select english language") public void setSelectLanguagePage() { Assert.assertTrue(verifyThePopup.verifyImageExists(selectLanguagePage.getImageEnglish())); selectLanguagePage.selectEnglish(); }


public boolean verifyImageExists(String images){

    boolean isValid = false;
    try {
        //Wait 10ms for image
        sikulix.waitVanish(images,10);
        if(sikulix.exists(images)!= null)
        {
            isValid = true;
        }
    }
    catch(Exception e){
    }
    return isValid;
}

Thanks

RaiMan commented 6 years ago

In the future please post questions like this on the launchpad page (larger community): https://answers.launchpad.net/sikuli

Your solution looks odd to me. ... but I am glad you are happy.