Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » How to wait until next label is visible
How to wait until next label is visible [message #1415126] Tue, 02 September 2014 06:39 Go to next message
Shwetali Dhumal is currently offline Shwetali DhumalFriend
Messages: 12
Registered: August 2014
Junior Member
Hi,

For wait i m using bot.sleep(); API but because of this my test cases are failing. In my application wait is unpredictable, some time wait is more to open any shell or widget to visible.

My requirement is i need to wait until label is visible on next page.

Can any one suggest me documents or link on matcher and wait.

Thank you in advance
Re: How to wait until next label is visible [message #1416215 is a reply to message #1415126] Thu, 04 September 2014 15:37 Go to previous messageGo to next message
Mickael Istria - away until August 14th is currently offline Mickael Istria - away until August 14thFriend
Messages: 833
Registered: July 2009
Location: Grenoble, France
Senior Member

Do not use bot.sleep(), it's not reliable.
Instead use bot.waitWhile or bot.waitUntil with smart conditions, it
should really make your tests more stable.

--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Re: How to wait until next label is visible [message #1419788 is a reply to message #1416215] Tue, 09 September 2014 04:55 Go to previous messageGo to next message
Shwetali Dhumal is currently offline Shwetali DhumalFriend
Messages: 12
Registered: August 2014
Junior Member
Hi Mickael ,

Thanks for the reply. But can you please give me code snippet so i can get idea. I am using following code to wait until label is visible but this code is also not working:

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
}
});


And to wait for shell to open i am using following snippet. But i m not getting it is working or not.

WaitForObjectCondition<Widget> waotForNewProjectShell = waitForWidget(WidgetMatcherFactory.withText("New Project"));
swtBot.waitUntilWidgetAppears(waotForNewProjectShell);


Can u please tell this way is correct way
Re: How to wait until next label is visible [message #1421408 is a reply to message #1419788] Thu, 11 September 2014 10:20 Go to previous messageGo to next message
pawan garia is currently offline pawan gariaFriend
Messages: 39
Registered: February 2013
Member
You can use this code but this is not for Label.This is for a Tree Node in View.

Using this type you can write for the Labels or Shell.

public static void waitForConnection(final String connectionName, final SWTBotTree Currenttree) throws Exception {
sleep(6000);
bot.waitUntil(new DefaultCondition() {
public boolean test() throws Exception {
SWTBotTreeItem[] TreeItems = Currenttree.getAllItems();
for (SWTBotTreeItem item : TreeItems) {

String text = item.getText();
if (text.contains(connectionName)) {
return true;
}
}
return false;
}


return "Connection with" + connectionName + " not visible in view.";

});
}
Re: How to wait until next label is visible [message #1421409 is a reply to message #1421408] Thu, 11 September 2014 10:21 Go to previous message
pawan garia is currently offline pawan gariaFriend
Messages: 39
Registered: February 2013
Member
public static void waitForDialogWithLabelText(final String LabelInDialogVisible) throws Exception {

//@SuppressWarnings("unused")


SWTBotShell shell = BotUtils.shellWithLabelText(new Runnable() {
public void run() {
bot.label(LabelInDialogVisible).isVisible();
}
}, LabelInDialogVisible);
}
Previous Topic:Context menu in project explorer view.
Next Topic:How to wait until context menu is visible
Goto Forum:
  


Current Time: Wed Nov 14 15:15:37 GMT 2018

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

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

Back to the top