Ejemplo n.º 1
0
 def capture_image(self, image_name="", window=""):
     # capture image and name it by time
     time.sleep(5.0)
     image_path = GUI_IMG_PATH
     if not os.path.exists(GUI_IMG_PATH):
         os.makedirs(GUI_IMG_PATH)
     picture_name = time.strftime('%Y%m%d%H%M%S') + "-" + image_name + ".png"
     ldtp.imagecapture(window, image_path + "/" + picture_name)
     logger.info("capture image: %s to runtime directory" % picture_name)
Ejemplo n.º 2
0
def do_screenshot(app, app_name):
    show("Next up is: {} ({})".format(app_name, app))
    l.launchapp(app)
    l.waittillguiexist(app_name)
    if video:
        time.sleep(5)
    l.imagecapture(app_name, os.path.join(basePath, app + ".png"))
    full_screen=l.imagecapture()
    shutil.move(full_screen, os.path.join(basePath, "fullscreen-" + app + ".png"))
    l.generatekeyevent("<alt><f4>")
Ejemplo n.º 3
0
def after_step(context, step):
    if os.environ.get("SCREENSHOTS") == "ALWAYS":
        directory=os.path.join(os.path.abspath(os.curdir),"Screenshots",context._stack[1]["feature"].name, 
                  "{}_{}_{}".format(context._stack[0]["scenario"].filename.replace(".feature",""), context._stack[0]["scenario"].line, context._stack[0]["scenario"].name))

        if not os.path.exists(directory):
            os.makedirs(directory)

        filename=os.path.join(directory, "{}_{}_{}_{}.png".format( step.filename.replace(".feature",""),step.line, step.step_type, step.name))
        l.imagecapture(None,filename)

    if DEBUG_ON_ERROR and step.status == "failed":
        # -- ENTER DEBUGGER: Zoom in on failure location.
        import pdb
        pdb.set_trace()
Ejemplo n.º 4
0
    def image_capture_2(self,
                        window_name=None,
                        out_file=None,
                        x=0,
                        y=0,
                        width=None,
                        height=None):
        """
        Captures screenshot of the whole desktop or given window

        @param window_name: Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type window_name: string

        @:argument out_file: the capture screenshot file save path.

        @type out_file: string

        @param x: x co-ordinate value

        @type x: int

        @param y: y co-ordinate value

        @type y: int

        @param width: width co-ordinate value

        @type width: int

        @param height: height co-ordinate value

        @type height: int

        @return: screenshot with base64 encoded for the client

        @rtype: string
        """
        try:
            self._info(
                "screen capture without embedding, and the out file: %s " %
                out_file)
            self._html('the capture picture is <a href="%s">%s</a>' %
                       (out_file, out_file))
            return ldtp.imagecapture(window_name, out_file, x, y, width,
                                     height)
        except LdtpExecutionError:
            raise LdtpExecutionError("image capture failed")
Ejemplo n.º 5
0
def after_step(context, step):
    if os.environ.get("SCREENSHOTS") == "ALWAYS":
        directory = os.path.join(
            os.path.abspath(os.curdir), "Screenshots",
            context._stack[1]["feature"].name, "{}_{}_{}".format(
                context._stack[0]["scenario"].filename.replace(".feature", ""),
                context._stack[0]["scenario"].line,
                context._stack[0]["scenario"].name))

        if not os.path.exists(directory):
            os.makedirs(directory)

        filename = os.path.join(
            directory,
            "{}_{}_{}_{}.png".format(step.filename.replace(".feature", ""),
                                     step.line, step.step_type, step.name))
        l.imagecapture(None, filename)

    if DEBUG_ON_ERROR and step.status == "failed" and os.environ.get(
            "TRAVIS") != "true":
        # -- ENTER DEBUGGER: Zoom in on failure location.
        import pdb
        pdb.set_trace()
    signal.alarm(0)
