diff options
-rw-r--r-- | doc/ldtp-tutorial.rst (renamed from doc/ldtp-tutorial) | 390 |
1 files changed, 278 insertions, 112 deletions
diff --git a/doc/ldtp-tutorial b/doc/ldtp-tutorial.rst index c48a866..75974f9 100644 --- a/doc/ldtp-tutorial +++ b/doc/ldtp-tutorial.rst @@ -12,7 +12,10 @@ Linux Desktop Testing Project Tutorial :Date: 2014-03-29 :Version: 1.1 -:Authors: Nagappan Alagappan <nagappan@gmail.com>, Harsha <nharsha@gmail.com>, Premkumar J <prem.jothimani@gmail.com>, Guofu Xu <lavixu@gmail.com>, Surendran M <suren.silverprince@gmail.com>, Vamsi B <vamsi1985@gmail.com>, Christopher Bayliss <christopher.j.bayliss@gmail.com> +:Authors: Nagappan Alagappan <nagappan@gmail.com>, Harsha <nharsha@gmail.com>, +Premkumar J <prem.jothimani@gmail.com>, Guofu Xu <lavixu@gmail.com>, Surendran +M <suren.silverprince@gmail.com>, Vamsi B <vamsi1985@gmail.com>, Christopher +Bayliss <christopher.j.bayliss@gmail.com> :Document: Linux Desktop Testing Project Tutorial @@ -26,17 +29,15 @@ Copyright 2008 - 12 Nagappan Alagappan Copyright 2014 Christopher Bayliss -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Lesser General Public License, Version 2 -or any later version published by the Free Software Foundation; -with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. -A copy of the license is included in the section entitled "GNU -Lesser General Public License". +Permission is granted to copy, distribute and/or modify this document under the +terms of the GNU Lesser General Public License, Version 2 or any later version +published by the Free Software Foundation; with no Invariant Sections, no +Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included +in the section entitled "GNU Lesser General Public License". -You should have received a copy of the GNU GNU Lesser General Public -License along with this documentation; if not, write to the -Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. +You should have received a copy of the GNU GNU Lesser General Public License +along with this documentation; if not, write to the Free Software Foundation, +Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. .. contents:: Table of Contents @@ -45,22 +46,40 @@ Boston, MA 02111-1307, USA. About LDTP ========== -Linux Desktop Testing Project(LDTP) is aimed at producing a high quality automated testing framework and cutting-edge tools that can be used to test GNU/Linux Desktop to improve it. It uses the Accessibility libraries to poke through the application's user interface. This idea has been extended to Microsoft Windows as Cobra and Mac OS X as ATOMac. With this we can proudly say; we have implemented a cross platform GUI testing tool. LDTP is now known to work on Windows, Mac, Linux, Palm Source, Solaris, NetBSD and FreeBSD. +Linux Desktop Testing Project(LDTP) is aimed at producing a high quality +automated testing framework and cutting-edge tools that can be used to test +GNU/Linux Desktop to improve it. It uses the Accessibility libraries to poke +through the application's user interface. This idea has been extended to +Microsoft Windows as Cobra and Mac OS X as ATOMac. With this we can proudly +say; we have implemented a cross platform GUI testing tool. LDTP is now known +to work on Windows, Mac, Linux, Palm Source, Solaris, NetBSD and FreeBSD. -The LDTP core framework uses Appmap(application map) and written test-cases to test an application and gives the status of each test-case as the output. LDTP can test any .NET/GNOME/KDE(QT >= 4.8) application which is accessibility enabled, Mozilla, Open Office/Libre Office, and any Java application(should have a UI based on swing). +The LDTP core framework uses Appmap(application map) and written test-cases to +test an application and gives the status of each test-case as the output. LDTP +can test any .NET/GNOME/KDE(QT >= 4.8) application which is accessibility +enabled, Mozilla, Open Office/Libre Office, and any Java application(should +have a UI based on swing). -We encourage you to join the project and help us to create a robust, reliable and stable test framework for Windows/Unix Desktops. Thanks to the Microsoft, Apple, GNOME and Sun Microsystems Accessibility team for their great work and their continuous support! +We encourage you to join the project and help us to create a robust, reliable +and stable test framework for Windows/Unix Desktops. Thanks to the Microsoft, +Apple, GNOME and Sun Microsystems Accessibility team for their great work and +their continuous support! Audience ======== -It is assumed that the user of this document has little knowledge about UI controls in any GUI application and minimal Windows/Mac OS X/Linux or Unix(Solaris/BSD) knowledge. +It is assumed that the user of this document has little knowledge about UI +controls in any GUI application and minimal Windows/Mac OS X/Linux or +Unix(Solaris/BSD) knowledge. About testing ============= -Testing is a process to identify defects in a(software) system, for more information see http://en.wikipedia.org/wiki/Software_testing. Testing an application multiple times with the same steps can get rather slow and annoying; therefore automating the process can do a better job. +Testing is a process to identify defects in a(software) system, for more +information see http://en.wikipedia.org/wiki/Software_testing. Testing an +application multiple times with the same steps can get rather slow and +annoying; therefore automating the process can do a better job. What is the complexity of GUI testing? @@ -73,7 +92,8 @@ What is the complexity of GUI testing? What type of testing can be done using LDTP? -LDTP can be used to test the functionality of any accessibility enabled application. +LDTP can be used to test the functionality of any accessibility enabled +application. Advantage of accessibility based testing. @@ -86,7 +106,9 @@ Disadvantage of accessibility based testing. What applications can be tested? -As of now, LDTP can test any .NET, GNOME applications which are accessibility enabled, Mozilla, OpenOffice.org/Libreoffice, any Java application(should have swing UI) and KDE applications based on QT 4.8. +As of now, LDTP can test any .NET, GNOME applications which are accessibility +enabled, Mozilla, OpenOffice.org/Libreoffice, any Java application(should have +swing UI) and KDE applications based on QT 4.8. Supported platforms @@ -126,7 +148,8 @@ LDTP Features * LDTP concepts are derived from Software Automation Framework Support. * LDTP supports verification of actions performed(guiexist(), verifystate, etc). -* Writing test scripts is very easy, and the script writer doesn't need to know about the object hierarchy. +* Writing test scripts is very easy, and the script writer doesn't need to know + about the object hierarchy. * CPU/Memory performance monitoring of application-under-test can be measured. LDTP on web @@ -201,7 +224,8 @@ Build and install LDTP on a Linux/Mac OS X environment: Setup LDTP from binary ---------------------- -Download latest Mac OS X, Windows, RPM, Deb, Gentoo, Solaris package from http://ldtp.freedesktop.org/wiki/Download +Download latest Mac OS X, Windows, RPM, Deb, Gentoo, Solaris package from +http://ldtp.freedesktop.org/wiki/Download Architecture ============ @@ -209,16 +233,23 @@ Architecture LDTP Overall Architecture ------------------------- -Test scripts uses LDTP API interface, which in-turn communicate to LDTP engine either by UNIX socket or by TCP socket. LDTP engine talks to Application under test(AUT) using AT-SPI library. +Test scripts uses LDTP API interface, which in-turn communicate to LDTP engine +either by UNIX socket or by TCP socket. LDTP engine talks to Application under +test(AUT) using AT-SPI library. LDTP Internals -------------- LDTP Clients can talk to LDTP engine with XML RPC protocol. -Most of LDTP ideas are implemented from http://safsdev.sf.net. Most of the commands takes at-least 2 arguments. First argument will be context(window in which we want to operate) and the second argument will be component(object in which we want to operate, based on the current context). +Most of LDTP ideas are implemented from http://safsdev.sf.net. Most commands +at-least 2 arguments. First argument will be context(window in which we want to +operate) and the second argument will be component(object in which we want to +operate, based on the current context). -Example: click('\*-gedit', 'btnNew') # Click operation will be performed on a window which is having \*-gedit(regexp) and in that window object name 'New', which is of type 'push button'. +Example: click('\*-gedit', 'btnNew') # Click operation will be performed on a +window which is having \*-gedit(regexp) and in that window object name 'New', +which is of type 'push button'. .. image:: images/LDTP.png :scale: 125 % @@ -228,22 +259,32 @@ Example: click('\*-gedit', 'btnNew') # Click operation will be performed on a wi Server ------ -When a test script is started, the LDTP client will establish a connection with the LDTP engine using AF_UNIX/AF_INET. +When a test script is started, the LDTP client will establish a connection with +the LDTP engine using AF_UNIX/AF_INET. Client Handler -------------- -Whenever a command is executed from the script, the client frames the XML data and send it to the server. LDTP engine parses the command request from the client and invoke the respective Component Handler. +Whenever a command is executed from the script, the client frames the XML data +and send it to the server. LDTP engine parses the command request from the +client and invoke the respective Component Handler. Component Handler ----------------- -Each individual component handlers uses the AT-SPI libraries to communicate to the respective application. Based on the execution status, success or failure will be notified as a response(in XML format) to the client. In few cases the requested data from the respective component will be returned to the client, based on the request(example: gettextvalue). +Each individual component handlers uses the AT-SPI libraries to communicate to +the respective application. Based on the execution status, success or failure +will be notified as a response(in XML format) to the client. In few cases the +requested data from the respective component will be returned to the client, +based on the request(example: gettextvalue). Event Handler ------------- -For unexpected windows(example: connection reset by peer /connection timed out dialogs) can be handled by registering a callback function and the respective callback function will be called, whenever the registered window with the title appears and even this window could be based on regular expression. +For unexpected windows(example: connection reset by peer /connection timed out +dialogs) can be handled by registering a callback function and the respective +callback function will be called, whenever the registered window with the title +appears and even this window could be based on regular expression. LDTP conventions ================ @@ -251,7 +292,11 @@ LDTP conventions Appmap ------ -'Appmap' [Application Map in short] is a text based representation of the GUI which is under testing. Each and every UI control viz., Button, Text Box etc., are represented using predefined conventions(which are listed in the table below) along with their parent UI object information. At runtime, a particular UI control is accessed by using the Appmap generated for the GUI under testing. +'Appmap' [Application Map in short] is a text based representation of the GUI +which is under testing. Each and every UI control viz., Button, Text Box etc., +are represented using predefined conventions(which are listed in the table +below) along with their parent UI object information. At runtime, a particular +UI control is accessed by using the Appmap generated for the GUI under testing. For more details about Appmap refer to: @@ -425,7 +470,8 @@ Appmap convention Example Applications ==================== -Examples will use gedit. You can download it from https://wiki.gnome.org/Apps/Gedit#Download. +Examples will use gedit. You can download it from +https://wiki.gnome.org/Apps/Gedit#Download. If you are using a linux distro, the install gedit with you package manager. @@ -447,7 +493,8 @@ Different window types 3. Alert(dlg) 4. Font Chooser(dlg) 5. File Chooser(dlg) -6. Window(This type in general does not have any associated title, so we need to represent them using index - dlg) +6. Window(This type in general does not have any associated title, so we need + to represent them using index - dlg) Glob pattern support ~~~~~~~~~~~~~~~~~~~~ @@ -455,8 +502,10 @@ Glob pattern support Window name can be clubbed with glob patterns(* or ?) EXAMPLE: - 1. \*-gedit means the title has -gedit in it, BUT can have anything before it or after it. - 2. ????-gedit means the title has -gedit in it, AND has four cractors before it. + 1. \*-gedit means the title has -gedit in it, BUT can have anything before + it or after it. + 2. ????-gedit means the title has -gedit in it, AND has four cractors + before it. .. NOTE:: You can use \* or ? anywhere for the title name. @@ -468,8 +517,11 @@ Different ways of representing window name 3. Window type, glob expression and partial window title(Ex: 'frm\*-gedit') 4. Glob pattern and partial window title(Ex: '\*-gedit') 5. Window type, partial window title and glob pattern(Ex: 'frmnew1\*') -6. Window type, window title and index(If two windows of same title exist at same time. Ex: First window name 'dlgAppoinment', Second window name 'dlgAppoinment1') -7. Window type and index(only if window does not have any accessible title, Ex: 'dlg0') +6. Window type, window title and index(If two windows of same title exist at + same time. Ex: First window name 'dlgAppoinment', Second window name + 'dlgAppoinment1') +7. Window type and index(only if window does not have any accessible title, Ex: + 'dlg0') Window name formats ~~~~~~~~~~~~~~~~~~~ @@ -478,17 +530,20 @@ If window label contains space or new line characters, they will be stripped. Example: 1. 'saved-doc - gedit\*', will be represented as 'saved-doc-gedit\*' - 2. 'Unsaved Document 1 - gedit*', will be represented as 'UnsavedDocument1-gedit\*' + 2. 'Unsaved Document 1 - gedit*', will be represented as + 'UnsavedDocument1-gedit\*' Object name ----------- -Object(the type of control in which we want to operate) can be identified either with a label or by an associated label. +Object(the type of control in which we want to operate) can be identified +either with a label or by an associated label. Label ~~~~~ -In general menu/menu item/push button/toggle button type controls can be accessed through its label. +In general menu/menu item/push button/toggle button type controls can be +accessed through its label. Example: @@ -502,7 +557,8 @@ Example: Label by/for(associated label) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In general text/tables/check box/radio button/spin button/combo box controls can be accessed using the associated label only. +In general text/tables/check box/radio button/spin button/combo box controls +can be accessed using the associated label only. Example: @@ -517,7 +573,8 @@ Example: Object name with out label/associated label accessing via index ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If a control does not have any label or associated label, then it can be accessed using index. +If a control does not have any label or associated label, then it can be +accessed using index. Example: @@ -531,7 +588,11 @@ Example: Object name with index ~~~~~~~~~~~~~~~~~~~~~~ -In some cases, a control type can be present in multiple places in the same window and chances that it may have same label too in that case, the first control can be accessed just with the default notation, but the second control and further can be accessed with the format control type, label or associated label and index starting from 1. +In some cases, a control type can be present in multiple places in the same +window and chances that it may have same label too in that case, the first +control can be accessed just with the default notation, but the second control +and further can be accessed with the format control type, label or associated +label and index starting from 1. Example: @@ -544,7 +605,10 @@ Example: Object name with window id(Windows only) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Object can be identified with window id, which is unique across all the application that are currently running, even on i18n/l10n environment. Object name when passed to the API, it should start with # and then the unique number, for the widget. +Object can be identified with window id, which is unique across all the +application that are currently running, even on i18n/l10n environment. Object +name when passed to the API, it should start with # and then the unique number, +for the widget. Example:: @@ -553,7 +617,9 @@ Example:: Object identification with object type and index ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -On a window, identify the control with index of widget type. Object name format passed should be, LDTP convention object type and object index, respective to the given object type. +On a window, identify the control with index of widget type. Object name format +passed should be, LDTP convention object type and object index, respective to +the given object type. Example:: @@ -563,7 +629,8 @@ Example:: Object name formats ~~~~~~~~~~~~~~~~~~~ -If object label or associated label contains space, dot, colon, under score or new line characters, they will be stripped. +If object label or associated label contains space, dot, colon, under score or +new line characters, they will be stripped. Example:: @@ -574,12 +641,16 @@ Example:: Accessibility library ===================== -LDTP uses accessibility libraries(at-spi) available in GNOME environment. Using accessibility we can get the information about the application and its current state(property). We can be able to poke through each layer in any application, if and only if, the application has accessibility enabled. +LDTP uses accessibility libraries(at-spi) available in GNOME environment. Using +accessibility we can get the information about the application and its current +state(property). We can be able to poke through each layer in any application, +if and only if, the application has accessibility enabled. Enabling accessibility ====================== -**GNOME 2.x:** Go to System > Preferences > Assistive Technologies and enable Assistive Technology. +**GNOME 2.x:** Go to System > Preferences > Assistive Technologies and enable +Assistive Technology. **GNOME 3.x:** Run the following command from command line to enable accessibility @@ -587,16 +658,22 @@ Enabling accessibility gsettings set org.gnome.desktop.interface toolkit-accessibility true -**Microsoft Windows:** No need to change any settings, as accessibility is enabled by default. +**Microsoft Windows:** No need to change any settings, as accessibility is +enabled by default. -**Mac OSX:** System wide accessibility must be enabled. Check the check box: System Preferences > Universal Access > Enable access for assistive devices. Failure to enable this will result in ErrorAPIDisabled exceptions during some module usage. +**Mac OSX:** System wide accessibility must be enabled. Check the check box: +System Preferences > Universal Access > Enable access for assistive devices. +Failure to enable this will result in ErrorAPIDisabled exceptions during some +module usage. Drawing 2: Screenshot of Assisstive technology preferences dialog Importing LDTP modules ====================== -We prefer to import everything, if we do we can just directly use all the ldtp functions just by calling their name. If we import the module as 'import ldtp', then we need to call the corresponding function as ldtp.<function_name> +We prefer to import everything, if we do we can just directly use all the ldtp +functions just by calling their name. If we import the module as 'import ldtp', +then we need to call the corresponding function as ldtp.<function_name> To import ldtp in python, do: @@ -611,7 +688,8 @@ Example 1: .. code-block:: python >>> from ldtp import * - >>> selectmenuitem('*-gedit', 'mnuFile;mnuNew') + >>> selectmenuitem('\*-gedit', 'mnuFile;mnuNew') + Example 2: @@ -628,7 +706,7 @@ Example 2: launchapp('gedit') # Now we find it and make sure it is open. - gedit_win = locate('*gedit') + gedit_win = locate('\*gedit') gedit_win.waittillguiexist() # Now we type into gedit. @@ -636,7 +714,7 @@ Example 2: text_field.enterstring("G'Day mate!") # Save a picture to prove we did it. - imagecapture('*gedit', '/tmp/foo.png') + imagecapture('\*gedit', '/tmp/foo.png') # Quit gedit. quit = gedit_win.getchild('mnuQuit') @@ -658,29 +736,42 @@ Call a function to perform an operation LDTP generally operates on the given object in a particular window. -To select a menu item, you need to call the selectmenuitem function. For example, to select open menu item in gedit application, call the below function: +To select a menu item, you need to call the selectmenuitem function. For +example, to select open menu item in gedit application, call the below +function: .. code-block:: python >>> selectmenuitem('frmUnsavedDocument1-gedit', 'mnuFile;mnuOpen') -When you call the above a new dialog box will be poped up, you can verify whether the window is opened or not either by guiexist() or by waittillguiexist(). +When you call the above a new dialog box will be poped up, you can verify +whether the window is opened or not either by guiexist() or by +waittillguiexist(). -.. NOTE:: The guiexist() function immediately returns either 1(window exist) or 0(window does not exist), waittillguiexist() waits for the window to appear. Wait time out is by default 30 seconds. This default time out can be either increased on decreased using GUI_TIMEOUT. +.. NOTE:: The guiexist() function immediately returns either 1(window exist) or + 0(window does not exist), waittillguiexist() waits for the window to + appear. Wait time out is by default 30 seconds. This default time + out can be either increased on decreased using GUI_TIMEOUT. -If you want to operate on a push button in a window, you need to call click(), e.g.: To press 'Cancel' button in a GTK Open File Selector dialog: +If you want to operate on a push button in a window, you need to call click(), +e.g.: To press 'Cancel' button in a GTK Open File Selector dialog: .. code-block:: python >>> click('dlgOpenFile', 'btnCancel') -When you do the above operation the GTK File selector dialog disappears. To verify whether the window actually quits or not use: +When you do the above operation the GTK File selector dialog disappears. To +verify whether the window actually quits or not use: .. code-block:: python >>> waittillguinotexist()() -If you modify any opened file in gedit, the window title will be modified. To continue operating on the window you need to change your context of operation. Reason: As you are aware that LDTP works based on individual window, the context of window will be changed, when the title changes. To over come this use: +If you modify any opened file in gedit, the window title will be modified. To +continue operating on the window you need to change your context of operation. +Reason: As you are aware that LDTP works based on individual window, the +context of window will be changed, when the title changes. To over come this +use: .. code-block:: python @@ -698,12 +789,14 @@ Edit your current opened file using: >>> settextvalue('frmUnsavedDocument1-gedit', 'txt0', 'Testing editing') -This will change the window title. Note, before doing the above operation, title will be 'Unsaved Document 1 - gedit' and after editing the title will look like '\*Unsaved Document 1 - gedit'. To further +This will change the window title. Note, before doing the above operation, +title will be 'Unsaved Document 1 - gedit' and after editing the title will +look like '\*Unsaved Document 1 - gedit'. To further operate on the same window, use: .. code-block:: python - >>> setcontext('Unsaved Document 1 - gedit', '*Unsaved Document 1 - gedit') + >>> setcontext('Unsaved Document 1 - gedit', '\*Unsaved Document 1 - gedit') So that you can continue using the same window name, for example: @@ -711,7 +804,10 @@ So that you can continue using the same window name, for example: >>> selectmenuitem('frmUnsavedDocument1-gedit', 'mnuFile;mnuSaveAs') -The above function will invoke the GTK save dialog box. If any of the action releated functions(example: selectmenuitem, click, settextvalue) fail, an exception is raised. It has to be handled by the program to either continue operating on execution or just halt. +The above function will invoke the GTK save dialog box. If any of the action +releated functions(example: selectmenuitem, click, settextvalue) fail, an +exception is raised. It has to be handled by the program to either continue +operating on execution or just halt. LDTP API -------- @@ -726,12 +822,13 @@ Identifying controls To operate on a window, first thing we need to know is the window title. -In the following picture you could notice red colored eclipse mark is the window title. +In the following picture you could notice red colored eclipse mark is the +window title. .. code-block:: python >>> from ldtp import * - >>> guiexist('*-gedit') + >>> guiexist('\*-gedit') 1 >>> guiexist('frmUnsavedDocument1-gedit') 1 @@ -745,35 +842,43 @@ In the following picture you could notice red colored eclipse mark is the window Push button ----------- -To operate on an object inside gedit window, we need to know the object information. +To operate on an object inside gedit window, we need to know the object +information. -To click on open push button in gedit tool bar control, we need to use click API with window name as first argument and object name as second argument. The above command does the click operation. Information to be gathered is Window name(Unsaved Document 1 – gedit) and push button control(Open). +To click on open push button in gedit tool bar control, we need to use click +API with window name as first argument and object name as second argument. The +above command does the click operation. Information to be gathered is Window +name(Unsaved Document 1 – gedit) and push button control(Open). .. code-block:: python >>> from ldtp import * - >>> click('*-gedit', 'btnOpen') + >>> click('\*-gedit', 'btnOpen') 1 Menu item --------- -To select a menu item under a menu in a window we need to use selectmenuitem API. +To select a menu item under a menu in a window we need to use selectmenuitem +API. -Informations to be gathered: Window name(Unsaved Document 1 – gedit), menu control(File), menu item control(New). +Informations to be gathered: Window name(Unsaved Document 1 – gedit), menu +control(File), menu item control(New). -Incase of menu, we handle them in hierarchy. So, to access 'New' menu item, we need 'File' menu control too. +Incase of menu, we handle them in hierarchy. So, to access 'New' menu item, we +need 'File' menu control too. .. code-block:: python >>> from ldtp import * - >>> selectmenuitem('*-gedit', 'mnuFile;mnuNew') + >>> selectmenuitem('\*-gedit', 'mnuFile;mnuNew') 1 Toggle button ------------- -To operate on a toggle button with a click action, information required are window name(Open Files...) toggle button control(Type a file name). +To operate on a toggle button with a click action, information required are +window name(Open Files...) toggle button control(Type a file name). .. code-block:: python @@ -784,7 +889,9 @@ To operate on a toggle button with a click action, information required are wind Text control ------------ -To set a text value in a text box, information like window name(Open Files...), text controls associated label(Location:) and the actual text to be placed(Class1.cs). +To set a text value in a text box, information like window name(Open Files...), +text controls associated label(Location:) and the actual text to be +placed(Class1.cs). .. code-block:: python @@ -795,7 +902,9 @@ To set a text value in a text box, information like window name(Open Files...), Table control ------------- -To select a row from the table of GTK open file selector, we need to collect information like, Window name(Open Files...), table name(Files – circled with blue color), row to be selected(Class1.cs). +To select a row from the table of GTK open file selector, we need to collect +information like, Window name(Open Files...), table name(Files – circled with +blue color), row to be selected(Class1.cs). .. code-block:: python @@ -806,7 +915,9 @@ To select a row from the table of GTK open file selector, we need to collect inf Push button ----------- -After selecting the file name, to open the file contents, we need to click on Open push button control. For doing this operation we need to gather informations like Window name(Open Files...), push button label name(Open). +After selecting the file name, to open the file contents, we need to click on +Open push button control. For doing this operation we need to gather +informations like Window name(Open Files...), push button label name(Open). .. code-block:: python @@ -817,7 +928,8 @@ After selecting the file name, to open the file contents, we need to click on Op Check box --------- -To click on a check box control, we need to collect informations like window name(gedit Preferences), check box associated label name(Display line numbers). +To click on a check box control, we need to collect informations like window +name(gedit Preferences), check box associated label name(Display line numbers). .. code-block:: python @@ -840,7 +952,8 @@ To click on a check box control, we need to collect informations like window nam Spin button ----------- -To operate on a spin button, we need to collect information like Window name(gedit Preferences), spin button control name(Right margin at column). +To operate on a spin button, we need to collect information like Window +name(gedit Preferences), spin button control name(Right margin at column). .. code-block:: python @@ -855,7 +968,10 @@ To operate on a spin button, we need to collect information like Window name(ged Page tab -------- -To operate on a page tab list, we need to collect information like window name(gedit Preferences), page tab list name(ptl0 in this case, as there are no label or associated label with this page tab list control), page tab name or index starting from 0. +To operate on a page tab list, we need to collect information like window +name(gedit Preferences), page tab list name(ptl0 in this case, as there are no +label or associated label with this page tab list control), page tab name or +index starting from 0. .. code-block:: python @@ -870,39 +986,45 @@ To operate on a page tab list, we need to collect information like window name(g Check menu item --------------- -To operate on check menu item, we need to gather information like window name(Unsaved Document 1 – gedit), menu name(View), check menu item name(Side Pane). +To operate on check menu item, we need to gather information like window +name(Unsaved Document 1 – gedit), menu name(View), check menu item name(Side +Pane). .. code-block:: python >>> from ldtp import * - >>> selectmenuitem('*-gedit', 'mnuView;mnuSidePane') + >>> selectmenuitem('\*-gedit', 'mnuView;mnuSidePane') 1 - >>> menuuncheck('*-gedit', 'mnuView;mnuSidePane') + >>> menuuncheck('\*-gedit', 'mnuView;mnuSidePane') 1 .. code-block:: python >>> from ldtp import * - >>> menucheck('*-gedit', 'mnuView;mnuStatusbar') + >>> menucheck('\*-gedit', 'mnuView;mnuStatusbar') 1 Radio menu item --------------- -To operate on a radio menu item control, we need to gather informations like window name(Unsaved Document 1 – gedit), menu name(Documents), menu item name(Class1.cs – assuming that Class1.cs is currently opened). +To operate on a radio menu item control, we need to gather informations like +window name(Unsaved Document 1 – gedit), menu name(Documents), menu item +name(Class1.cs – assuming that Class1.cs is currently opened). .. code-block:: python >>> from ldtp import * - >>> selectmenuitem('*-gedit', 'mnuDocuments;mnuClass1.cs') + >>> selectmenuitem('\*-gedit', 'mnuDocuments;mnuClass1.cs') 1 - >>> menucheck('*-gedit', 'mnuDocuments;mnuClass1.cs') + >>> menucheck('\*-gedit', 'mnuDocuments;mnuClass1.cs') 1 Combo box – Menu item --------------------- -To select a menu item under a combo box, we need to gather informations like window name(Open Files...), combo box name(Character Coding), menu item name(Current Locale). +To select a menu item under a combo box, we need to gather informations like +window name(Open Files...), combo box name(Character Coding), menu item +name(Current Locale). .. code-block:: python @@ -913,7 +1035,10 @@ To select a menu item under a combo box, we need to gather informations like win Combo box – List item --------------------- -To operate on list item under a combo box control, we need to gather informations like window name(Find), Combo box control name(Search for), list item existing content or list item index or new item name(OdbcMetaDataCollectionName.cs) +To operate on list item under a combo box control, we need to gather +informations like window name(Find), Combo box control name(Search for), list +item existing content or list item index or new item +name(OdbcMetaDataCollectionName.cs) .. code-block:: python @@ -941,13 +1066,28 @@ Application to be tested can be launched using LDTP API launchapp. GUI exist --------- -To check a GUI(window) exist, you can use this guiexist() API. Also it has different flavors like waittillguiexist(), waittillguinotexist(). - -guiexist() function checks whether the given window exists or not. If exist returns 1, else returns 0. - -waittillguiexist() function will wait for the given window to appear. If appeared returns 1, else returns 0. Difference between guiexist() and waittillguiexist() is, guiexist() returns immediately, but waittillguiexist() will wait for a max of 30 seconds for a window to appear. Note: On doing some operation, if the expected result is, a window will be pop-ed up, then it is recommended to use waittillguiexist(), instead of wait or sleep. Reason: wait or sleep will wait till the time period, but waittillguiexist(), will return immediately once the window appears. - -waittillguinotexist() function will wait for the given window to close. If closed returns 1, else returns 0. waittillguinotexist() will wait for a max of 30 seconds for a window to close. Note: On doing some operation, if the expected result is, an existing window will be closed, then it is recommended to use waittillguinotexist(), instead of wait or sleep. Reason: wait or sleep will wait till the time period, but waittillguinotexist(), will return immediately once the window closed. +To check a GUI(window) exist, you can use this guiexist() API. Also it has +different flavors like waittillguiexist(), waittillguinotexist(). + +guiexist() function checks whether the given window exists or not. If exist +returns 1, else returns 0. + +waittillguiexist() function will wait for the given window to appear. If +appeared returns 1, else returns 0. Difference between guiexist() and +waittillguiexist() is, guiexist() returns immediately, but waittillguiexist() +will wait for a max of 30 seconds for a window to appear. Note: On doing some +operation, if the expected result is, a window will be pop-ed up, then it is +recommended to use waittillguiexist(), instead of wait or sleep. Reason: wait +or sleep will wait till the time period, but waittillguiexist(), will return +immediately once the window appears. + +waittillguinotexist() function will wait for the given window to close. If +closed returns 1, else returns 0. waittillguinotexist() will wait for a max of +30 seconds for a window to close. Note: On doing some operation, if the +expected result is, an existing window will be closed, then it is recommended +to use waittillguinotexist(), instead of wait or sleep. Reason: wait or sleep +will wait till the time period, but waittillguinotexist(), will return +immediately once the window closed. Timeout ------- @@ -955,12 +1095,16 @@ Timeout GUI timeout ~~~~~~~~~~~ -GUI timeout, is the default timeout settings used, by waittillguiexist() and waittillguinotexist() functions. This function will wait for the specified number of seconds, for the window to either appear or disappear. Default timeout period is 30 seconds. +GUI timeout, is the default timeout settings used, by waittillguiexist() and +waittillguinotexist() functions. This function will wait for the specified +number of seconds, for the window to either appear or disappear. Default +timeout period is 30 seconds. This default timeout period that can be modified: * By setting the environment variable GUI_TIMEOUT to whatever seconds. -* By passing a value to guiTimeOut argument of waittillguiexist() or waittillguinotexist() functions. +* By passing a value to guiTimeOut argument of waittillguiexist() or + waittillguinotexist() functions. * By calling guitimeout function. * When invoking LDTP engine, use -g option. @@ -974,7 +1118,7 @@ This default timeout period that can be modified: .. code-block:: python - waittillguiexist('*-gedit', guiTimeOut=30) + waittillguiexist('\*-gedit', guiTimeOut=30) waittillguinotexist('dlgOpenFiles...', guiTimeOut=30) *Example 3* @@ -992,7 +1136,9 @@ This default timeout period that can be modified: OBJ timeout ~~~~~~~~~~~ -OBJ timeout, is the default timeout settings used, internally. This function will wait for the specified number of seconds, for the object inside a window to appear. Default timeout period is 5 seconds. +OBJ timeout, is the default timeout settings used, internally. This function +will wait for the specified number of seconds, for the object inside a window +to appear. Default timeout period is 5 seconds. This default timeout period that can be modified: @@ -1022,7 +1168,13 @@ ldtp -o 5 Generate raw keyboard events ---------------------------- -In some cases, the window we are trying to operate may not be accessibility enabled or we may need to generate non-printable keys(ALT, CTRL, ENTER, BACKSPACE, ESC, F1-F12, SHIFT, CAPS LOCK, TAB, PAGE UP, PAGE DOWN, HOME, END, RIGHT / LEFT / UP / DOWN ARROW KEYS, INS, DEL). We can use generatekeyevent function or enterstring function to simulate the key events, as if the user typed. Note: All the non-printable characters will be enclosed with in angular brackets. +In some cases, the window we are trying to operate may not be accessibility +enabled or we may need to generate non-printable keys(ALT, CTRL, ENTER, +BACKSPACE, ESC, F1-F12, SHIFT, CAPS LOCK, TAB, PAGE UP, PAGE DOWN, HOME, END, +RIGHT / LEFT / UP / DOWN ARROW KEYS, INS, DEL). We can use generatekeyevent +function or enterstring function to simulate the key events, as if the user +typed. Note: All the non-printable characters will be enclosed with in angular +brackets. *Example 1* @@ -1047,11 +1199,11 @@ In some cases, the window we are trying to operate may not be accessibility enab >>> from ldtp import * >>> launchapp('gedit') 1 - >>> waittillguiexist('*-gedit') + >>> waittillguiexist('\*-gedit') 1 >>> enterstring('<alt><tab>') 1 - >>> enterstring('*-gedit', 'txt0', '<caps>Testing enterstring API<enter>') + >>> enterstring('\*-gedit', 'txt0', '<caps>Testing enterstring API<enter>') 1 >>> generatekeyevent('<alt><tab>') 1 @@ -1059,7 +1211,9 @@ In some cases, the window we are trying to operate may not be accessibility enab Generate raw mouse events ------------------------- -To generate raw mouse events of different types like, b1c, b1d, b2c, b2d, b3c, b3d, X and Y of screen co-ordinates has to be provided. Here b is button, c is single click, d is double click. +To generate raw mouse events of different types like, b1c, b1d, b2c, b2d, b3c, +b3d, X and Y of screen co-ordinates has to be provided. Here b is button, c is +single click, d is double click. .. code-block:: python @@ -1072,7 +1226,12 @@ To generate raw mouse events of different types like, b1c, b1d, b2c, b2d, b3c, b Application information ----------------------- -On calling getapplist, will get all the accessibility application name that are currently running. To get window list for which the application map's are gathered and stored in local cache, use getwindowlist. To get all the object list under a window, use getobjectlist API. To get a list of properties available under an object, use getobjectinfo. To get the property of an object, use getobjectproperty. +On calling getapplist, will get all the accessibility application name that are +currently running. To get window list for which the application map's are +gathered and stored in local cache, use getwindowlist. To get all the object +list under a window, use getobjectlist API. To get a list of properties +available under an object, use getobjectinfo. To get the property of an object, +use getobjectproperty. .. code-block:: python @@ -1084,22 +1243,25 @@ On calling getapplist, will get all the accessibility application name that are u'nm-applet', u'soffice.bin'] >>> getwindowlist() [u'frmUnsavedDocument1-gedit'] - >>> getobjectlist('*-gedit') + >>> getobjectlist('\*-gedit') ... - >>> getobjectinfo('*-gedit', 'btnNew') + >>> getobjectinfo('\*-gedit', 'btnNew') [u'child_index', u'class', u'description', u'parent', u'label'] - >>> getobjectproperty('*-gedit', 'btnNew', 'class') + >>> getobjectproperty('\*-gedit', 'btnNew', 'class') 'New' Callback – On new window creation --------------------------------- -Register a callback event, when a window with given title is created. Glob type pattern can be given as title name. +Register a callback event, when a window with given title is created. Glob type +pattern can be given as title name. Advantage --------- -Unexpected window can be easily handled using this. For example, the password dialog box of Evolution, connection reset by peer dialog, application crash dialog, etc. +Unexpected window can be easily handled using this. For example, the password +dialog box of Evolution, connection reset by peer dialog, application crash +dialog, etc. Example ------- @@ -1124,8 +1286,8 @@ Example # Callback registration onwindowcreate('Replace', cb) # General operation, which will invoke a window - click('*gedit', 'btnReplace') - click('*gedit', 'btnOpen') + click('\*gedit', 'btnReplace') + click('\*gedit', 'btnOpen') waittillguiexist('dlgOpenFiles...') click('dlgOpenFiles...', 'btnClose') # Wait for callback to complete, if invoked @@ -1160,9 +1322,9 @@ Example script try: launchapp('gedit') - if waittillguiexist('*-gedit') == 0: + if waittillguiexist('\*-gedit') == 0: raise LdtpExecutionError('Gedit window does not exist') - selectmenuitem('*-gedit', 'mnuFile;mnuOpen') + selectmenuitem('\*-gedit', 'mnuFile;mnuOpen') if waittillguiexist('dlgOpenFiles') == 0: raise LdtpExecutionError('Open Files dialog does not exist') selectrow('dlgOpenFiles...', 'tblFiles', fileName [0]) @@ -1193,7 +1355,10 @@ Example Suggestions from LDTP team ========================== -When a new window is expected after an operation, we suggest to use waittillguiexist() and on some operation, if a window is expected to close we suggest to use waittillguinotexist(). In both cases, the time-out period is 30 seconds. This value can be modified – refer LDTP API reference. +When a new window is expected after an operation, we suggest to use +waittillguiexist() and on some operation, if a window is expected to close we +suggest to use waittillguinotexist(). In both cases, the time-out period is 30 +seconds. This value can be modified – refer LDTP API reference. How to operate LDTP from a remote system ======================================== @@ -1246,7 +1411,8 @@ Follow one of the options in the client side to communicate to LDTP engine Troubleshooting LDTP ==================== -In-case, if you want to see whats happening on executing some LDTP commands, follow these steps. +In-case, if you want to see whats happening on executing some LDTP commands, +follow these steps. In a terminal: |