# –– 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)