Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » RCP Testing Tool » How to use if condition with a label
How to use if condition with a label [message #1794014] Wed, 22 August 2018 12:47 Go to next message
Angelo Sala is currently offline Angelo SalaFriend
Messages: 2
Registered: August 2018
Junior Member
Hi,
starting from the fact that I'm not a programmer and that I've been using RCPTT for a couple of weeks I would like to submit to you the following "problem".
I have a label that can have multiple values ("Stopped" in the image in attach that can have also "Idle" as a value) and I would like to use the if condition like "if the value of the statement is Stopped then push the button "Start in standard mode" otherwise go ahead".
Given that, reading the documentation, if the statement is false I receive back an error I cannot do something like this:

if [get-label "Stopped" |get-property caption| eq "Stopped"]{
get-button "Start in standard mode" | click }

Do you have any suggestion?Is there a better statement to use instead of "if"?

I'm a rookie but I really would like to learn how to use RCPTT.

Thanks to everyone that can help me,

Angelo
  • Attachment: Capture.PNG
    (Size: 3.07KB, Downloaded 112 times)
Re: How to use if condition with a label [message #1800052 is a reply to message #1794014] Wed, 19 December 2018 11:08 Go to previous messageGo to next message
Jens Lidestrom is currently offline Jens LidestromFriend
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

Re: How to use if condition with a label [message #1803200 is a reply to message #1800052] Mon, 25 February 2019 09:50 Go to previous message
Victor Dulepov is currently offline Victor DulepovFriend
Messages: 9
Registered: December 2014
Junior Member
Quote:
It would be better if RCPTT provided an exists test which could be used in if-statements.


You can build basic "exists-style" checkers of your own and put them as procedures into your tests or into contexts. Kind of:

proc buttonExists [val Name] {
	try {
		verify-error {
			get-button $Name
		}
		bool false
	} -catch {
		bool true
	}
}

//now you use it in your test code like:
if [buttonExists "My Schroedingerian Button"] {get-button "My Schroedingerian Button" | click}


You can do the same to windows and other controls.
Previous Topic:FrameworkError. Missng org.eclipse.emf.ant while attaching to the AUT
Next Topic:RCPTT plugin AUT launch error in eclipse Neon
Goto Forum:
  


Current Time: Wed Apr 24 16:15:36 GMT 2024

Powered by FUDForum. Page generated in 0.03195 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top