Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » How to click a button until the condition is true.?
How to click a button until the condition is true.? [message #1077768] Fri, 02 August 2013 01:50 Go to next message
Pawan Relan is currently offline Pawan Relan
Messages: 7
Registered: July 2013
Junior Member
Hi,

I want button.click() to be executed until the conditon in while condition in loop is False.
Please refer the following code...
final SWTBotButton button = bot.button("Next");
do
{
button.click();
}
while(bot.label("LabelName").isVisible()==false);

My Program goes into time out after executing "button.click();" once or twice even though the value returned by while loop is false.

Regards,
Pawan Relan
Re: How to click a button until the condition is true.? [message #1090064 is a reply to message #1077768] Mon, 19 August 2013 13:02 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael Istria
Messages: 741
Registered: July 2009
Location: Grenoble, France
Senior Member
The error you get seems to show that the button is hidden when you try
to click it for the 2nd or 3rd time, independently of the condition.

--
Mickael Istria
JBoss, by Red Hat
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: How to click a button until the condition is true.? [message #1091359 is a reply to message #1077768] Wed, 21 August 2013 07:55 Go to previous messageGo to next message
Pawan Relan is currently offline Pawan Relan
Messages: 7
Registered: July 2013
Junior Member
Thanks Mickael for your Reply
I have verified but the button is visible and also enabled.
However sometimes "button.click()" is working for more than 4 or 5 iterations but it not able to complete all the iterations.

Regards,
Pawan Relan

[Updated on: Wed, 21 August 2013 07:56]

Report message to a moderator

Re: How to click a button until the condition is true.? [message #1173248 is a reply to message #1077768] Wed, 06 November 2013 06:45 Go to previous message
Martin Schemel is currently offline Martin Schemel
Messages: 4
Registered: November 2013
Location: Berlin
Junior Member
Pawan Relan wrote on Fri, 02 August 2013 01:50
Hi,

I want button.click() to be executed until the conditon in while condition in loop is False.
Please refer the following code...
final SWTBotButton button = bot.button("Next");
do
{
button.click();
}
while(bot.label("LabelName").isVisible()==false);

My Program goes into time out after executing "button.click();" once or twice even though the value returned by while loop is false.

Regards,
Pawan Relan


What you're looking for is a Wait condition. See following example:

bot.button("Next").click();
		
		bot.waitUntil(new DefaultCondition() {
			
			@Override
			public boolean test() throws Exception {
				return !bot.label("LabelName").isVisible(); // waits here until TRUE is returned. But max 5 seconds.
			}
			
			@Override
			public String getFailureMessage() {
				return "Error waiting for condition to be true."; // error msg here
			}
		});
Previous Topic:Run test from jenkins
Next Topic:How to click menu items in SWTBOT
Goto Forum:
  


Current Time: Thu Aug 21 18:08:27 EDT 2014

Powered by FUDForum. Page generated in 0.02713 seconds