Ejemplo n.º 6
0
def capture_translations(app="app",lang="unknown"):


    wins1=l.getwindowlist()
    time.sleep(2) # sometimes the window is not ready yet
    wins=l.getwindowlist()

    img_name = l.imagecapture()

    re_pattern = r"(.*)auto([0-9]+)auto(.*)"

    for w in wins:
        obj = l.getobjectlist(w)
        w_clean = re.sub(re_pattern,"\\1\\3",w)
        for o in obj:
            info = l.getobjectinfo(w,o)
            o_clean = re.sub(re_pattern,"\\1\\3",o)
            if 'label' in info:
                label = l.getobjectproperty(w,o,'label')
                size = None

                # check if we find the "automate language"
                m = re.search(re_pattern, label)
                if m:
                    id_num = m.group(2)
                    size = l.getobjectsize(w,o)
                    if size[0] > 0:
                        translation[id_num] = (w_clean, o_clean)
                        w_o_mapping[(w_clean, o_clean)] = id_num
                        print("Translation #{} is here: ('{}','{}')".format(id_num, w_clean, o_clean))
                        print("Located in picture: {}".format(size))
                    else:
                        size = None

                # or check if we already know the translation from the "automate language"-run
                elif (w, o) in w_o_mapping.keys():
                    id_num = w_o_mapping[(w, o)]
                    size = l.getobjectsize(w,o)
                    if size[0] > 0:
                        print("Found translation #{}".format(id_num))
                    else:
                        size = None

                # in both cases we want a screenshot
                if size:
                    img = cv2.imread(img_name)
                    new_img = cv2.rectangle(img, (size[0], size[1]), (size[0] + size[2], size[1] + size[3]), (0,0,255), 3)
                    cv2.imwrite('/tmp/translation_{}_{}_{}_{}.png'.format(app, lang, id_num, o), new_img)
Ejemplo n.º 7
0
def capture_translations(app="app",lang="unknown"):


    wins1=l.getwindowlist()
    time.sleep(2) # sometimes the window is not ready yet
    wins=l.getwindowlist()

    img_name = l.imagecapture()

    re_pattern = r"(.*)auto([0-9]+)auto(.*)"

    for w in wins:
        obj = l.getobjectlist(w)
        w_clean = re.sub(re_pattern,"\\1\\3",w)
        for o in obj:
            info = l.getobjectinfo(w,o)
            o_clean = re.sub(re_pattern,"\\1\\3",o)
            if 'label' in info:
                label = l.getobjectproperty(w,o,'label')
                size = None

                # check if we find the "automate language"
                m = re.search(re_pattern, label)
                if m:
                    id_num = m.group(2)
                    size = l.getobjectsize(w,o)
                    if size[0] > 0:
                        translation[id_num] = (w_clean, o_clean)
                        w_o_mapping[(w_clean, o_clean)] = id_num
                        print("Translation #{} is here: ('{}','{}')".format(id_num, w_clean, o_clean))
                        print("Located in picture: {}".format(size))
                    else:
                        size = None

                # or check if we already know the translation from the "automate language"-run
                elif (w, o) in w_o_mapping.keys():
                    id_num = w_o_mapping[(w, o)]
                    size = l.getobjectsize(w,o)
                    if size[0] > 0:
                        print("Found translation #{}".format(id_num))
                    else:
                        size = None

                # in both cases we want a screenshot
                if size:
                    img = cv2.imread(img_name)
                    new_img = cv2.rectangle(img, (size[0], size[1]), (size[0] + size[2], size[1] + size[3]), (0,0,255), 3)
                    cv2.imwrite('{}/translation_{}_{}_{}_{}.png'.format(OUTPUT_DIR, app, lang, id_num, o), new_img)
Ejemplo n.º 8
0
def imagecapture(window_name = '', out_file = None, x = 0, y = 0, width = -1, height = -1):
    '''
    Captures screenshot of the whole desktop or given window

    @param window_name: Window name to look for, either full name,
    LDTP's name convention, or a Unix glob.
    @type window_name: string
    @param x: x co-ordinate value
    @type x: integer
    @param y: y co-ordinate value
    @type y: integer
    @param width: width co-ordinate value
    @type width: integer
    @param height: height co-ordinate value
    @type height: integer

    @return: screenshot filename
    @rtype: string
    '''
    return ldtp.imagecapture(window_name=window_name,out_file=out_file,x=x,y=y,width=width,height=height)
