Skip to main content



      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 02:39 Go to next message
Eclipse UserFriend
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 11:37 Go to previous messageGo to next message
Eclipse UserFriend
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 00:55 Go to previous messageGo to next message
Eclipse UserFriend
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 06:20 Go to previous messageGo to next message
Eclipse UserFriend
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 06:21 Go to previous message
Eclipse UserFriend
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: Tue May 13 00:27:26 EDT 2025

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

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

Back to the top