onwindowcreate

Syntax

onwindowcreate ('<window title>', '<callback function>'[, <arguments to callback function>])

Description

Watch, window create event, with the given title and call the respective callback function. Window title supports regular expression too.

Return values:
1 on success, else LdtpExecutionError exception

Refer: http://cgit.freedesktop.org/ldtp/ldtp/tree/src/client-handler.c http://cgit.freedesktop.org/ldtp/ldtp/tree/src/ldtp-gui.c

Example

With respect to gedit application, replace dialog

 from ldtp import *
 import threading
 callbackRunning = threading.Event()
 callbackRunning.clear()
 callbackState = threading.Event()
 callbackState.clear()
 def cb():
      callbackState.set()
      waittillguiexist('dlgReplace')
      click('dlgReplace', 'btnClose')
      callbackState.clear()
      callbackRunning.set()
      print 'callbackend'
 def cbwithvarargs(*args):
      for arg in args:
              print arg
      print 'callbackend'
 onwindowcreate('dlgReplace', cb)
 onwindowcreate('dlgFind', cbwithvarargs, 'test', 'var', 'args')
 click('*gedit', 'btnReplace')
 click('*gedit', 'btnFind')
 waittillguiexist('dlgFind')
 click('dlgFind', 'btnClose')
 if callbackState.isSet():
      print 'Waiting for callback to complete'
      callbackRunning.wait()
      print 'callbackset'
 print 'test end'
 
Author:
Nagappan Alagappan <nagappan@gmail.com>


Linux Desktop Testing Project