Search code examples
eclipse-rcpeclipse-rcptt

How to check if a window is open in Eclipse RCP, with RCPTT


I have an ECL script developed in RCPTT, to test an RCP application. During the test, it sets some settings and save it. When the test press "OK", an information window can open to inform user that this change need to rebuild the project.

enter image description here

My problem is that this window will not always shown. If in the workspace where the test run, this window has already been opened, and the option "Remmenber my decision" has been set, then it won't open.

I want to put a if in my test to handle the both cases. It should be something like :

if [/* what can i put here ?*/] {
    get-window Settings | get-button Yes | click
}

How to write such a condition ?

Can I do something like if [get-window Settings | verify-true ] or if [ not [get-window Settings | verify-error ] ] ?

Edit: By using the "record snippet" tool, I've arrived to something like :

with [get-window Settings] {
    get-property "isEnabled()" | equals true | verify-true
    get-property "isVisible()" | equals true | verify-true
}

Which property is the good one tu use in my case ? Enable, Visible or both ?


Solution

  • Use try-catch in such cases:

    try {
        get-window Settings | get-button Yes | click
    } -catch {
        // Verify that the window was missing (and not some other problem)
        verify-error -command {get-window Settings}
    }