dtmilano / CulebraTester-public

Public repository corresponding to CulebraTester
11 stars 0 forks source link

CulebraTester Python Script #5

Closed 7ikPDYl3 closed 6 years ago

7ikPDYl3 commented 8 years ago

Culebra Tester Version 0.8.14 Culebra Tester Instrumentation 0.8.14 Android version 4.4.2 Phone: Motorola Moto G

1) Created a Python27 script on a MAC with Safari Browser Version 9.1.3 (9537.86.7.8).

2) Ran the script with the following command line based on what I read in the help menu and from the YouTube video entitled Tutorial 24: AndroidViewClient and Culebra and CulebraTester Demo. The YouTube demo show a Javascript executed with the following command line, but Javascript is not accessible on my CulebraTester browser menu.

curl -o - -v -X POST --data-urlenco @/Users/mtirone/Androidtest/Culebratester/calc1.py.txt http://10.100.20.123:9999/evaluatePythonscript

3) The Code Generation menu allows Python or Java to be selected, but the following are not selectable: Javascript Qunit Java(Expresso) Groovy

4) Result of running the command line in step 2.

dtmilano commented 8 years ago

As indicated by the UI, and also as you mentioned, some languages have been disabled for code generation in this instalment. Python and Java (UiAutomator) are the top selected languages in the opt-in form so that's the main reason why they have been chosen first.

This allows us to focus on the issues that could be found generating those languages to reach the expected maturity soon.

Then to your specific question

1) Created a Python27 script on a MAC with Safari Browser Version 9.1.3 (9537.86.7.8).

That's perfect. Once you test script is generated you can run it as you do with any other AndroidViewClient/culebra script.

This is a summary of the steps

  1. Set Python as CulebraTester Code Generation language
  2. Press SOURCE CODE START recording
  3. Interact with the device representation
  4. Once done. press SOURCE CODE STOP
  5. Save the script using SOURCE CODE SAVE (you may have to remove the .txt extension)
  6. Set the execution permission on the saved script using chmod +x test.py
  7. Ensure that AndroidViewClient is in PYTHONPATH or set ANDROID_VIEW_CLIENT_HOME accordingly
  8. Run test.py

The generated script contains the needed options to use CulebraTester as the backend ('useuiautomatorhelper': True) so the script will connect to automatically to your device.

Hope this helps. Don't hesitate to ask more questions or create some issues if you find them.

7ikPDYl3 commented 8 years ago

Hi Diego,

Thanks! That worked. I'm getting the following error when I execute the test.py file. I'm just creating a basic test by clicking on the Calculator application and selecting number buttons. I'll document the issue after I'm sure it is not a configuration issue.

self.vc.click(oid=2)

TypeError: click() got an unexpected keyword argument 'oid'

Also, is the test.java file complied with javac to produce a test.jar file to run a test?

Regards,

Mike Tirone


From: Diego Torres Milano notifications@github.com Sent: Wednesday, October 19, 2016 10:21:51 PM To: dtmilano/CulebraTester-public Cc: Michael Tirone; Author Subject: Re: [dtmilano/CulebraTester-public] CulebraTester Python Script (#5)

As indicated by the UI, and also as you mentioned, some languages have been disabled for code generation in this instalment. Python and Java (UiAutomator) are the top selected languages in the opt-in formhttp://goo.gl/forms/aqLL7ni6NH so that's the main reason why they have been chosen first.

This allows us to focus on the issues that could be found generating those languages to reach the expected maturity soon.

Then to your specific question

1) Created a Python27 script on a MAC with Safari Browser Version 9.1.3 (9537.86.7.8).

That's perfect. Once you test script is generated you can run it as you do with any other AndroidViewClient/culebrahttps://github.com/dtmilano/AndroidViewClient script.

This is a summary of the steps

  1. Set Python as CulebraTester Code Generation language
  2. Press SOURCE CODE START recording
  3. Interact with the device representation
  4. Once done. press SOURCE CODE STOP
  5. Save the script using SOURCE CODE SAVE (you may have to remove the .txt extension)
  6. Set the execution permission on the saved script using chmod +x test.py
  7. Ensure that AndroidViewClient is in PYTHONPATH or set ANDROID_VIEW_CLIENT_HOME accordingly
  8. Run test.py

The generated script contains the needed options to use CulebraTester as the backend ('useuiautomatorhelper': True) so the script will connect to automatically to your device.

Hope this helps. Don't hesitate to ask more questions or create some issues if you find them.

You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/dtmilano/CulebraTester-public/issues/5#issuecomment-254992156, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARcisEalilHSLdIXPnrx96Nq38WdOgTYks5q1tA_gaJpZM4Ka_JP.

dtmilano commented 8 years ago