ldtp.waittillguiexist(fenetre)
ldtp.mouseleftclick(fenetre, 'txt1')
ajouterPressePapier("Lorem ipsum dolor sit amet, consectetur adipiscing elit. In rhoncus felis sed condimentum pretium. Etiam vulputate sapien eu massa consectetur imperdiet. Nunc non pulvinar magna. Donec fermentum sagittis condimentum. Vivamus et quam nec ante turpis ")
ldtp.keypress('<ctrl>')
ldtp.keypress('v')
ldtp.keyrelease('<ctrl>')
ldtp.mouseleftclick(fenetre, 'sldr0')
ldtp.enterstring(fenetre, 'txt0', "<del><del><del><del><del>999,99")
ldtp.click(fenetre, 'btnSaveEnter')

ldtp.click("*Traitement d'une fiche de maintenance*", 'btnSaveEnter')
ldtp.click('*Gestion de dossiers*', 'btnTraiter')
fenetre = "*Traitement d'une fiche de maintenance*"
ldtp.waittillguiexist(fenetre)

coordinate = ldtp.getwindowsize(fenetre)
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
	ldtp.imagecapture(fenetre, 'images/ajouter_piece_test_nom_haute_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture(fenetre, 'images/ajouter_piece_test_nom_haute.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/ajouter_piece_test_nom_haute.png")
    im2 = Image.open("images/ajouter_piece_test_nom_haute_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Ajout piece test: nom haute'")

ldtp.click(fenetre, 'btnSaveEnter')
fermer()
fenetre = "*Ajouter une*"
ldtp.waittillguiexist(fenetre)
ldtp.mouseleftclick(fenetre, 'cboDown')
ldtp.mouseleftclick(fenetre, 'lstCombofix')
ldtp.mouseleftclick(fenetre, 'cboDown1')
ldtp.mouseleftclick(fenetre, 'lstEncours')
# ldtp.mouseleftclick(fenetre, 'txt0')
# ldtp.enterstring(fenetre, 'txt0', "")
ldtp.click(fenetre, 'btnSaveEnter')

ldtp.click("*Traitement d'une fiche de maintenance*", 'btnSaveEnter')
ldtp.click('*Gestion de dossiers*', 'btnTraiter')
fenetre = "*Traitement d'une fiche de maintenance*"
ldtp.waittillguiexist(fenetre)

coordinate = ldtp.getwindowsize(fenetre)
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
	ldtp.imagecapture(fenetre, 'images/ajouter_tache_test_commentaire_basse_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture(fenetre, 'images/ajouter_tache_test_commentaire_basse.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/ajouter_tache_test_commentaire_basse.png")
    im2 = Image.open("images/ajouter_tache_test_commentaire_basse_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Ajout tache test: commentaire basse'")

ldtp.click(fenetre, 'btnSaveEnter')
fermer()
fenetre = "*Ajouter une*"
ldtp.waittillguiexist(fenetre)
ldtp.mouseleftclick(fenetre, 'cboDown')
ldtp.mouseleftclick(fenetre, 'lstCombofix')
ldtp.mouseleftclick(fenetre, 'cboDown1')
ldtp.mouseleftclick(fenetre, 'lstEncours')
# ldtp.mouseleftclick(fenetre, 'txt0')
# ldtp.enterstring(fenetre, 'txt0', "")
ldtp.click(fenetre, 'btnCancel')

ldtp.click("*Traitement d'une fiche de maintenance*", 'btnSaveEnter')
ldtp.click('*Gestion de dossiers*', 'btnTraiter')
fenetre = "*Traitement d'une fiche de maintenance*"
ldtp.waittillguiexist(fenetre)

coordinate = ldtp.getwindowsize(fenetre)
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
	ldtp.imagecapture(fenetre, 'images/ajouter_tache_test_annulation_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture(fenetre, 'images/ajouter_tache_annulation.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/ajouter_tache_annulation.png")
    im2 = Image.open("images/ajouter_tache_test_annulation_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Ajout tache test: annulation'")

ldtp.click(fenetre, 'btnSaveEnter')
fermer()
import sys
import ldtp
import Image
import ImageChops
from commandes_bases import *

connecter()

ajouterFiche()

ldtp.click('*Gestion de dossiers*', 'btnAjouter')
ldtp.waittillguiexist('*une nouvelle fiche*')
ldtp.click('*une nouvelle fiche*', 'btnSaveEnter')

coordinate = ldtp.getobjectsize('*Gestion de dossiers*', 'pane0')
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
    ldtp.imagecapture('*Gestion de dossiers*', 'images/creer_fiche_test_preselection_description_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture('*Gestion de dossiers*', 'images/creer_fiche_test_preselection_description.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/creer_fiche_test_preselection_description.png")
    im2 = Image.open("images/creer_fiche_test_preselection_description_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Creation Fiche test Preselection et description vide'")

fermer()
Ejemplo n.º 13
0
def do_screenshot(app, app_name):
    l.launchapp(app)
    l.waittillguiexist(app_name)
    l.imagecapture(app_name, os.path.join(basePath, app + ".png"))
    l.generatekeyevent("<alt><f4>")
Ejemplo n.º 14
0
import time
import sys

basePath="/screenshots"

if not os.path.exists(basePath):
    os.mkdir(basePath)

def do_screenshot(app, app_name):
    l.launchapp(app)
    l.waittillguiexist(app_name)
    l.imagecapture(app_name, os.path.join(basePath, app + ".png"))
    l.generatekeyevent("<alt><f4>")


full_screen=l.imagecapture()
os.rename(full_screen, os.path.join(basePath, "xfce-desktop.png"))

# I/O error workaround
l.launchapp("xfce4-terminal")
time.sleep(1)
l.generatekeyevent("<alt><f4>")


# move the mouse away to avoid tool tips
l.generatemouseevent(800,600, "abs")

# appfinder crashes on imagecapture() - (has to window?)
l.launchapp("xfce4-appfinder")
l.waittillguiexist("ApplicationFinder")
full_screen=l.imagecapture()
Ejemplo n.º 15
0
@license: LGPL

http://ldtp.freedesktop.org

This file may be distributed and/or modified under the terms of the GNU General
Public License version 2 as published by the Free Software Foundation. This file
is distributed without any warranty; without even the implied warranty of 
merchantability or fitness for a particular purpose.

See "COPYING" in the source distribution for more information.

Headers in this file shall remain intact.
'''

import ldtp, ooldtp
from time import sleep
ldtp.launchapp('gedit')

frm = ooldtp.context('*gedit')
frm.waittillguiexist()
txt_field = frm.getchild('txt1')
txt_field.enterstring('Hello world!<return>bye<return>')
ldtp.imagecapture('*gedit', '/tmp/foo.png')
mnu_quit = frm.getchild('mnuQuit')
mnu_quit.selectmenuitem()
alert = ooldtp.context('Question')
alert.waittillguiexist()
btn = alert.getchild('btnClosewithoutSaving')
btn.click()
frm.waittillguinotexist()
ldtp.keypress('a')
ldtp.keyrelease('<ctrl>')
ldtp.keypress('<bksp>')
ldtp.keyrelease('<bksp>')

ajouterPressePapier("Lorem ipsum dolor sit amet, consectetur adipiscing elit. In rhoncus felis sed condimentum pretium. Etiam vulputate sapien eu massa consectetur imperdiet. Nunc non pulvinar magna. Donec fermentum sagittis condimentum. Vivamus et quam nec ante turpis ")
ldtp.keypress('<ctrl>')
ldtp.keypress('v')
ldtp.keyrelease('<ctrl>')

ldtp.click(fenetre, 'btnSaveEnter')

ldtp.click('*Gestion de dossiers*', 'btnTraiter')
ldtp.waittillguiexist(fenetre)

coordinate = ldtp.getwindowsize(fenetre)
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
	ldtp.imagecapture(fenetre, 'images/traiter_fiche_description_haute_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture(fenetre, 'images/traiter_fiche_description_haute.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/traiter_fiche_description_haute.png")
    im2 = Image.open("images/traiter_fiche_description_haute_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Traitement fiche test: description haute'")

ldtp.click(fenetre, 'btnSaveEnter')
fermer()
connecter()

ajouterFiche()

ldtp.click('*Gestion de dossiers*', 'btnAjouter')
ldtp.waittillguiexist('*une nouvelle fiche*')
ldtp.mouseleftclick('*une nouvelle fiche*', 'txt0')
ajouterPressePapier("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas porttitor congue interdum. Ut non felis id neque sollicitudin interdum. Cras ac posuere erat, quis finibus sapien. Vivamus facilisis urna quis arcu pulvinar, in venenatis risus scelerisque. Vivamus vel elit at magna viverra facilisis. Aenean tempus est eget fermentum suscipit. Morbi aliquam bibendum justo pretium rhoncus. Nulla elit nibh, semper ac laoreet nec, suscipit ut leo. Morbi convallis mauris eget quam finibus, non sagittis turpis dictum. Sed sagittis a erat nec placerat. Fusce at erat mauris. Quisque commodo, tellus sit amet commodo vulputate, sem nunc dignissim felis, fermentum vulputate lectus nunc sit amet velit. Curabitur aliquam neque et enim dignissim porta. Integer vitae consequat ligula. Curabitur at orci elit. Aenean quis convallis neque. Suspendisse ullamcorper feugiat sem nec feugiat. Donec lorem purus, venenatis nec sodales congue, fermentum at turpis. Nulla ut risus et lorem aliquet blandit a vitae est. Quisque id posuere")
ldtp.keypress('<ctrl>')
ldtp.keypress('v')
ldtp.keyrelease('<ctrl>')
ldtp.mouseleftclick('*une nouvelle fiche*', 'cboDown')
ldtp.mouseleftclick('*une nouvelle fiche*', 'lstInstallationavecbackup')
ldtp.click('*une nouvelle fiche*', 'btnSaveEnter')

coordinate = ldtp.getobjectsize('*Gestion de dossiers*', 'pane0')
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
    ldtp.imagecapture('*Gestion de dossiers*', 'images/creer_fiche_test_descritpion_haute_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture('*Gestion de dossiers*', 'images/creer_fiche_test_descritpion_haute.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/creer_fiche_test_descritpion_haute.png")
    im2 = Image.open("images/creer_fiche_test_descritpion_haute_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Creation Fiche test: description haute'")

fermer()
Ejemplo n.º 18
0
def step_impl(context, win):
    lang = context._root.get('my_lang', None)
    w_o_mapping = context._root.get('w_o_mapping', {})
    feature = context._stack[1]["feature"].filename
    line = context._root["my_line"]
    po_map = context._root.get('po_map', {})
    locator_map = context._root.get('locator_map', {})

    (win, _) = _resolveNames(context, win)

    # _resolveNames() already saved the indexes - we can quit now
    if lang is None:
        return

    img_name = l.imagecapture()

    re_pattern = r"(.*)auto([0-9]+)auto(.*)"
    time.sleep(1)
    obj = l.getobjectlist(win)
    w_clean = re.sub(re_pattern, "\\1\\3", win)

    # avoiding multiple appearances with the same filename
    multi_appear = {}
    for o in obj:
        print(f"Get info for {o}")
        info = l.getobjectinfo(win, o)
        o_clean = re.sub(re_pattern, "\\1\\3", o)
        # "or o_clean" means that the pattern can be applied
        if 'label' in info or o_clean:
            if 'label' in info:
                print("Get real label")
                label = l.getobjectproperty(win, o, 'label')
            else:
                print("Use object as label")
                label = o
            print(f"   label: {label}")
            size = None
            if label is None:
                print("label is none")
                continue

            try:
                size = l.getobjectsize(win, o)
                if size[0] < 0:
                    size = None
            except Exception as e:
                print(e)
                size = None
            # check if we find the "automate language"
            m = re.search(re_pattern, label)
            if m:
                print(f"Found automate here: {label}")
                id_num = m.group(2)
                if size:
                    # store "translation ID" (i.e. po-line number) for later
                    w_o_mapping[(w_clean, o_clean, line)] = id_num
                    print("Translation #{} is here: ('{}','{}')".format(
                        id_num, w_clean, o_clean))
                    print("Located in picture: {}".format(size))

            # or check if we already know the translation from the "automate language"-run
            elif (win, o, line) in w_o_mapping.keys():
                print(f"Found mapping: {label}")
                id_num = w_o_mapping[(win, o, line)]
                if size:
                    print("Found translation #{}".format(id_num))

                    # SMELL: move to feature function and execute only once
                    if not os.path.exists(OUTPUT_DIR):
                        os.makedirs(OUTPUT_DIR)
                    img = cv2.imread(img_name)
                    x = size[0]
                    y = size[1]
                    w = size[2]
                    h = size[3]
                    new_img = cv2.rectangle(img, (x, y), (x + w, y + h),
                                            (0, 0, 255), 3)
                    timestamp = int(time.time())
                    filename = f"{feature}_{lang}_po{id_num}_featureline_{line}_{timestamp}"
                    # for multiple ocurrances of one translation in the same window and same step
                    multi_appear[filename] = multi_appear.get(filename, 0) + 1
                    filename = f"{filename}_{multi_appear[filename]}.png"
                    cv2.imwrite(os.path.join(OUTPUT_DIR, filename), new_img)

                    if timestamp not in locator_map:
                        locator_map[timestamp] = []

                    locator_map[timestamp].append({
                        "x": x,
                        "y": y,
                        "w": w,
                        "h": h,
                        "timestamp": timestamp,
                        "name": f"PO{id_num}",
                        "filename": filename
                    })

            else:
                print("Neither Automate nor mapping")
    context._root["w_o_mapping"] = w_o_mapping
    context._root["locator_map"] = locator_map
Ejemplo n.º 19
0
@license: LGPL

http://ldtp.freedesktop.org

This file may be distributed and/or modified under the terms of the GNU Lesser General
Public License version 2 as published by the Free Software Foundation. This file
is distributed without any warranty; without even the implied warranty of 
merchantability or fitness for a particular purpose.

See "COPYING" in the source distribution for more information.

Headers in this file shall remain intact.
'''

import ldtp, ooldtp
from time import sleep
ldtp.launchapp('gedit')

frm = ooldtp.context('*gedit')
frm.waittillguiexist()
txt_field = frm.getchild('txt1')
txt_field.enterstring('Hello world!<return>bye<return>')
ldtp.imagecapture('*gedit', '/tmp/foo.png')
mnu_quit = frm.getchild('mnuQuit')
mnu_quit.selectmenuitem()
alert = ooldtp.context('Question')
alert.waittillguiexist()
btn = alert.getchild('btnClosewithoutSaving')
btn.click()
frm.waittillguinotexist()
fenetre = "*Traitement d'une fiche de maintenance*"
ldtp.waittillguiexist(fenetre)

ldtp.mouseleftclick(fenetre, 'txtFiche#13')
ldtp.keypress('<ctrl>')
ldtp.keypress('a')
ldtp.keyrelease('<ctrl>')
ldtp.keypress('<bksp>')
ldtp.keyrelease('<bksp>')
ldtp.enterstring(fenetre, 'txtFiche#13', 'allo mon grand')
ldtp.click(fenetre, 'btnCancel')

ldtp.click('*Gestion de dossiers*', 'btnTraiter')
ldtp.waittillguiexist(fenetre)

coordinate = ldtp.getwindowsize(fenetre)
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
	ldtp.imagecapture(fenetre, 'images/traiter_fiche_commentaire_basse_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture(fenetre, 'images/traiter_fiche_commentaire_basse.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/traiter_fiche_commentaire_basse.png")
    im2 = Image.open("images/traiter_fiche_commentaire_basse_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Traitement fiche test: commentaire basse'")

ldtp.click(fenetre, 'btnSaveEnter')
fermer()
fenetre = "*une nouvelle*"
ldtp.waittillguiexist(fenetre)
ldtp.mouseleftclick(fenetre, 'txt1')
ldtp.enterstring(fenetre, 'txt1', "disque dur")
#ldtp.mouseleftclick(fenetre, 'txt0')
#ldtp.enterstring(fenetre, 'txt0', "")
ldtp.mouseleftclick(fenetre, 'sldr0')
ldtp.enterstring(fenetre, 'txt0', "<del><del><del><del><del>999,99")
ldtp.click(fenetre, 'btnSaveEnter')

ldtp.click("*Traitement d'une fiche de maintenance*", 'btnSaveEnter')
ldtp.click('*Gestion de dossiers*', 'btnTraiter')
fenetre = "*Traitement d'une fiche de maintenance*"
ldtp.waittillguiexist(fenetre)

coordinate = ldtp.getwindowsize(fenetre)
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
	ldtp.imagecapture(fenetre, 'images/ajouter_piece_test_descritpion_basse_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture(fenetre, 'images/ajouter_piece_test_descritpion_basse.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/ajouter_piece_test_descritpion_basse.png")
    im2 = Image.open("images/ajouter_piece_test_descritpion_basse_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Ajout piece test: description basse'")

ldtp.click(fenetre, 'btnSaveEnter')
fermer()
ldtp.waittillguiexist(fenetre)
ldtp.mouseleftclick(fenetre, 'txt1')
ajouterPressePapier("Lorem ipsum dolor sit amet, consectetur adipiscing elit. In rhoncus felis sed condimentum pretium. Etiam vulputate sapien eu massa consectetur imperdiet. Nunc non pulvinar magna. Donec fermentum sagittis condimentum. Vivamus et quam nec ante turpis ")
ldtp.keypress('<ctrl>')
ldtp.keypress('v')
ldtp.keyrelease('<ctrl>')
ldtp.mouseleftclick(fenetre, 'sldr0')
ldtp.enterstring(fenetre, 'txt0', "<del><del><del><del><del>999,99")
ldtp.click(fenetre, 'btnCancel')

ldtp.click("*Traitement d'une fiche de maintenance*", 'btnSaveEnter')
ldtp.click('*Gestion de dossiers*', 'btnTraiter')
fenetre = "*Traitement d'une fiche de maintenance*"
ldtp.waittillguiexist(fenetre)

coordinate = ldtp.getwindowsize(fenetre)
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
	ldtp.imagecapture(fenetre, 'images/ajouter_piece_test_annuler_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture(fenetre, 'images/ajouter_piece_test_annuler.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/ajouter_piece_test_annuler.png")
    im2 = Image.open("images/ajouter_piece_test_annuler_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Ajout piece test: annulation'")

ldtp.click(fenetre, 'btnSaveEnter')
fermer()
Ejemplo n.º 23
0
import sys

basePath = "/screenshots"

if not os.path.exists(basePath):
    os.mkdir(basePath)


def do_screenshot(app, app_name):
    l.launchapp(app)
    l.waittillguiexist(app_name)
    l.imagecapture(app_name, os.path.join(basePath, app + ".png"))
    l.generatekeyevent("<alt><f4>")


full_screen = l.imagecapture()
os.rename(full_screen, os.path.join(basePath, "xfce-desktop.png"))

# I/O error workaround
l.launchapp("xfce4-terminal")
time.sleep(1)
l.generatekeyevent("<alt><f4>")

# move the mouse away to avoid tool tips
l.generatemouseevent(800, 600, "abs")

# appfinder crashes on imagecapture() - (has to window?)
l.launchapp("xfce4-appfinder")
l.waittillguiexist("ApplicationFinder")
full_screen = l.imagecapture()
os.rename(full_screen, os.path.join(basePath, "xfce4-appfinder-main.png"))
import ImageChops
from commandes_bases import *

connecter()

ajouterFiche()

ldtp.click('*Gestion de dossiers*', 'btnAjouter')
ldtp.waittillguiexist('*une nouvelle fiche*')
ldtp.mouseleftclick('*une nouvelle fiche*', 'txt0')
ldtp.enterstring('*une nouvelle fiche*', 'txt0', "bonjour comment ca va")
ldtp.mouseleftclick('*une nouvelle fiche*', 'cboDown')
ldtp.mouseleftclick('*une nouvelle fiche*', 'lstInstallationavecbackup')
ldtp.mouseleftclick('*une nouvelle fiche*', 'sldr0')
ldtp.enterstring('*une nouvelle fiche*', 'sldr0', "<del>2")
ldtp.click('*une nouvelle fiche*', 'btnSaveEnter')

coordinate = ldtp.getobjectsize('*Gestion de dossiers*', 'pane0')
if (len(sys.argv) > 1) and (sys.argv[1] == 'origin'):
    ldtp.imagecapture('*Gestion de dossiers*', 'images/creer_fiche_test_priorite2_origin.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
else:
    ldtp.imagecapture('*Gestion de dossiers*', 'images/creer_fiche_test_priorite2.png',
                      coordinate[0], coordinate[1], coordinate[2], coordinate[3])
    im1 = Image.open("images/creer_fiche_test_priorite2.png")
    im2 = Image.open("images/creer_fiche_test_priorite2_origin.png")
    diff = ImageChops.difference(im2, im1)
    if diff.getbbox():
        print("Erreur possible dans 'Creation Fiche test: priorite2'")

fermer()
Ejemplo n.º 25
0
def do_screenshot(app, app_name):
    l.launchapp(app)
    l.waittillguiexist(app_name)
    l.imagecapture(app_name, os.path.join(basePath, app + ".png"))
    l.generatekeyevent("<alt><f4>")