Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Problem in running multiple swtbot in thread
Problem in running multiple swtbot in thread [message #647039] Tue, 04 January 2011 04:22 Go to next message
vaibhav  is currently offline vaibhav
Messages: 22
Registered: September 2010
Junior Member
Hi,

I am trying to run following code snippet in a single thread.Then "first swtbot" snippet works fine means java project with name MyFirstProject got created, but "second swtbot" throw some exception which i mentioned at last:

Runnable runnable = new Runnable() {
			public void run() {
			SWTWorkbenchBot	bot=new SWTWorkbenchBot();
/*
*
*
*
*first swtbot
*/

bot.menu("File").menu("New").menu("Project...").click();
 
SWTBotShell shell = bot.shell("New Project");
		shell.activate();
		bot.tree().expandNode("Java").select("Java Project");
		bot.button("Next >").click();
		bot.textWithLabel("Project name:").setText("MyFirstProject");
		bot.button("Finish").click();	
		
/*
*
*
*
*second swtbot
*/


	                     bot.menu("File").menu("New").menu("File").click();
		SWTBotShell shell1 = bot.shell("New File");
		shell1.activate();
		bot.textWithLabel("File name:").setText("MyFile");
		bot.button("Finish").click();			}
		};
		new Thread(runnable, "Executing thread...").start(); //$NON-NLS-1$
		}[/B]




The Exception is
!ENTRY org.eclipse.ui 4 0 2011-01-04 14:30:01.245
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
	at org.eclipse.swt.SWT.error(SWT.java:4083)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4083)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.SWT.error(SWT.java:3969)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)
	at org.eclipse.swt.widgets.Decorations.getMenuBar(Decorations.java:672)
	at org.eclipse.swtbot.swt.finder.finders.MenuFinder$1.run(MenuFinder.java:106)
	at org.eclipse.swtbot.swt.finder.finders.MenuFinder$1.run(MenuFinder.java:1)
	at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$2.doRun(UIThreadRunnable.java:140)
	at org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$1.run(UIThreadRunnable.java:89)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	... 23 more
org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could not find widget.
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:348)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFactory.java:257)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFactory.java:208)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFactory.java:198)
	at com.sap.departmentdsl.providers.swtbot.MenuImpl.select(MenuImpl.java:26)
	at com.sap.departmentdsl.core.impl.SelectMenuImpl.execute(SelectMenuImpl.java:166)
	at com.sap.departmentdsl.core.impl.TestImpl.execute(TestImpl.java:313)
	at com.sap.companydsl.ui.action.Executable$1.run(Executable.java:35)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find a menu within the shell 'Shell with text {}' matching 'with mnemonic 'File''
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:398)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:372)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:360)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:346)
	... 8 more
Exception in thread "Executing test..." org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: Could not find widget.
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:348)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.shells(SWTBotFactory.java:112)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.shell(SWTBotFactory.java:102)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.shell(SWTBotFactory.java:93)
	at com.sap.departmentdsl.providers.swtbot.WizardImpl.open(WizardImpl.java:11)
	at com.sap.departmentdsl.core.impl.WizardStepImpl.execute(WizardStepImpl.java:180)
	at com.sap.departmentdsl.core.impl.TestImpl.execute(TestImpl.java:313)
	at com.sap.companydsl.ui.action.Executable$1.run(Executable.java:35)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find shell matching: with text 'New File'
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:398)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:372)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBotFactory.java:360)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:346)
	... 8 more


Has anyone help me out how we can able to run this?

Thanks in advance,

Best Regards,
Vaibhav

[Updated on: Tue, 04 January 2011 10:27]

Report message to a moderator

