android 如何边界界面,如何使用appium对Android用户界面python脚本中的垂直边界/坐标进行点击/点击操作...

在MAC-appium和MAC-appium中,只有在MAC-appium中使用Xpath,才能在MAC-appium中使用。

代码如下:#-*- coding: utf-8 -*-

__author__ = 'chetan.krishna'

import os

import time

import unittest

from time import sleep

from appium import webdriver

from pylab import *

from teamcity import is_running_under_teamcity

from teamcity.unittestpy import TeamcityTestRunner

import logging

# Returns absolute path relative to this file

PATH = lambda p: os.path.abspath(

os.path.join(os.path.dirname(__file__), p)

)

class AvavntiAndroidTests(unittest.TestCase):

def setUp(self):

desired_caps = {}

# Specify platform below(Android, iOS)

desired_caps['platformName'] = 'Android'

# Specify OS version(Settings->About phone -> android version)

desired_caps['platformVersion'] = '4.4.4'

# Obtain the Device name from Adb[For Android](Terminal Command: "adb devices")

desired_caps['deviceName'] = '4d0081004c8741a9'

desired_caps['noReset'] = False

# Specify the path to Application

desired_caps["app"] = PATH('AvantiMarket_v1.4.apk')

# Wait for email login activity to appear

desired_caps["appWaitActivity"]= ('com.android.avantimarket.ui.activity.EmailLoginActivity')

self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

def tearDown(self):

# end the session

self.driver.quit()

def test_Avanti(self):

# wait for the login screen to appear

self.driver.implicitly_wait(20)

# set values for plotting pass and fail results

nPass = 0

nFail = 0

print('Checking login for registered user')

# Logging in as indiaone@avantilab.org

elf.driver.implicitly_wait('20')

print('Trying to login with abc@abc.org')

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIATextField[1]').send_keys('abc@abc.org.org')

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIASecureTextField[1]').send_keys('12345678')

self.driver.hide_keyboard()

self.driver.implicitly_wait(10)

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIAButton[3]').click()

time.sleep(20)

self.driver.implicitly_wait(99)

try:

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIASecureTextField[1]')

except :

print('Login failed, please check credentials and network')

else:

print('Login successful, creating pin')

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIASecureTextField[1]').send_keys('1')

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIASecureTextField[2]').send_keys('1')

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIASecureTextField[3]').send_keys('1')

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIASecureTextField[4]').send_keys('1')

self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[2]/UIASecureTextField[5]').send_keys('1')

self.driver.find_element_by_id('com.android.avantimarket:id/m_emailTextField').send_keys('abc@abc.org.org')

self.driver.back()

nPass= nPass+1

self.driver.implicitly_wait(20)

self.driver.find_element_by_id('com.android.avantimarket:id/m_passwordTextField').send_keys('12345678')

nPass= nPass+1

self.driver.back()

self.driver.implicitly_wait(10)

self.driver.find_element_by_name('SIGN IN').click()

self.driver.implicitly_wait(30)

time.sleep(5)

# validating for successful login

try:

self.driver.find_element_by_id('com.android.avantimarket:id/create_pin_fields_container')

print('Login successful')

nPass= nPass+1

except:

print('Login failed')

nFail = nFail + 1

else:

# Creating pin required for login

print('Creating Pin for user')

self.driver.find_element_by_id('com.android.avantimarket:id/create_pin_fields_container').send_keys('1111')

self.driver.find_element_by_id('com.android.avantimarket:id/reEnter_pin_fields_container').send_keys('1111')

self.driver.back()

self.driver.implicitly_wait(20)

self.driver.find_element_by_id('com.android.avantimarket:id/m_saveButton').click()

self.driver.implicitly_wait(10)

self.driver.find_element_by_id('com.android.avantimarket:id/btn_cominsoon_Yes').click()

self.driver.implicitly_wait(10)

time.sleep(8)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# -*- coding: UTF-8 -*- from lib2to3.pgen2 import driver from appium import webdriver from appium.webdriver.common.appiumby import AppiumBy el1 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="通讯录") el1.click() el2 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[1]/android.widget.FrameLayout/android.widget.ListView/android.widget.FrameLayout[3]/android.widget.RelativeLayout") el2.click() el3 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[1]/android.widget.TextView") el3.click() el4 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[8]") el4.click() el5 = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout[2]/android.view.ViewGroup/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.view.ViewGroup[11]") el5.click()
最新发布
06-08

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值