If you haven't done it yet update to CulebraTester 0.8.16 and AndroidViewClient/culebra v 12.1.2.

A lot of fixes are there.

Just tried what you said:

and this is the script generated which works as expected

#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013-2016  Diego Torres Milano
Created on 2016-10-25 by CulebraTester 
                      __    __    __    __
                     /  \  /  \  /  \  /  \ 
____________________/  __\/  __\/  __\/  __\_____________________________
___________________/  /__/  /__/  /__/  /________________________________
                   | / \   / \   / \   / \   \___
                   |/   \_/   \_/   \_/   \    o \ 
                                           \_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''

import re
import sys
import os

import unittest
try:
    sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient, CulebraTestCase
from com.dtmilano.android.uiautomator.uiautomatorhelper import UiAutomatorHelper, UiScrollable, UiObject, UiObject2

TAG = 'CULEBRA'

class CulebraTests(CulebraTestCase):

    @classmethod
    def setUpClass(cls):
        cls.kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
        cls.kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': True, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}
        cls.options = {'start-activity': None, 'concertina': False, 'device-art': None, 'use-jar': False, 'multi-device': False, 'unit-test-class': True, 'save-screenshot': None, 'use-dictionary': False, 'glare': False, 'dictionary-keys-from': 'id', 'scale': 1, 'find-views-with-content-description': True, 'window': -1, 'orientation-locked': None, 'save-view-screenshots': None, 'find-views-by-id': True, 'log-actions': False, 'use-regexps': False, 'null-back-end': False, 'auto-regexps': None, 'do-not-verify-screen-dump': True, 'verbose-comments': False, 'gui': False, 'find-views-with-text': True, 'prepend-to-sys-path': False, 'install-apk': None, 'drop-shadow': False, 'output': None, 'unit-test-method': None, 'interactive': False}
        cls.sleep = 5

    def setUp(self):
        super(CulebraTests, self).setUp()

    def tearDown(self):
        super(CulebraTests, self).tearDown()

    def preconditions(self):
        if not super(CulebraTests, self).preconditions():
            return False
        return True

    def testSomething(self):
        if not self.preconditions():
            self.fail('Preconditions failed')

        _s = CulebraTests.sleep
        _v = CulebraTests.verbose

        self.vc.uiAutomatorHelper.pressHome()
        self.vc.sleep(_s)
        self.vc.uiAutomatorHelper.findObject(bySelector='desc@Apps,package@com.android.launcher3').clickAndWait(eventCondition='until:newWindow', timeout=_s*1000)
        UiScrollable(self.vc.uiAutomatorHelper, uiSelector='res@com.android.launcher3:id/apps_list_view,package@com.android.launcher3').getChildByDescription(uiSelector='desc@Calculator', description="Calculator", allowScrollSearch=True).click()
        UiScrollable(self.vc.uiAutomatorHelper, uiSelector='res@com.android.calculator2:id/pad_pager,index@1,package@com.android.calculator2').getChildByText(uiSelector='text@2', text="2", allowScrollSearch=True).click()
        UiScrollable(self.vc.uiAutomatorHelper, uiSelector='res@com.android.calculator2:id/pad_pager,index@1,package@com.android.calculator2').getChildByDescription(uiSelector='desc@plus', description="plus", allowScrollSearch=True).click()
        UiScrollable(self.vc.uiAutomatorHelper, uiSelector='res@com.android.calculator2:id/pad_pager,index@1,package@com.android.calculator2').getChildByText(uiSelector='text@1', text="1", allowScrollSearch=True).click()

if __name__ == '__main__':
    CulebraTests.main()
7ikPDYl3 commented 8 years ago

Hi Diego, The following link is a video of how I’m generating the Python27 script. I updated using easyinstall and the version shows 12.2.0.

https://dl.dropboxusercontent.com/u/59429708/Diego/culebratesterpython27.mov

The following is the error message I get when I run the .py script. Regards, Mike Tirone

E

ERROR: testSomething (main.CulebraTests)

Traceback (most recent call last): File "./test1.py", line 61, in testSomething self.vc.click(oid=2) TypeError: click() got an unexpected keyword argument 'oid'


Ran 1 test in 5.904s

FAILED (errors=1)

Culebra Tester: Debug Info Helper

Platform

Device

falcon_umts

Brand

motorola

Board

MSM8226

Hardware

motorola

Model

XT1034

API

19

Build

qcom KXB20.9-1.10-1.24-1.1 TA88000JUO

Build number

KXB20.9-1.10-1.24-1.1

APK

version code

8014

version name

0.8.14

Display

Size

720x1280