Re: Problem in running multiple swtbot in thread [message #647348 is a reply to message #647039] Wed, 05 January 2011 12:58 Go to previous message
Ketan Padegaonkar is currently offline Ketan Padegaonkar
Messages: 873
Registered: July 2009
Senior Member
Hi Vaibhav,

When you click finish on the new project dialog, that dialog might take
a few milliseconds to close.

The next line after clicking on finish looks for the "File" menu, but
cannot find it because the new project dialog is still the active dialog.

Try using

bot.waitUntil(Condions.shellCloses(newProjectDialog))

after clicking on the finish button to see if this fixes your problem.

--
Ketan
ketan.padegaonkar.name | eclipse.org/swtbot | @ketanpkr

On 1/4/11 1:22 AM, vaibhav wrote:
> Hi,
>
> I am trying to run following code snippet in a single thread.Then "first
> swtbot" snippet works fine means java project with name MyFirstProject
> got created, but "second swtbot" throw some exception which i mentioned
> at last:
>
> Runnable runnable = new Runnable() {
> public void run() {
> SWTWorkbenchBot bot=new SWTWorkbenchBot();
> /*
> *
> *
> *
> *first swtbot
> */
>
> bot.menu("File").menu("New").menu("Project...").click();
>
> SWTBotShell shell = bot.shell("New Project");
> shell.activate();
> bot.tree().expandNode("Java").select("Java Project");
> bot.button("Next >").click();
> bot.textWithLabel("Project name:").setText("MyFirstProject");
> bot.button("Finish").click();
>
> /*
> *
> *
> *
> *second swtbot
> */
>
>
> bot.menu("File").menu("New").menu("File").click();
> SWTBotShell shell1 = bot.shell("New File");
> shell1.activate();
> bot.textWithLabel("File name:").setText("MyFile");
> bot.button("Finish").click(); }
> };
> new Thread(runnable, "Executing thread...").start(); //$NON-NLS-1$
> }[/B]
>
>
>
> The Exception is
> !ENTRY org.eclipse.ui 4 0 2011-01-04 14:30:01.245
> !MESSAGE Unhandled event loop exception
> !STACK 0
> org.eclipse.swt.SWTException: Failed to execute runnable
> (org.eclipse.swt.SWTException: Widget is disposed)
> at org.eclipse.swt.SWT.error(SWT.java:4083)
> at org.eclipse.swt.SWT.error(SWT.java:3998)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:137)
>
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:4041)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3660)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2629)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:663)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
> Caused by: org.eclipse.swt.SWTException: Widget is disposed
> at org.eclipse.swt.SWT.error(SWT.java:4083)
> at org.eclipse.swt.SWT.error(SWT.java:3998)
> at org.eclipse.swt.SWT.error(SWT.java:3969)
> at org.eclipse.swt.widgets.Widget.error(Widget.java:468)
> at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)
> at org.eclipse.swt.widgets.Decorations.getMenuBar(Decorations.j ava:672)
> at
> org.eclipse.swtbot.swt.finder.finders.MenuFinder$1.run(MenuF inder.java:106)
> at
> org.eclipse.swtbot.swt.finder.finders.MenuFinder$1.run(MenuF inder.java:1)
> at
> org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$2.doR un(UIThreadRunnable.java:140)
>
> at
> org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable$1.run (UIThreadRunnable.java:89)
>
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
>
> ... 23 more
> org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion: Could
> not find widget.
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetA ppears(SWTBotFactory.java:348)
>
> at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFacto ry.java:257)
> at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFacto ry.java:208)
> at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFacto ry.java:198)
> at com.sap.testdsl.providers.swtbot.MenuImpl.select(MenuImpl.ja va:26)
> at
> com.sap.testdsl.core.impl.SelectMenuImpl.execute(SelectMenuI mpl.java:166)
> at com.sap.testdsl.core.impl.TestImpl.execute(TestImpl.java:313 )
> at com.sap.storydsl.ui.action.Executable$1.run(Executable.java: 35)
> at java.lang.Thread.run(Unknown Source)
> Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException:
> Timeout after: 5000 ms.: Could not find a menu within the shell 'Shell
> with text {}' matching 'with mnemonic 'File''
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:398)
>
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:372)
>
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:360)
>
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetA ppears(SWTBotFactory.java:346)
>
> ... 8 more
> Exception in thread "Executing test..."
> org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion: Could
> not find widget.
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetA ppears(SWTBotFactory.java:348)
>
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.shells(SWTBotFac tory.java:112)
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.shell(SWTBotFact ory.java:102)
> at org.eclipse.swtbot.swt.finder.SWTBotFactory.shell(SWTBotFact ory.java:93)
> at com.sap.testdsl.providers.swtbot.WizardImpl.open(WizardImpl. java:11)
> at
> com.sap.testdsl.core.impl.WizardStepImpl.execute(WizardStepI mpl.java:180)
> at com.sap.testdsl.core.impl.TestImpl.execute(TestImpl.java:313 )
> at com.sap.storydsl.ui.action.Executable$1.run(Executable.java: 35)
> at java.lang.Thread.run(Unknown Source)
> Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException:
> Timeout after: 5000 ms.: Could not find shell matching: with text 'New
> File'
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:398)
>
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:372)
>
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:360)
>
> at
> org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetA ppears(SWTBotFactory.java:346)
>
> ... 8 more
>
>
> Has anyone help me out how we can able to run this?
>
> Thanks in advance,
>
> Best Regards,
> Vaibhav
Previous Topic:SWTBot and Rich Text Editor
Next Topic:Errors on Mac when running SWTBot tests
Goto Forum:
  


Current Time: Fri Aug 01 06:04:10 EDT 2014

Powered by FUDForum. Page generated in 0.01631 seconds