栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python+appium+unittest

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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)

暑期编程PK赛 得CSDN机械键盘等精美礼品!
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1016056.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号