Skip to main content



      Home
Home » Eclipse Projects » SWTBot » How to test native dialog withswtbot(Native dialog testing with swtbot)
icon14.gif  How to test native dialog withswtbot [message #520368] Fri, 12 March 2010 01:38 Go to next message
Eclipse UserFriend
Hi Ketan,

I am really impressed with swtbot.I have been using this tool for past 3 months.I found it very useful to my project.But I am facing problem when try to browse a file because file browser is native dialog.

Regards,
Ajay
Re: How to test native dialog withswtbot [message #520390 is a reply to message #520368] Thu, 11 March 2010 22:46 Go to previous messageGo to next message
Eclipse UserFriend
Ajay Tiwari a écrit :
> Hi Ketan,
>
> I am really impressed with swtbot.I have been using this tool for past 3
> months.I found it very useful to my project.But I am facing problem when
> try to browse a file because file browser is native dialog.
>
> Regards,
> Ajay

Here we use a flag in the class that uses the file dialog to replace it by a message dialog, so that we can check with SWTBot that the pop-up opens and close it. It is more like a mock than a real solution, but it is helpful.

--
Mickael Istria - BonitaSoft S.A.
http://www.bonitasoft.com/products/downloads.php
Re: How to test native dialog withswtbot [message #520397 is a reply to message #520390] Fri, 12 March 2010 04:06 Go to previous messageGo to next message
Eclipse UserFriend
Hi Mickael,

Thanks Mickael for response.I think that my comment is not clear.Actually I have to select a file here I am not able to select a file.My project is related to wtp where I am testing whether web service project can be created or not.You can think of my project as j2ee application server plugin like jboss and others available in eclipse.For creating web service i have to import wsdl file from disk as per test case.Similar problem i solved using keystrokes but the difference is in first case file not selected by default so OK button is not activated and keystroke cannot be used and in another case where i do is bydefault project file is selected and OK button is activated and i click OK button using awt keyevent.

So my problem is how to select a file from file browser.Here I am not testing brower itself.Here my requirenment is to load file for further testing.

Regards,
Ajay
Re: How to test native dialog withswtbot [message #520412 is a reply to message #520397] Fri, 12 March 2010 05:06 Go to previous messageGo to next message
Eclipse UserFriend
Hello Ajay,

You can use the AWT Robot class (http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Robot.html)
- see the keyPress method. You can type in the name of the file in the text
box of the browse file dialog. This will make your test case OS specific
though (as this is a native dialog).

Thanks
Petar P

> Hi Mickael,
>
> Thanks Mickael for response.I think that my comment is not
> clear.Actually I have to select a file here I am not able to select a
> file.My project is related to wtp where I am testing whether web
> service project can be created or not.You can think of my project as
> j2ee application server plugin like jboss and others available in
> eclipse.For creating web service i have to import wsdl file from disk
> as per test case.Similar problem i solved using keystrokes but the
> difference is in first case file not selected by default so OK button
> is not activated and keystroke cannot be used and in another case
> where i do is bydefault project file is selected and OK button is
> activated and i click OK button using awt keyevent.
>
> So my problem is how to select a file from file browser.Here I am
> not testing brower itself.Here my requirenment is to load file for
> further testing.
>
> Regards,
> Ajay
Re: How to test native dialog withswtbot [message #520413 is a reply to message #520368] Fri, 12 March 2010 05:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ajay,

You can also use a flag for tests to replace file dialog to input dialog, and set the input with the file path.

BR,
Re: How to test native dialog withswtbot [message #520427 is a reply to message #520413] Fri, 12 March 2010 05:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi Baptiste,

Thanks Baptiste.I didn't get where to set flag.I think you are telling that in project itself i have to code to open input dialog in testing mode not in test case.

Regards,
Ajay
Re: How to test native dialog withswtbot [message #520430 is a reply to message #520412] Fri, 12 March 2010 05:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Petar,

Thanks for valuable input.I have used Robot class in so many places and working fine but in this case i had not used i try it and inform.

Regards,
Ajay
Re: How to test native dialog withswtbot [message #520446 is a reply to message #520368] Fri, 12 March 2010 07:31 Go to previous messageGo to next message
Eclipse UserFriend
Yes i was meaning putting a flag inside the project itself and setting the flag in your tests.

It's maybe not the best way to do it but at least your test will not be os specific.
Re: How to test native dialog withswtbot [message #1227068 is a reply to message #520368] Fri, 03 January 2014 07:45 Go to previous messageGo to next message
Eclipse UserFriend
http://prasi82.blogspot.in/2014/01/wanna-test-natives-from-java.html
Re: How to test native dialog withswtbot [message #1227088 is a reply to message #1227068] Fri, 03 January 2014 09:03 Go to previous message
Eclipse UserFriend
Hey Prasad,

That would be very cool if you could use this and implement an extension
to SWTBot that allows to test native widgets!
You could either share this via MarketPlace or try to contribute it to
SWTBot directly (if license allows this).
http://wiki.eclipse.org/SWTBot/Contributing . I can imagine a method
such as
"bot.nativeFileDialog().inFolder("/path/to/folder").selectFile("file.jpeg")"
which would delegate to native implementations using JNA...
--
Mickael Istria
My job: http://www.jboss.org/tools
My blog: http://mickaelistria.wordpress.com
My Tweets: http://twitter.com/mickaelistria
Previous Topic:Command Line
Next Topic:SWTBot with Tycho in Travis CI
Goto Forum:
  


Current Time: Sun Jul 13 00:42:50 EDT 2025

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

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

Back to the top