0

I am not able run below script on my android device. Can you please help with this because I am new to automation & python.

import os, time, re
import unittest
from appium import webdriver

class ContactAppTest(unittest.TestCase):
    def setUp(self):
        desired_caps = {}
        desired_caps['deviceName'] = 'CID6CUQWW47DM7BI'
        desired_caps['platformName'] = 'Android'
        desired_caps['appPackage'] = 'com.android.contacts'
        desired_caps['appActivity'] = '.activities.PeopleActivity'
        self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps)

    def ContactAppTestAppium(self):
        self.driver.find_element_by_xpath("//android.view.ViewGroup[@content-desc=\"Home screen 1\"]/android.widget.TextView[3]").click()
        self.driver.find_element_by_id("com.android.contacts:id/menu_add_contact").click()
        self.driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout[2]/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.LinearLayout[2]/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.EditText").click().send_keys("umesh123")
        self.driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout[2]/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.EditText").click().send_keys("7987654354")
        self.driver.find_element_by_id("com.android.contacts:id/save_menu_item").click()

    def tearDown(self):
        self.driver.quit()
BlueSheepToken
  • 5,751
  • 3
  • 17
  • 42
Umesh
  • 1
  • Hello @Umesh, please explain the problem: wrong result, execution errors, ... – Bertrand Gazanion Jun 06 '19 at 12:38
  • May I ask what exactly are you trying to do (I'm talking about the big picture)? I'm not familiar enough with android (I have some familiarity), and I have no idea how python is related to android development... – noamgot Jun 06 '19 at 12:38
  • Hi @ Bertrand Gazanion, My script is running properly without no error in the editor the only issue, it is not working on android device. So I am also not getting exactly issue – Umesh Jun 07 '19 at 05:26
  • Hello @ noamgot, I am testing android apps on the device through python script & appium. Here I am trying to test "add contacts" feature on device. – Umesh Jun 07 '19 at 05:29

1 Answers1

1

You should use the android debug bridge, adb, in order to perform some kind of automation using python.

With adb you'll be able to use some command in order to perform actions on your device.

For example you could do a python script who perform a swipe on your device.

Use this for you inputs : ADB Shell Input Events You should also watch UiAutomator and Monkey, this is very helpful for automation on android.

HLupo
  • 317
  • 3
  • 12