[Pharo-project] GUI Testing Library
I'm starting to put together some helpers for UI testing. What's out there already? I started simulating keyboard events. It seems like the place to hook is ActiveHand>>handleEvent:. This way, it will take into account the keyboard focus and route the event the way it would for a real event. Does that sound right? So far the API adds TestCase>>simulateKeyStrokes: which forwards to ActiveHand>>handleEvent:, so you can put in a test: testMyMorph MyMorph new openInWorld. "MyMorph takes the keyboard focus in #initialize" self simulateKeyStrokes: 'abcd'. "keystrokes go to MyMorph instance" Obviously, there are things missing (like modifier keys), but what are your thoughts on the general approach? Sean -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4097866.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Sean P. DeNigris wrote
So far the API adds...
This is fun! I integrated with Keymapping, so now you can write: self simulateKeyStrokes: 'Object'. self simulateKeyStroke: $s command. To play, doit:
Gofer new squeaksource: 'ShortWays'; package: 'ConfigurationOfKeymapping'; load. (Smalltalk at: #ConfigurationOfKeymapping) project bleedingEdge load.
Gofer it squeaksource: 'BDDExtensions'; package: 'BDDExtensions'; load.
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4098126.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
On 23 November 2011 02:09, Sean P. DeNigris <sean@clipperadams.com> wrote:
Sean P. DeNigris wrote
So far the API adds...
This is fun! I integrated with Keymapping, so now you can write: Â Â Â Â self simulateKeyStrokes: 'Object'. Â Â Â Â self simulateKeyStroke: $s command.
To play, doit:
Nice! It would be cool to cover UI stuff with such tests. Like if you have browser window and press something, it should do somehting.. etc
Gofer new        squeaksource: 'ShortWays';        package: 'ConfigurationOfKeymapping';        load. (Smalltalk at: #ConfigurationOfKeymapping) project bleedingEdge load.
Gofer it    squeaksource: 'BDDExtensions';    package: 'BDDExtensions';    load.
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4098126.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- Best regards, Igor Stasenko.
I am quite interested, as well. I am not sure I understand how to reproduce your approach, though. Could you provide more information? Or maybe an example? Cheers, Doru On Wed, Nov 23, 2011 at 11:54 AM, Igor Stasenko <siguctua@gmail.com> wrote:
On 23 November 2011 02:09, Sean P. DeNigris <sean@clipperadams.com> wrote:
Sean P. DeNigris wrote
So far the API adds...
This is fun! I integrated with Keymapping, so now you can write: Â Â Â Â self simulateKeyStrokes: 'Object'. Â Â Â Â self simulateKeyStroke: $s command.
To play, doit:
Nice! It would be cool to cover UI stuff with such tests. Like if you have browser window and press something, it should do somehting.. etc
Gofer new        squeaksource: 'ShortWays';        package: 'ConfigurationOfKeymapping';        load. (Smalltalk at: #ConfigurationOfKeymapping) project bleedingEdge load.
Gofer it    squeaksource: 'BDDExtensions';    package: 'BDDExtensions';    load.
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4098126.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- Best regards, Igor Stasenko.
-- www.tudorgirba.com "Every thing has its own flow"
Tudor Girba-2 wrote
Could you provide more information? Or maybe an example?
Sure. Thanks for the push to write tests :) I just uploaded a new version with some simple tests. Here is a snippet: testSimulateCmdKeystroke | ws | ws := Workspace open. self simulateKeyStrokes: 'var := 3.'. self simulateKeyStroke: $s command. self assert: ws hasUnacceptedEdits = false. I'll be adding functionality as I go because I'm using it to test my own GUIs, but let me know if there's anything specific that you'd really love to see here... Sean p.s. only in a live, open, dynamic system like Smalltalk could I do this so easily. I've read books devoted to this topic, but I coded this up in a few minutes. -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4099975.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Wow, this looks brilliant! I will definitely give it a try in the following days. Doru On Wed, Nov 23, 2011 at 4:10 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Tudor Girba-2 wrote
Could you provide more information? Or maybe an example?
Sure. Thanks for the push to write tests :)
I just uploaded a new version with some simple tests. Here is a snippet: testSimulateCmdKeystroke
    | ws |     ws := Workspace open.     self simulateKeyStrokes: 'var := 3.'.
    self simulateKeyStroke: $s command.
    self assert: ws hasUnacceptedEdits = false.
I'll be adding functionality as I go because I'm using it to test my own GUIs, but let me know if there's anything specific that you'd really love to see here...
Sean
p.s. only in a live, open, dynamic system like Smalltalk could I do this so easily. I've read books devoted to this topic, but I coded this up in a few minutes.
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4099975.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- www.tudorgirba.com "Every thing has its own flow"
Hi Sean, I just wrote the first test case for Glamour using the BDDExtensions. This was for a bug that that was present in Glamour since several months, but I just did not know how to test. With the new facilities, it got as simple as: testExplicitAcceptDoesNotAffectTextPort ... textMorph := self find: GLMPluggableTextMorph in: window. textMorph simulateClick. self simulateKeyStrokes: '4'. self assert: (browser panes first port: #text) value = '1234'. self simulateKeyStroke: $s command. self simulateKeyStrokes: '56'. self assert: (browser panes first port: #text) value = '123456' It's just cool. Thanks, Doru On 23 Nov 2011, at 16:17, Tudor Girba wrote:
Wow, this looks brilliant!
I will definitely give it a try in the following days.
Doru
On Wed, Nov 23, 2011 at 4:10 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Tudor Girba-2 wrote
Could you provide more information? Or maybe an example?
Sure. Thanks for the push to write tests :)
I just uploaded a new version with some simple tests. Here is a snippet: testSimulateCmdKeystroke
| ws | ws := Workspace open. self simulateKeyStrokes: 'var := 3.'.
self simulateKeyStroke: $s command.
self assert: ws hasUnacceptedEdits = false.
I'll be adding functionality as I go because I'm using it to test my own GUIs, but let me know if there's anything specific that you'd really love to see here...
Sean
p.s. only in a live, open, dynamic system like Smalltalk could I do this so easily. I've read books devoted to this topic, but I coded this up in a few minutes.
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4099975.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- www.tudorgirba.com "Every thing has its own flow"
-- www.tudorgirba.com "From an abstract enough point of view, any two things are similar."
Tudor Girba-2 wrote
It's just cool.
Excellent! The latest package in the repo adds right clicking, choosing from menus, and a bug fix for Morphs that use local coordinates. -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4153835.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Hi Sean, Unfortunately, it seems that Keymapping introduces subtle bugs in the other tools. Would it be possible to simulate keys with modifiers without Keymapping present? Cheers, Doru On 3 Dec 2011, at 17:38, Sean P. DeNigris wrote:
Tudor Girba-2 wrote
It's just cool.
Excellent! The latest package in the repo adds right clicking, choosing from menus, and a bug fix for Morphs that use local coordinates.
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4153835.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- www.tudorgirba.com If you can't say why something is relevant, it probably isn't.
Tudor Girba-2 wrote
Would it be possible to simulate keys with modifiers without Keymapping present?
I think I only used Keymapping for the modifier key syntax, but looking at its repository, the shortcuts are packaged separately. So you could try only loading Keymapping-Shortcuts, which does not hook into the system (so shouldn't break anything) and will add #command, $shift, etc. Let me know if that works for you. Sean -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4172952.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Thanks a lot, Sean! It works just great with BDDExtensions and Keymapping-Shortcuts. Cheers, Doru On Thu, Dec 8, 2011 at 3:35 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Tudor Girba-2 wrote
Would it be possible to simulate keys with modifiers without Keymapping present?
I think I only used Keymapping for the modifier key syntax, but looking at its repository, the shortcuts are packaged separately. So you could try only loading Keymapping-Shortcuts, which does not hook into the system (so shouldn't break anything) and will add #command, $shift, etc. Let me know if that works for you.
Sean
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4172952.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- www.tudorgirba.com "Every thing has its own flow"
Btw, I think these should get in the Pharo distribution because they are just too valuable. Doru On Fri, Dec 9, 2011 at 4:07 PM, Tudor Girba <tudor@tudorgirba.com> wrote:
Thanks a lot, Sean!
It works just great with BDDExtensions and Keymapping-Shortcuts.
Cheers, Doru
On Thu, Dec 8, 2011 at 3:35 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Tudor Girba-2 wrote
Would it be possible to simulate keys with modifiers without Keymapping present?
I think I only used Keymapping for the modifier key syntax, but looking at its repository, the shortcuts are packaged separately. So you could try only loading Keymapping-Shortcuts, which does not hook into the system (so shouldn't break anything) and will add #command, $shift, etc. Let me know if that works for you.
Sean
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4172952.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- www.tudorgirba.com
"Every thing has its own flow"
-- www.tudorgirba.com "Every thing has its own flow"
Tudor Girba-2 wrote
Btw, I think these should get in the Pharo distribution because they are just too valuable.
I will open an issue and submit a slice. Do you have any suggestions/requests while I'm there? I think the only basic thing missing is middle-click, which will be easy to add. Right now we have: * send a string of keystrokes * send a single keystroke, with modifiers if desired * left click * right click * choose item from menu Except for the tests, there's only extension methods, which I'll recategorize. The ones I have questions about are: * TestCase - I know SUnit is an external project. Is ours forked? i.e. can I add methods to it? * Keymapping - simulating modifier keys requires Keymapping-Shortcuts. What would be best? Sean -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4177181.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Hi, I think the best would be to add it externally from a configuration. So, I created one: Gofer new squeaksource: 'BDDExtensions'; package: 'ConfigurationOfBDDExtensions'; load. (Smalltalk at: #ConfigurationOfBDDExtensions) loadDevelopment At the moment it only has a 1.0-baseline with BDDExtensions and Keymapping-Shortcuts. Cheers, Doru On 9 Dec 2011, at 17:13, Sean P. DeNigris wrote:
Tudor Girba-2 wrote
Btw, I think these should get in the Pharo distribution because they are just too valuable.
I will open an issue and submit a slice. Do you have any suggestions/requests while I'm there? I think the only basic thing missing is middle-click, which will be easy to add. Right now we have: * send a string of keystrokes * send a single keystroke, with modifiers if desired * left click * right click * choose item from menu
Except for the tests, there's only extension methods, which I'll recategorize. The ones I have questions about are: * TestCase - I know SUnit is an external project. Is ours forked? i.e. can I add methods to it? * Keymapping - simulating modifier keys requires Keymapping-Shortcuts. What would be best?
Sean
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4177181.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- www.tudorgirba.com "Live like you mean it."
Tudor Girba-2 wrote
I think the best would be to add it externally from a configuration. So, I created one:
Thanks! Of course if it's external no one will use it to test the image itself :( p.s. I added middle click and tests for all click types -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4196899.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Sean P. DeNigris wrote
I will open an issue
Issue 5077: UI simulation from BDDExtensions project http://code.google.com/p/pharo/issues/detail?id=5077 -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4177726.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
On Tue, Nov 22, 2011 at 10:09 PM, Sean P. DeNigris <sean@clipperadams.com>wrote:
This is fun! I integrated with Keymapping, so now you can write: self simulateKeyStrokes: 'Object'. self simulateKeyStroke: $s command.
Haha! great :) I'll freeze an stable version soon.
Hi Sean, This is very valuable. Currently it is really hard to test GUI in Pharo. One problem I faced several times is that GUI are not uniformly managed: some GUI widgets use of exceptions (which is cool), some other are blocking the currently thread (which is not cool). For example, I can write: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | t | [self inform: 'blah'] on: Exception do: [:ex | t := ex ]. self assert: t messageText = 'blah' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Other cool tests: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= testSupplyAnswerOfFillInTheBlank self should: ['blue' = ([UIManager default request: 'Your favorite color?'] valueSupplyingAnswer: #('Your favorite color?' 'blue'))] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= However, not all widgets can be tested that way, which is quite problematic. For example, the following code opens a window, which is not one would expect: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= self should: ['/tmp' = ([UIManager default chooseDirectory] valueSupplyingAnswer: #('/tmp'))] -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= I am not sure how easy is to solve this problem, but this is something we need to work on. This is important. I opened an issue: http://code.google.com/p/pharo/issues/detail?id=5010 Cheers, Alexandre On 22 Nov 2011, at 20:27, Sean P. DeNigris wrote:
I'm starting to put together some helpers for UI testing. What's out there already?
I started simulating keyboard events. It seems like the place to hook is ActiveHand>>handleEvent:. This way, it will take into account the keyboard focus and route the event the way it would for a real event. Does that sound right?
So far the API adds TestCase>>simulateKeyStrokes: which forwards to ActiveHand>>handleEvent:, so you can put in a test: testMyMorph MyMorph new openInWorld. "MyMorph takes the keyboard focus in #initialize" self simulateKeyStrokes: 'abcd'. "keystrokes go to MyMorph instance"
Obviously, there are things missing (like modifier keys), but what are your thoughts on the general approach?
Sean
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4097866.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Alexandre Bergel-7 wrote
I opened an issue: http://code.google.com/p/pharo/issues/detail?id=5010
Fix (although I guess there are more widgets to fix?) in 1.4 inbox SLICE-Issue-5010-Testing-GUI-widgets-SeanDeNigris.1 Alexandre Bergel-7 wrote
This is very valuable. Currently it is really hard to test GUI in Pharo.
I think it could be very easy with a little work Alexandre Bergel-7 wrote
One problem I faced several times is that GUI are not uniformly managed: some GUI widgets use of exceptions (which is cool), some other are blocking the currently thread (which is not cool).
The hook points are in MorphicUIManager's "ui requests" protocol. For each type of interaction (e.g. confirm), in the method that takes the most arguments (e.g. #confirm:label:, not #confirm:), ProvideAnswerNotification is signaled. Alexandre Bergel-7 wrote
For example, I can write...
Thanks for the examples. I wrote them into Morphic tests (incl. in fix above) Alexandre Bergel-7 wrote
self should: ['/tmp' = ([UIManager default chooseDirectory] valueSupplyingAnswer: #('/tmp'))]
This works now, but the syntax is ...valueSupplyingAnswer: { 'Choose Directory'. FileDirectory on: '/tmp' }. HTH, Sean -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4100236.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
I will invite you for a couple of beers at the next esug :-) I cannot try it right now (bad internet connection), but I checked the source code. It looks good. Cheers, Alexandre On 23 Nov 2011, at 13:12, Sean P. DeNigris wrote:
Alexandre Bergel-7 wrote
I opened an issue: http://code.google.com/p/pharo/issues/detail?id=5010
Fix (although I guess there are more widgets to fix?) in 1.4 inbox SLICE-Issue-5010-Testing-GUI-widgets-SeanDeNigris.1
Alexandre Bergel-7 wrote
This is very valuable. Currently it is really hard to test GUI in Pharo.
I think it could be very easy with a little work
Alexandre Bergel-7 wrote
One problem I faced several times is that GUI are not uniformly managed: some GUI widgets use of exceptions (which is cool), some other are blocking the currently thread (which is not cool).
The hook points are in MorphicUIManager's "ui requests" protocol. For each type of interaction (e.g. confirm), in the method that takes the most arguments (e.g. #confirm:label:, not #confirm:), ProvideAnswerNotification is signaled.
Alexandre Bergel-7 wrote
For example, I can write...
Thanks for the examples. I wrote them into Morphic tests (incl. in fix above)
Alexandre Bergel-7 wrote
self should: ['/tmp' = ([UIManager default chooseDirectory] valueSupplyingAnswer: #('/tmp'))]
This works now, but the syntax is ...valueSupplyingAnswer: { 'Choose Directory'. FileDirectory on: '/tmp' }.
HTH, Sean
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4100236.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Alexandre Bergel-7 wrote
I will invite you for a couple of beers at the next esug :-)
Paid in beer?! This is the best job ever ;-) -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4102097.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Starting to add simulated mouse actions... testSimulateMouseClick | textMorph | textMorph := TextMorph new contents: ''; openInWorld. textMorph simulateClick. self assert: textMorph hasKeyboardFocus. -- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4102095.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Sean P. DeNigris wrote:
I'm starting to put together some helpers for UI testing. What's out there already?
I started simulating keyboard events. It seems like the place to hook is ActiveHand>>handleEvent:. This way, it will take into account the keyboard focus and route the event the way it would for a real event. Does that sound right?
So far the API adds TestCase>>simulateKeyStrokes: which forwards to ActiveHand>>handleEvent:, so you can put in a test: testMyMorph MyMorph new openInWorld. "MyMorph takes the keyboard focus in #initialize" self simulateKeyStrokes: 'abcd'. "keystrokes go to MyMorph instance"
Obviously, there are things missing (like modifier keys), but what are your thoughts on the general approach?
Sean
-- View this message in context: http://forum.world.st/GUI-Testing-Library-tp4097866p4097866.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Perhaps an event recorder and replay could be added. This may be useful for instance if a regression GUI bug is introduced between Pharo versions that I encounter when driving the GUI. Then in the earlier version I could record the expected output of what I do in the GUI, then save that as a test to be loaded into the later version, and also attached to the issue tracker. just idle chatter and wild speculation. cheers, Ben
participants (6)
-
Alexandre Bergel -
Ben Coman -
Guillermo Polito -
Igor Stasenko -
Sean P. DeNigris -
Tudor Girba