[Laszlo-user] Sending an onclick to a button with a debugger command

Frisco Del Rosario frisco at laszlosystems.com
Mon Jul 9 09:47:09 PDT 2007


   I said:

<button text="click" id="me" onclick="doSomething"/>

Rather than click the button, can I send the button an onclick event
through the debugger input field?

To which P T Withington replied:

me.onclick.sendEvent(me);

This means we can test the results of a buttonclick in Selenium. For
instance:

<canvas debug="true">
      <edittext id="myEdittext" width="300" x="20" y="20"
text="cartman"/>
      <button id="me" text="click" x="20" y="50"
onclick="myEdittext.setAttribute('text', 'kyle')"/>
</canvas>

To test the 'me' button -- does its click change 'cartman' to 'kyle' in
the edittext field? -- we have the Selenese script:

<tr>
	<td>type</td>
	<td>LaszloDebuggerInput</td>
	<td>myEdittext.text=='cartman'</td>
</tr>
<tr>
	<td>click</td>
	<td>//input[@value='eval']</td>
	<td></td>
</tr>
<tr>
	<td>assertTextPresent</td> // does myEdittext.text == cartman?
	<td>true</td>
	<td></td>
</tr>
<tr>
	<td>click</td>
	<td>//input[@value='clear']</td>
	<td></td>
</tr>
<tr>
	<td>type</td>
	<td>LaszloDebuggerInput</td>
	<td>me.onclick.sendEvent(me)</td> // change myEdittext.text to kyle 
with the button
</tr>
<tr>
	<td>click</td>
	<td>//input[@value='eval']</td>
	<td></td>
</tr>
<tr>
	<td>type</td>
	<td>LaszloDebuggerInput</td>
	<td>myEdittext.text=='kyle'</td> // now test for whether 
myEdittext.text changed to kyle
</tr>
<tr>
	<td>click</td>
	<td>//input[@value='eval']</td>
	<td></td>
</tr>
<tr>
	<td>assertTextPresent</td> // success!
	<td>true</td>
	<td></td>
</tr>





--
assertEquals(Frisco Del Rosario, OpenLaszlo tester)


More information about the Laszlo-user mailing list