From: Diego Torres Milano notifications@github.com Reply-To: dtmilano/CulebraTester-public reply@reply.github.com Date: Tuesday, October 25, 2016 at 3:18 PM To: dtmilano/CulebraTester-public CulebraTester-public@noreply.github.com Cc: Michael Tirone mtirone@aciedge.com, Author author@noreply.github.com Subject: Re: [dtmilano/CulebraTester-public] CulebraTester Python Script (#5)

If you haven't done it yet update to AndroidViewClient/culebra v 12.1.2https://github.com/dtmilano/AndroidViewClient/releases/tag/v12.1.2.

A lot of fixes are there.

Just tried what you said:

and this is the script generated which works as expected

! /usr/bin/env python

-- coding: utf-8 --

'''

Copyright (C) 2013-2016 Diego Torres Milano

Created on 2016-10-25 by CulebraTester

                  __    __    __    __

                 /  \  /  \  /  \  /  \

____/ \/ \/ \/ _____****

___/ // // // /__

               | / \   / \   / \   / \   \___

               |/   \_/   \_/   \_/   \    o \

                                       \_____/--<

@author: Diego Torres Milano

@author: Jennifer E. Swofford (ascii art snake)

'''

import re

import sys

import os

import unittest

try:

sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))

except:

pass

from com.dtmilano.android.viewclient import ViewClient, CulebraTestCase

from com.dtmilano.android.uiautomator.uiautomatorhelper import UiAutomatorHelper, UiScrollable, UiObject, UiObject2

TAG = 'CULEBRA'

class CulebraTests(CulebraTestCase):

@classmethod

def setUpClass(cls):

    cls.kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}

    cls.kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': True, 'ignoreuiautomatorkilled': True, 'autodump': False, 'startviewserver': True, 'compresseddump': True}

    cls.options = {'start-activity': None, 'concertina': False, 'device-art': None, 'use-jar': False, 'multi-device': False, 'unit-test-class': True, 'save-screenshot': None, 'use-dictionary': False, 'glare': False, 'dictionary-keys-from': 'id', 'scale': 1, 'find-views-with-content-description': True, 'window': -1, 'orientation-locked': None, 'save-view-screenshots': None, 'find-views-by-id': True, 'log-actions': False, 'use-regexps': False, 'null-back-end': False, 'auto-regexps': None, 'do-not-verify-screen-dump': True, 'verbose-comments': False, 'gui': False, 'find-views-with-text': True, 'prepend-to-sys-path': False, 'install-apk': None, 'drop-shadow': False, 'output': None, 'unit-test-method': None, 'interactive': False}

    cls.sleep = 5

def setUp(self):

    super(CulebraTests, self).setUp()

def tearDown(self):

    super(CulebraTests, self).tearDown()

def preconditions(self):

    if not super(CulebraTests, self).preconditions():

        return False

    return True

def testSomething(self):

    if not self.preconditions():

        self.fail('Preconditions failed')

    _s = CulebraTests.sleep

    _v = CulebraTests.verbose

    self.vc.uiAutomatorHelper.pressHome()

    self.vc.sleep(_s)

    self.vc.uiAutomatorHelper.findObject(bySelector='desc@Apps,package@com.android.launcher3').clickAndWait(eventCondition='until:newWindow', timeout=_s*1000)

    UiScrollable(self.vc.uiAutomatorHelper, uiSelector='res@com.android.launcher3:id/apps_list_view,package@com.android.launcher3').getChildByDescription(uiSelector='desc@Calculator', description="Calculator", allowScrollSearch=True).click()

    UiScrollable(self.vc.uiAutomatorHelper, uiSelector='res@com.android.calculator2:id/pad_pager,index@1,package@com.android.calculator2').getChildByText(uiSelector='text@2', text="2", allowScrollSearch=True).click()

    UiScrollable(self.vc.uiAutomatorHelper, uiSelector='res@com.android.calculator2:id/pad_pager,index@1,package@com.android.calculator2').getChildByDescription(uiSelector='desc@plus', description="plus", allowScrollSearch=True).click()

    UiScrollable(self.vc.uiAutomatorHelper, uiSelector='res@com.android.calculator2:id/pad_pager,index@1,package@com.android.calculator2').getChildByText(uiSelector='text@1', text="1", allowScrollSearch=True).click()

if name == 'main':

CulebraTests.main()

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/dtmilano/CulebraTester-public/issues/5#issuecomment-256147673, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ARcisDXUcMTOTUBvvLUZjStZhmpK-Smjks5q3lX_gaJpZM4Ka_JP.

dtmilano commented 8 years ago

The video is really helpful. All the problems you are seeing should be fixed in 0.8.17. Let me know.

dtmilano commented 8 years ago

I uploaded a video doing (almost) exactly the same: https://youtu.be/TeJNBU_5TAg

dtmilano commented 7 years ago

Latest CulebraTester versions specify the minimum required AndroidViewClient version to run the generated script.