python+appium+unittest

# –– conding=utf-8 –

import traceback

import unittest

import time

from telnetlib import EC

from appium.webdriver.common.touch_action import TouchAction

from selenium.webdriver.common.by import By

from selenium.webdriver.support.wait import WebDriverWait

from app.config.Drivertest import DriverTest

class testOne(unittest.TestCase):

global driver

def __init__(self,methodName=‘runTest’):

super(testOne,self).__init__(methodName)

@classmethod

def setUpClass(cls):

driver=cls.driver=DriverTest().get_driver()

@classmethod

def tearDownClass(cls):

cls.driver.quit()

def atestone(self):

try:

# self.driver.find_element_by_android_uiautomator(‘new UiSelector().text(“我的”)’).click()

# time.sleep(1)

# self.driver.find_element_by_id(‘com.youdao.note:id/user_info’).click()

# time.sleep(5)

self.driver.find_element_by_android_uiautomator(‘new UiSelector().text(“网易邮箱登录”)’).click()

time.sleep(3)

username =****

self.driver.find_element_by_xpath(‘//*[@resource-id=“com.youdao.note:id/account”]/android.widget.EditText’).send_keys(username)

time.sleep(2)

self.driver.press_keycode(20)

password=self.driver.find_element_by_xpath(‘//*[@resource-id=“com.youdao.note:id/password”]/android.widget.EditText’)

password.click()

time.sleep(1)

password.send_keys(‘’)

time.sleep(2)

self.driver.find_element_by_id(‘com.youdao.note:id/login’).click()

time.sleep(2)

self.driver.find_element_by_android_uiautomator(‘new UiSelector().text(“我的”)’).click()

time.sleep(1)

extualusern=self.driver.find_element_by_id(‘com.youdao.note:id/user_name’).text

print(extualusern)

self.assertIn(extualusern,username)

time.sleep(10)

except Exception as e:

raise e

def btestTwo(self):

xpath1=‘//*[@resource-id=“com.youdao.note:id/refresh_layout”]//android.widget.RelativeLayout[1]’

self.driver.find_element_by_xpath(xpath1).click()

time.sleep(1)

self.driver.find_element_by_id(‘com.youdao.note:id/edit’).click()

time.sleep(5)

self.driver.find_element_by_id(‘com.youdao.note:id/insert_image’).click()

time.sleep(2)

self.driver.find_element_by_id(‘com.youdao.note:id/from_gallery’).click()

time.sleep(3)

xpath2=‘//android.widget.GridView//android.widget.ImageView’

eles=self.driver.find_elements_by_xpath(xpath2)

print(len(eles))

n=len(eles) if len(eles)<9 else 9

print(n)

time.sleep(2)

for i in range(1,n):

self.driver.find_element_by_xpath(‘//*[@resource-id=“com.youdao.note:id/image_layout”]//android.widget.RelativeLayout[%d]’% i).click()

time.sleep(1)

self.driver.find_element_by_id(‘com.youdao.note:id/complete’).click()

time.sleep(10)

#WebDriverWait(self.driver,10).until(EC.presense_of_element_locate(By.ID,‘com.youdao.note:id/actionbar_complete_text’))

self.driver.find_element_by_id(‘com.youdao.note:id/actionbar_complete_text’).click()

time.sleep(10)

def testThree(self):

self.driver.find_element_by_id(‘com.qingsong.drawing:id/ec’).click()

time.sleep(1)

self.driver.find_element_by_id(‘com.qingsong.drawing:id/fm’).click()

time.sleep(2)

self.driver.find_element_by_id(‘com.qingsong.drawing:id/fm’).click()

time.sleep(2)

width=self.driver.get_window_size()[‘width’]

height=self.driver.get_window_size()[‘height’]

x1=int(width*0.5)

y1=int(height*0.3)

x2=int(width*0.7)

l1=(x1,y1,x2,y1)

self.driver.swipe(x1,y1,x2,y1,1000)

# action=TouchAction(self.driver)

# action.press(x1,y1).move_to(x1,y2)

ll=self.driver.find_element_by_id(‘com.qingsong.drawing:id/fm’).rect

l2=(ll[‘x’],ll[‘y’],ll[‘height’]+ll[‘x’],ll[‘width’]+ll[‘y’])

print(l1,l2)

self.assertEqual(l1,l2)

time.sleep(10)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值