|
Re: How to use if condition with a label [message #1800052 is a reply to message #1794014] |
Wed, 19 December 2018 11:08 |
Jens Lidestrom Messages: 11 Registered: April 2017 Location: Göteborg, Sweden |
Junior Member |
|
|
The best way I have found for testning the existence of controls is to use try-statements.
The idea is to get a control with get-label, and catch the exception that is thrown if the control doesn't exist.
Example:
try {
get-label "Stopped"
// If no label with the text "Stopped" exist then an exception
// will get thrown, the next statement will not get executed,
// and the script will jump to the -catch block of the
// surrounding try
get-button "Start in standard mode" | click
} -catch {
try {
get-label "Idle"
get-button "Start in XXX mode" | click
} -catch {
assert-true false -message "No matching label found."
}
}
I don't think this solution is very good, it's a bit hard to read and it can be confusing if other kinds of exceptions are thrown in the try-statement and get ignored. It would be better if RCPTT provided an exists test which could be used in if-statements.
Read more about the try-statement here:
https://hudson.eclipse.org/rcptt/job/rcptt-all/ws/releng/doc/target/doc/ecl/index.html#try
Good luck with the coding, Angelo! It sounds like you're going to get the hang of it eventually. :)
[Updated on: Wed, 19 December 2018 11:12] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.06165 seconds