Reputation: 71
I am new to Appium. I want to control my android device via appium without sending any apk to phone. I have tried many examples but in each example everyone is pushing an apk and then controlling it using touches and keypress.
I am not looking for an app testing instead I am looking for an android device testing using resorce id ,name,class or xpath.
And will the procedure remain same for ios also ?
Can anyone help me in writing a script in python?
Upvotes: 0
Views: 2213
Reputation: 435
I think the problem is like mine...want to control an android device or emulator with Appium, may be Mayank Shivhare already try to learn culebra and found the fact that....culebra is still not support by python 3 yet (same problem like me that prefer python 3.7 than python 2.7).
I have the same problem..., what I understood right now is:
All environment should be set up first
The emulator should be run first...before type any code
then run Appium to make a gateway with IP and port.
the missing link is how to connect an emulator to appium via ip and port that provide by appium server.
I can detect the emulator element by run 'uiautomatorviewer.bat' from sdk\tools\bin
folder, the problem is the problem in number 3, is how to send a command to the emulator via appium. so the command to control emulator base on data that given by 'uiautomatorviewer.bat'
coding is about trial and error, so we need live interaction, to build source code. every developer has a personal interest in build a script or source code. so..to make easier, as beginner, we need live interaction that shows every error in every step our script or to make sure that every line of our script that we type is run smoothly in the android device or emulator.
The problem in learn appium is all manual already given finished script...without a really-really basic explanation...in my case, how to connect appium to emulator, send a command from python console, and see the script is work or not...
what I mean is... we need the step by step explanation of script...because every beginner developers need a live 'trial and error' experience to understand how it works...
Upvotes: 0
Reputation: 69388
Not sure about appium, but AndroidViewClient/culebra can easily do what you want.
Install it, run culebra
with or without GUI (-G
) and you will be able to automatically generate python tests or plain scripts.
For example, if you run
$ culebra -GuU --scale=0.5 -o chrome.py
while the device is on the home screen and click the Chrome icon to open it, this script will be generated
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright (C) 2013-2018 Diego Torres Milano
Created on 2018-04-04 by Culebra v15.1.2
__ __ __ __
/ \ / \ / \ / \
____________________/ __\/ __\/ __\/ __\_____________________________
___________________/ /__/ /__/ /__/ /________________________________
| / \ / \ / \ / \ \___
|/ \_/ \_/ \_/ \ o \
\_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
"""
import re
import sys
import os
import unittest
from com.dtmilano.android.viewclient import ViewClient, CulebraTestCase
TAG = 'CULEBRA'
class CulebraTests(CulebraTestCase):
@classmethod
def setUpClass(cls):
cls.kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
cls.kwargs2 = {'forceviewserveruse': False, 'useuiautomatorhelper': False, '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': 0.5, 'find-views-with-content-description': True, 'window': -1, 'orientation-locked': None, 'concertina-config': 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': True, 'find-views-with-text': True, 'prepend-to-sys-path': False, 'install-apk': None, 'drop-shadow': False, 'output': 'chrome.py', '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.dump(window=-1)
self.vc.findViewWithContentDescriptionOrRaise(u'''Chrome''').touch()
self.vc.sleep(_s)
self.vc.dump(window=-1)
if __name__ == '__main__':
CulebraTests.main()
then you can run it as
$ ./chrome.py
to achieve the same at any time
Upvotes: 1