Hi Chris, Thron7/Thomas, all nice developers in
RAP/Qooxdoo/Selenium-wunderland,
another day is gone and I'm not so much further. But something learned:
When I look in the HTML/Java-Script of my RAP/Qooxdoo-application there are a
lot of Eventlistener registered for the textfield (this happens in as far as I
understand in org.eclipse.swt.TextUtil):
/**
* This class contains static functions for the Text and Combo widget. Note that
* the Combo widget also calls the "protected" (_xxx) methods in this class.
*/
qx.Class.define( "org.eclipse.swt.TextUtil", {
statics : {
// === Public methods ===
/*
* To be called right after widget creation.
*/
initialize : function( text ) {
if( text.isCreated() ) {
org.eclipse.swt.TextUtil._doAddListener( text );
} else {
text.addEventListener( "appear",
org.eclipse.swt.TextUtil._onAppearAddListener );
}
text.setLiveUpdate( true );
},
/*
* Sets the hasSelectionListerner property on the given text widget.
* This property tracks whether the text widget has a selection listener
* attached.
*/
setHasSelectionListener : function( text, newValue ) {
var oldValue = text.getUserData( "hasSelectionListener" );
if( newValue != oldValue ) {
text.setUserData( "hasSelectionListener", newValue );
org.eclipse.swt.TextUtil._updateSelectionListener( text, newValue );
}
},
hasSelectionListener : function( text ) {
return text.getUserData( "hasSelectionListener" ) == true;
},
/*
* Sets the hasVerifyOrModifyListener property on the given widget.
* This property tracks whether the text widget has a verify listener or a
* modify listener attached.
*/
setHasVerifyOrModifyListener : function( text, newValue ) {
var oldValue = text.getUserData( "hasVerifyOrModifyListener" );
if( newValue != oldValue ) {
text.setUserData( "hasVerifyOrModifyListener", newValue );
org.eclipse.swt.TextUtil._updateVerifyOrModifyListener( text, newValue
);
}
},
hasVerifyOrModifyListener : function( text ) {
return text.getUserData( "hasVerifyOrModifyListener" ) == true;
},
/*
* Sets the selected text range of the given text widget.
*/
setSelection : function( text, start, length ) {
if( text.isCreated() && !text.getUserData( "pooled" ) ) {
org.eclipse.swt.TextUtil._doSetSelection( text, start, length );
} else {
text.setUserData( "onAppear.selectionStart", start );
text.setUserData( "onAppear.selectionLength", length );
text.addEventListener( "appear",
org.eclipse.swt.TextUtil._onAppearSetSelection );
}
},
// === Private methods ===
_onAppearAddListener : function( event ) {
// TODO [rst] Optimize: add/remove listener on change of
// hasVerifyOrModifyListener property
var text = event.getTarget();
text.removeEventListener( "appear",
org.eclipse.swt.TextUtil._onAppearAddListener );
org.eclipse.swt.TextUtil._doAddListener( text );
},
_doAddListener : function( text ) {
text.addEventListener( "mouseup", org.eclipse.swt.TextUtil._onMouseUp );
text.addEventListener( "keyup", org.eclipse.swt.TextUtil._onKeyUp );
text.addEventListener( "keydown", org.eclipse.swt.TextUtil._onKeyDown );
text.addEventListener( "keypress", org.eclipse.swt.TextUtil._onKeyPress );
text.addEventListener( "changeValue",
org.eclipse.swt.TextUtil._onTextChange );
},
// === Event listener ===
_onMouseUp : function( event ) {
// event.debug( "_____ onMouseUp ", event );
if( !org_eclipse_rap_rwt_EventUtil_suspend ) {
var text = event.getTarget();
org.eclipse.swt.TextUtil._handleSelectionChange( text );
}
},
_onKeyDown : function( event ) {
// event.debug( "_____ onKeyDown ", event );
if( !org_eclipse_rap_rwt_EventUtil_suspend ) {
var text = event.getTarget();
org.eclipse.swt.TextUtil._handleSelectionChange( text );
if( event.getKeyIdentifier() == "Enter"
&& !event.isShiftPressed()
&& !event.isAltPressed()
&& !event.isCtrlPressed()
&& !event.isMetaPressed()
&& org.eclipse.swt.TextUtil.hasSelectionListener( text ) )
{
event.setPropagationStopped( true );
org.eclipse.swt.TextUtil._sendWidgetDefaultSelected( text );
}
}
},
_onKeyPress : function( event ) {
// event.debug( "_____ onKeyPress ", event );
if( !org_eclipse_rap_rwt_EventUtil_suspend ) {
var text = event.getTarget();
org.eclipse.swt.TextUtil._handleSelectionChange( text );
}
},
_onKeyUp : function( event ) {
// event.debug( "_____ onKeyUp ", event );
if( !org_eclipse_rap_rwt_EventUtil_suspend ) {
var text = event.getTarget();
org.eclipse.swt.TextUtil._handleSelectionChange( text );
}
},
_onTextChange : function( event ) {
// event.debug( "_____ onTextChange ", event );
if( !org_eclipse_rap_rwt_EventUtil_suspend ) {
var text = event.getTarget();
org.eclipse.swt.TextUtil._handleModification( text );
org.eclipse.swt.TextUtil._handleSelectionChange( text );
}
},
// === Request related ===
_handleModification : function( text ) {
// if not yet done, register an event listener that adds a request param
// with the text widgets' content just before the request is sent
if( !org.eclipse.swt.TextUtil._isModified( text ) ) {
org.eclipse.swt.TextUtil._setModified( text, true );
var req = org.eclipse.swt.Request.getInstance();
req.addEventListener( "send", org.eclipse.swt.TextUtil._onSend, text );
if( org.eclipse.swt.TextUtil.hasVerifyOrModifyListener( text ) ) {
// add modifyText-event with sender-id to request parameters
var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
var id = widgetManager.findIdByWidget( text );
var req = org.eclipse.swt.Request.getInstance();
req.addEvent( "org.eclipse.swt.events.modifyText", id );
// register listener that is notified when a request is sent
qx.client.Timer.once( org.eclipse.swt.TextUtil._delayedSend, text,
500 );
}
}
},
_updateSelectionListener : function( text, newValue ) {
// text.debug( "_____ update selection listener", text, newValue );
},
_updateVerifyOrModifyListener : function( text, newValue ) {
// text.debug( "_____ update ver/mod listener", text, newValue );
},
_onSend : function( event ) {
// NOTE: 'this' references the text widget
var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
var id = widgetManager.findIdByWidget( this );
var req = org.eclipse.swt.Request.getInstance();
req.addParameter( id + ".text", this.getComputedValue() );
// remove the _onSend listener and change the text widget state to
'unmodified'
req.removeEventListener( "send", org.eclipse.swt.TextUtil._onSend, this );
org.eclipse.swt.TextUtil._setModified( this, false );
// Update the value property (which is qooxdoo-wise only updated on
// focus-lost) to be in sync with server-side
if( this.getFocused() ) {
this.setValue( this.getComputedValue() );
}
},
_delayedSend : function( event ) {
// NOTE: "this" references the text widget (see qx.client.Timer.once
above)
if( org.eclipse.swt.TextUtil._isModified( this ) ) {
var req = org.eclipse.swt.Request.getInstance();
req.send();
}
},
/*
* Sends a widget default selected event to the server.
*/
_sendWidgetDefaultSelected : function( text ) {
var widgetManager = org.eclipse.swt.WidgetManager.getInstance();
var id = widgetManager.findIdByWidget( text );
var req = org.eclipse.swt.Request.getInstance();
req.addEvent( "org.eclipse.swt.events.widgetDefaultSelected", id );
req.send();
},
// === Auxiliary ===
/*
* Returns modified property of the given text widget. If true, a request
* send listener is already attached.
*/
_isModified : function( widget ) {
return widget.getUserData( "modified" ) == true;
},
_setModified : function( widget, modified ) {
widget.setUserData( "modified", modified );
},
/**
* Determines whether the given keyIdentifier potentially modifies the
* content of a text widget.
* TODO [rst] Obsolete but still used by ComboUtil
*/
_isModifyingKey : function( keyIdentifier ) {
var result = false;
switch( keyIdentifier ) {
// Modifier keys
case "Shift":
case "Control":
case "Alt":
case "Meta":
case "Win":
// Navigation keys
case "Up":
case "Down":
case "Left":
case "Right":
case "Home":
case "End":
case "PageUp":
case "PageDown":
case "Tab":
// Context menu key
case "Apps":
//
case "Escape":
case "Insert":
case "Enter":
//
case "CapsLock":
case "NumLock":
case "Scroll":
case "PrintScreen":
// Function keys 1 - 12
case "F1":
case "F2":
case "F3":
case "F4":
case "F5":
case "F6":
case "F7":
case "F8":
case "F9":
case "F10":
case "F11":
case "F12":
break;
default:
result = true;
}
return result;
},
///////////////////////////////////////////////////////////////////
// Functions to maintain the selection-start and -length properties
/*
* Checks for a selection change and updates the request parameter if
* necessary.
*/
_handleSelectionChange : function( text, enclosingWidget ) {
var widget = enclosingWidget != null ? enclosingWidget : text;
var start = text.getSelectionStart();
var length = text.getSelectionLength();
// TODO [rst] Workaround for qx bug 521. Might be redundant as the
// bug is marked as (partly) fixed.
// See http://bugzilla.qooxdoo.org/show_bug.cgi?id=521
if( typeof length == "undefined" ) {
text.debug( "___ qx bug 521 still exists" );
length = 0;
}
if( text.getUserData( "selectionStart" ) != start
|| text.getUserData( "selectionLength" ) != length )
{
text.setUserData( "selectionStart", start );
org.eclipse.swt.WidgetUtil.setPropertyParam( widget,
"selectionStart",
start );
text.setUserData( "selectionLength", length );
org.eclipse.swt.WidgetUtil.setPropertyParam( widget,
"selectionLength",
length );
}
},
_onAppearSetSelection : function( event ) {
var text = event.getTarget();
var start = text.getUserData( "onAppear.selectionStart" );
var length = text.getUserData( "onAppear.selectionLength" );
org.eclipse.swt.TextUtil._doSetSelection( text, start, length );
text.removeEventListener( "appear",
org.eclipse.swt.TextUtil._onAppearSetSelection
);
},
_doSetSelection : function( text, start, length ) {
text.setUserData( "selectionStart", start );
text.setSelectionStart( start );
text.setUserData( "selectionLength", length );
text.setSelectionLength( length );
}
}
});
And as I have seen in JMeter, not every keypress leads to an AJAX-request, e.g.
the changes in my textfield are cached (until they are send) in a Map in the
Request-Class:
var req = org.eclipse.swt.Request.getInstance();
req.addParameter( id + ".text", this.getComputedValue() );
This doesn't happens when I call "type" or typeKeys from Selenium-RC (but it
happens when I use Selenium-IDE). I would like to write a selenium Extension
like Qooxdoo Simulator which can call:
var req = org.eclipse.swt.Request.getInstance();
req.addParameter( id + ".text", this.getComputedValue() );
But how is it possible to access/import the classes defined in the
Qooxdoo/RAP-Webapp from an (not embedded) Selenium user-extension.js ?
Michael
-------- Original-Nachricht --------
> Datum: Mon, 10 Nov 2008 13:13:22 +0100
> Von: "Michael Willig" <[EMAIL PROTECTED]>
> An: qooxdoo Development <[email protected]>
> Betreff: Re: [qooxdoo-devel] qxType, change a textbox
> Hi Chris,
>
> many thanks for your help. On friday we came more inside the problem
> (using JMeter to look for the server-communication).
> We use a stripped down RAP-Controls-Demo (ButtonTab.java). There is a
> textfield defined and the Button, but it looks the same way as your example:
>
> final Text text = new Text( group, SWT.BORDER | SWT.SINGLE );
> defaultButton = new Button( group, style | SWT.PUSH );
> defaultButton.setText( "Default Button" );
> defaultButton.getShell().setDefaultButton( defaultButton );
> defaultButton.addSelectionListener( new SelectionAdapter() {
> public void widgetSelected( final SelectionEvent event ) {
> String message = "The text You entered: " + text.getText();
> MessageDialog.openInformation( group.getShell(),
> "Information",
> message );
> }
> } );
>
>
> It seems that after a automatically input (type-Command) the Textfield is
> not set to changed.
>
> complete manually:
> input 12 in the textfield and button-Click leads to TWO Requests:
>
> my ids:
> w1 the ui-Root-ID for the application
> w7 is the workbench-Window inside the Browser-Window
> w76 the div where the Button-Div is in
> w80 is the div where the textfield is in (XPath its
> //[EMAIL PROTECTED]'w80']/input)
>
> first request:
> Name Value
> w7.activeControl w76
> w80.selectionStart 2
> w80.selectionLength 0
> org.eclipse.swt.events.widgetSelected w76
> w76.bounds.x 5
> w76.bounds.y 59
> w76.bounds.width 152
> w76.bounds.height 25
> w1.focusControl w76
> w80.text 12
> uiRoot w1
> requestCounter 39
>
> second request:
> 389628459 442,13
> w1.focusControl w162
> uiRoot w1
> requestCounter 40
>
>
> type-Command fired with Selenium-IDE
> <tr>
> <td>type</td>
> <td>//[EMAIL PROTECTED]'w80']/input</td>
> <td>9</td>
> </tr>
> After that the "9" is visible, after pressing manually the button there is
> only ONE Request:
> w7.activeControl w76
> org.eclipse.swt.events.widgetSelected w76
> w76.bounds.x 5
> w76.bounds.y 59
> w76.bounds.width 152
> w76.bounds.height 25
> w1.focusControl w76
> uiRoot w1
> requestCounter 54
>
> and as you can see there is no w80.text in the request and so the new
> Information says "The text you entered: 12" which means the old value is not
> changed.
>
> Is there a javascript-function which I could call to say "do the changed
> value in the next request"?
>
> There is a strange behaviour when "typeKeys"-Selenium-Command follows
> direct after "type"
> Then it works for Selenium IDE but not for Selenium-RC --> Which Versions
> did you use (Selenium IDE or Selenium RC?) Do you use some userextensions
> (e.g. the Qooxdoo Simular- Userextension)? And especially which
> browser/version and OS do you use?
>
> Michael
>
>
>
> -------- Original-Nachricht --------
> > Datum: Fri, 07 Nov 2008 12:36:22 +0100
> > Von: Christian Schmidt <[EMAIL PROTECTED]>
> > An: qooxdoo Development <[email protected]>
> > Betreff: Re: [qooxdoo-devel] qxType, change a textbox
>
> > Hi Michael,
> >
> > I have tried a small demo with RAP 1.1.1.20080917-1625 and I have no
> > problems with it. I have extended the "Hello World" demo from RAP with
> > a text field and a button. When I use selenium to set a text in the text
> > field:
> >
> > <tr>
> > <td>type</td>
> > <td>//[EMAIL PROTECTED]'text']</td>
> > <td>new text value</td>
> > </tr>
> >
> > The text is set in the browser (qooxdoo) and when I manually click on
> > the button. The RAP code:
> >
> > defaultButton.addSelectionListener(new SelectionAdapter() {
> > public void widgetSelected(final SelectionEvent event) {
> > String message = "The text You entered: " + text.getText();
> > MessageDialog.openInformation(parent.getShell(), "Information",
> > message);
> > }
> > });
> >
> > shows a new dialog with the "The text You entered: new text value" text.
> > So the text value property is in sync with RAP and qooxdoo.
> >
> > Can you send more informations, perhaps the code too have a look?
> >
> > Chris
>
>
>
>
> >
> > Michael Willig schrieb:
> > > I've been trying (with no success) to interact with RAP(Version 1.1.1,
> > it contains Qooxdoo (perhaps version 0.7.3)) textboxes with selenium
> (also
> > with qooxdoo extension), for testing automation purposes.(Browser I have
> > tried Firefox 2 and 3)
> > > I'm using the selenium commands: type, typeKeys, keyPress
> > > type and typeKeys show the value changing (visually) in the field, but
> > when some code accesses the text field (in the RAP level), it remains
> > unchanged (text.getText() in Java im RAP-Controls-Demo inside class
> > Button-Tab.java :
> > > defaultButton.addSelectionListener( new SelectionAdapter() {
> > > public void widgetSelected( final SelectionEvent event ) {
> > > String message = "The text You entered: " + text.getText();
> > > MessageDialog.openInformation( group.getShell(),
> > > "Information",
> > > message );
> > > }
> > > } );
> > > )
> > >
> > > I've tried (with selenium) to replicate every event in the input
> field,
> > but with no success (again the value changes in the input field, but the
> > upper-level widget at RAP level remains unchanged):
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>onChange</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>change</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>Change</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>blur</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>onblur</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>textchange</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>ontextchange</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>changeValue</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>onchangevalue</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>_onchange</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>_change</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>_blur</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>_onblur</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>_textchange</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>_ontextchange</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>_changevalue</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>_onchangevalue</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>keyinput</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>focus</td>
> > > </tr>
> > > <tr>
> > > <td>fireEvent</td>
> > > <td>//[EMAIL PROTECTED]'text']</td>
> > > <td>focusLost</td>
> > > </tr>
> > >
> > >
> > > I need something like qxClick in Simulator-Project but for input text
> in
> > Textfields. I tried to write my own qxType but also with no success.
> > >
> > > Any idea?
> > >
> > > Michael
> > >
> > >
> > >
> > >
> >
> -------------------------------------------------------------------------
> > > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > > Build the coolest Linux based applications with Moblin SDK & win great
> > prizes
> > > Grand prize is a trip for two to an Open Source event anywhere in the
> > world
> > > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > > _______________________________________________
> > > qooxdoo-devel mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> > >
> >
> >
> > --
> > Christian Schmidt
> > Software Engineer
> > Core Development :: Web Technologies
> >
> > 1&1 Internet AG
> > Ernst-Frey-Str. 9
> > 76135 Karlsruhe, Germany
> > http://www.1und1.de
> >
> > Amtsgericht Montabaur / HRB 6484
> >
> > Vorst?§nde: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas
> > Gottschlich, Robert Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr.
> Oliver
> > Mauss, Jan Oetjen
> >
> > Aufsichtsratsvorsitzender: Michael Scheeren
> >
> >
> >
> -------------------------------------------------------------------------
> > This SF.Net email is sponsored by the Moblin Your Move Developer's
> > challenge
> > Build the coolest Linux based applications with Moblin SDK & win great
> > prizes
> > Grand prize is a trip for two to an Open Source event anywhere in the
> > world
> > http://moblin-contest.org/redirect.php?banner_id=100&url=/
> > _______________________________________________
> > qooxdoo-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> --
> Michael Willig
> Weidmannstra?üe 14
> 04315 Leipzig
> Tel.: +49 341 30 48 64 9
> Handy: +49 179 6732641
> Fax: +49 121 20 22 87 46
> E-Mail: [EMAIL PROTECTED]
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
--
Michael Willig
Weidmannstraße 14
04315 Leipzig
Tel.: +49 341 30 48 64 9
Handy: +49 179 6732641
Fax: +49 121 20 22 87 46
E-Mail: [EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel