Commit a640e09b authored by libin's avatar libin
Browse files

uitest

parent cf29053d
/.svn/
/.idea/
/src/testcase_for_test/
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Smart_workspace</name>
<comment></comment>
<projects>
<project>.settings</project>
<project>PythonTester</project>
<project>tester</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Smart_workspace</name>
<comment></comment>
<projects>
<project>.settings</project>
<project>PythonTester</project>
<project>tester</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/Smart_workspace/src</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/Smart_workspace/src</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
eclipse.preferences.version=1
encoding//src/common/com_module.py=utf-8
encoding//src/common/keyboard_util.py=utf-8
encoding//src/common/mouse_util.py=utf-8
encoding//src/common/ssh_client.py=utf-8
encoding//src/datalib/data.py=utf-8
encoding//src/elementlib/administrator.py=utf-8
encoding//src/elementlib/companyadmin.py=utf-8
encoding//src/elementlib/touchdata.py=utf-8
encoding//src/elementlib/ttbb.py=utf-8
encoding//src/elementlib/user_login.py=utf-8
encoding//src/elementlib/xtpz_home_page.py=utf-8
encoding//src/elementlib/xtpz_xtsz.py=utf-8
encoding//src/elementlib/ydgl.py=utf-8
encoding//src/module/Login_Swp.py=utf-8
encoding//src/module/deal_db_data.py=utf-8
encoding//src/module/edit_build.py=utf-8
encoding//src/module/edit_yuanqu.py=utf-8
encoding//src/module/login_swp.py=utf-8
encoding//src/module/sendemail.py=utf-8
encoding//src/module/upload_file.py=utf-8
encoding//src/testcase_touch/001login.py=utf-8
encoding//src/testcase_touch/002login_auto_quit.py=utf-8
encoding//src/testcase_touch/005choose_qy.py=utf-8
encoding//src/testcases/testcase001.py=utf-8
encoding//src/testcases/testcase001_superadministrator_login.py=utf-8
encoding//src/testcases/testcase002.py=utf-8
encoding//src/testcases/testcase002_superadministrator_navigation_menu.py=utf-8
encoding//src/testcases/testcase003.py=utf-8
encoding//src/testcases/testcase003_superadministrator_createcompany.py=utf-8
encoding//src/testcases/testcase004.py=utf-8
encoding//src/testcases/testcase004_superadministrator_editcompany.py=utf-8
encoding//src/testcases/testcase005.py=utf-8
encoding//src/testcases/testcase005_superadministrator_deletecompany.py=utf-8
encoding//src/testcases/testcase006_superadministrator_change_password.py=utf-8
encoding//src/testcases/testcase008_Flip.py=utf-8
encoding//src/testcases/testcase008_page_turning.py=utf-8
encoding//src/testcases/testcase009_companyadmin_login.py=utf-8
encoding//src/testcases/testcase010_companyadmin_listclick.py=utf-8
encoding//src/testcases/testcase011_companyadmin_create_park.py=utf-8
encoding//src/testcases/testcase012_companyadmin_creat_build.py=utf-8
encoding//src/testcases/testcase014_companyadmin_createarea.py=utf-8
encoding//src/testcases/testcase015_companyadmin_create_department.py=utf-8
encoding//src/testcases/testcase016_companyadmin_careteuser.py=utf-8
encoding//src/testcases/testcase016_companyadmin_create_user.py=utf-8
encoding//src/testcases/testcase017_companyadmin_create_role.py=utf-8
encoding//src/testcases/testcase017_companyadmin_rolemanger.py=utf-8
encoding//src/testcases/testcase018_companyadmin_retedate.py=utf-8
encoding//src/testcases/testcase020_companyadmin_uploading_station_map.py=utf-8
encoding//src/testcases/testcase021_companyadmin_stationinfo.py=utf-8
encoding//src/testcases/testcase025_companyadmin_search_park.py=utf-8
encoding//src/testcases/testcase026_companyadmin_edit_build.py=utf-8
encoding//src/testcases/testcase029_companyadmin_edit_department.py=utf-8
encoding//src/testcases/testcase030_companyadmin_search_department.py=utf-8
encoding//src/testcases/testcase031_companyadmin_delete_department.py=utf-8
encoding//src/testcases/testcase032_companyadmin_edit_user.py=utf-8
encoding//src/testcases/testcase033_companyadmin_search_user.py=utf-8
encoding//src/testcases/testcase034_companyadmin_delete_user.py=utf-8
encoding//src/testcases/testcase035_companyadmin_edit_role.py=utf-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
encoding//src/common/com_module.py=utf-8
encoding//src/common/keyboard_util.py=utf-8
encoding//src/common/mouse_util.py=utf-8
encoding//src/common/ssh_client.py=utf-8
encoding//src/datalib/data.py=utf-8
encoding//src/elementlib/administrator.py=utf-8
encoding//src/elementlib/companyadmin.py=utf-8
encoding//src/elementlib/touchdata.py=utf-8
encoding//src/elementlib/ttbb.py=utf-8
encoding//src/elementlib/user_login.py=utf-8
encoding//src/elementlib/xtpz_home_page.py=utf-8
encoding//src/elementlib/xtpz_xtsz.py=utf-8
encoding//src/elementlib/ydgl.py=utf-8
encoding//src/module/Login_Swp.py=utf-8
encoding//src/module/deal_db_data.py=utf-8
encoding//src/module/edit_build.py=utf-8
encoding//src/module/edit_yuanqu.py=utf-8
encoding//src/module/login_swp.py=utf-8
encoding//src/module/sendemail.py=utf-8
encoding//src/module/upload_file.py=utf-8
encoding//src/testcase_touch/001login.py=utf-8
encoding//src/testcase_touch/002login_auto_quit.py=utf-8
encoding//src/testcase_touch/005choose_qy.py=utf-8
encoding//src/testcases/testcase001.py=utf-8
encoding//src/testcases/testcase001_superadministrator_login.py=utf-8
encoding//src/testcases/testcase002.py=utf-8
encoding//src/testcases/testcase002_superadministrator_navigation_menu.py=utf-8
encoding//src/testcases/testcase003.py=utf-8
encoding//src/testcases/testcase003_superadministrator_createcompany.py=utf-8
encoding//src/testcases/testcase004.py=utf-8
encoding//src/testcases/testcase004_superadministrator_editcompany.py=utf-8
encoding//src/testcases/testcase005.py=utf-8
encoding//src/testcases/testcase005_superadministrator_deletecompany.py=utf-8
encoding//src/testcases/testcase006_superadministrator_change_password.py=utf-8
encoding//src/testcases/testcase008_Flip.py=utf-8
encoding//src/testcases/testcase008_page_turning.py=utf-8
encoding//src/testcases/testcase009_companyadmin_login.py=utf-8
encoding//src/testcases/testcase010_companyadmin_listclick.py=utf-8
encoding//src/testcases/testcase011_companyadmin_create_park.py=utf-8
encoding//src/testcases/testcase012_companyadmin_creat_build.py=utf-8
encoding//src/testcases/testcase014_companyadmin_createarea.py=utf-8
encoding//src/testcases/testcase015_companyadmin_create_department.py=utf-8
encoding//src/testcases/testcase016_companyadmin_careteuser.py=utf-8
encoding//src/testcases/testcase016_companyadmin_create_user.py=utf-8
encoding//src/testcases/testcase017_companyadmin_create_role.py=utf-8
encoding//src/testcases/testcase017_companyadmin_rolemanger.py=utf-8
encoding//src/testcases/testcase018_companyadmin_retedate.py=utf-8
encoding//src/testcases/testcase020_companyadmin_uploading_station_map.py=utf-8
encoding//src/testcases/testcase021_companyadmin_stationinfo.py=utf-8
encoding//src/testcases/testcase025_companyadmin_search_park.py=utf-8
encoding//src/testcases/testcase026_companyadmin_edit_build.py=utf-8
encoding//src/testcases/testcase029_companyadmin_edit_department.py=utf-8
encoding//src/testcases/testcase030_companyadmin_search_department.py=utf-8
encoding//src/testcases/testcase031_companyadmin_delete_department.py=utf-8
encoding//src/testcases/testcase032_companyadmin_edit_user.py=utf-8
encoding//src/testcases/testcase033_companyadmin_search_user.py=utf-8
encoding//src/testcases/testcase034_companyadmin_delete_user.py=utf-8
encoding//src/testcases/testcase035_companyadmin_edit_role.py=utf-8
encoding/<project>=UTF-8
# -*- coding:utf-8 -*-
import os
import time
import platform
import js2py
debug_log_FLAGE = 0
def throw_error(msg="raise error"):
raise Exception(msg)
def debug_log(msg):
current_day = str(time.strftime('%Y%m%d', time.localtime(time.time())))
log_dir = "./log/"
log_file_name = ''.join([current_day, ".log"])
log_file_path = ''.join([log_dir, log_file_name])
if 0 != debug_log_FLAGE:
if False == os.path.exists(log_dir[:-1]):
os.makedirs(log_dir)
f = open(log_file_path, 'w+')
f.write(msg)
def is_windows_platform():
return platform.system() == "Windows"
'''
添加执行js的函数
'''
def execute_js(js_code, *args):
if len(args) == 0:
return js2py.eval_js(js_code)
else:
fun = js2py.eval_js(js_code)
return fun(*args)
if __name__ == '__main__':
# print(is_windows_platform())
js_code = '''
function f(a, b) {
return a + b;
}
'''
print(execute_js(js_code, 1, 2))
# -*- coding:utf-8 -*-
import os
import time
import platform
import js2py
debug_log_FLAGE = 0
def throw_error(msg="raise error"):
raise Exception(msg)
def debug_log(msg):
current_day = str(time.strftime('%Y%m%d', time.localtime(time.time())))
log_dir = "./log/"
log_file_name = ''.join([current_day, ".log"])
log_file_path = ''.join([log_dir, log_file_name])
if 0 != debug_log_FLAGE:
if False == os.path.exists(log_dir[:-1]):
os.makedirs(log_dir)
f = open(log_file_path, 'w+')
f.write(msg)
def is_windows_platform():
return platform.system() == "Windows"
'''
添加执行js的函数
'''
def execute_js(js_code, *args):
if len(args) == 0:
return js2py.eval_js(js_code)
else:
fun = js2py.eval_js(js_code)
return fun(*args)
if __name__ == '__main__':
# print(is_windows_platform())
js_code = '''
function f(a, b) {
return a + b;
}
'''
print(execute_js(js_code, 1, 2))
# -*- coding:utf-8 -*-
from pykeyboard import PyKeyboard
class KeyBoardUtil():
def send_keys(self, input_msg):
k = PyKeyboard()
'''windows上使用组合件,出现异常,所以把多个输入分开执行'''
if isinstance(input_msg,tuple):
for key in input_msg:
if key == 'shift':
k.press_key(k.shift_key)
else:
k.press_key(key)
for key in input_msg:
if key == 'shift':
k.release_key(k.shift_key)
else:
k.release_key(key)
else:
for i in input_msg:
k.press_key(i)
k.release_key(k.shift_key)
if __name__ == '__main__':
a = KeyBoardUtil()
a.send_keys(('shift', 'h'))
a.send_keys('\n')
a.send_keys('a')
# a.send_keys('\r')
# a.send_keys('b')
# a.send_keys('\r\n')
# a.send_keys('c')
# a.send_keys(('shift', '-'))
# a.send_keys('2')
# a.send_keys('\n')
# a.send_keys(('shift', 'o'))
# a.send_keys('1000')
# -*- coding:utf-8 -*-
from pykeyboard import PyKeyboard
class KeyBoardUtil():
def send_keys(self, input_msg):
k = PyKeyboard()
'''windows上使用组合件,出现异常,所以把多个输入分开执行'''
if isinstance(input_msg,tuple):
for key in input_msg:
if key == 'shift':
k.press_key(k.shift_key)
else:
k.press_key(key)
for key in input_msg:
if key == 'shift':
k.release_key(k.shift_key)
else:
k.release_key(key)
else:
for i in input_msg:
k.press_key(i)
k.release_key(k.shift_key)
if __name__ == '__main__':
a = KeyBoardUtil()
a.send_keys(('shift', 'h'))
a.send_keys('\n')
a.send_keys('a')
# a.send_keys('\r')
# a.send_keys('b')
# a.send_keys('\r\n')
# a.send_keys('c')
# a.send_keys(('shift', '-'))
# a.send_keys('2')
# a.send_keys('\n')
# a.send_keys(('shift', 'o'))
# a.send_keys('1000')
#-*- coding:utf-8 -*-
from pymouse import PyMouse
class MouseClient():
def __init__(self):
self.mouse_object = PyMouse()
def get_current_position(self):
cur_position = self.mouse_object.position()
print (cur_position)
return cur_position
def move_mouse(self, position_x, position_y):
self.mouse_object.move(position_x, position_y)
def click_mouse(self, position_x, position_y):
self.mouse_object.click(position_x, position_y)
self.mouse_object.release(position_x, position_y)
if __name__ == '__main__':
import time
time.sleep(5)
a = MouseClient()
a.get_current_position()
print ("game over")
#-*- coding:utf-8 -*-
from pymouse import PyMouse
class MouseClient():
def __init__(self):
self.mouse_object = PyMouse()
def get_current_position(self):
cur_position = self.mouse_object.position()
print (cur_position)
return cur_position
def move_mouse(self, position_x, position_y):
self.mouse_object.move(position_x, position_y)
def click_mouse(self, position_x, position_y):
self.mouse_object.click(position_x, position_y)
self.mouse_object.release(position_x, position_y)
if __name__ == '__main__':
import time
time.sleep(5)
a = MouseClient()
a.get_current_position()
print ("game over")
#-*-coding:utf-8-*-
import pymysql
from src.datalib import test_data
class MySQLClient():
def __init__(self,host,port,username,passwd,db,charset="utf8"):
self.host = host
self.port = port
self.username = username
self.passwd = passwd
self.db = db
self.charset = charset
def connectdb(self):
self.conn = pymysql.connect(host=self.host,port=self.port,user=self.username,passwd=self.passwd,\
db=self.db,charset=self.charset)
self.cursor = self.conn.cursor()
def executeSQL(self, sql):
self.cursor.execute(sql)
self.result = self.cursor.fetchall()
def execute_param_SQL(self, sql, param):
self.cursor.execute(sql,param)
def commitSQL(self):
self.cursor.close()
self.conn.commit()
def close_connect(self):
self.conn.close()
if __name__ == '__main__':
a = MySQLClient('192.168.203.20',20001,'wafer','wafer','reservestation')
a.connectdb()
a.executeSQL("select count(*) from `park` where domainID = '135' and parkName like 'autotest%';")
a.commitSQL()
for row in a.result:
print (row)
a.close_connect()
#-*-coding:utf-8-*-
import pymysql
from src.datalib import test_data
class MySQLClient():
def __init__(self,host,port,username,passwd,db,charset="utf8"):
self.host = host
self.port = port
self.username = username
self.passwd = passwd
self.db = db
self.charset = charset
def connectdb(self):
self.conn = pymysql.connect(host=self.host,port=self.port,user=self.username,passwd=self.passwd,\
db=self.db,charset=self.charset)
self.cursor = self.conn.cursor()
def executeSQL(self, sql):
self.cursor.execute(sql)
self.result = self.cursor.fetchall()
def execute_param_SQL(self, sql, param):
self.cursor.execute(sql,param)
def commitSQL(self):
self.cursor.close()
self.conn.commit()
def close_connect(self):
self.conn.close()
if __name__ == '__main__':
a = MySQLClient('192.168.203.20',20001,'wafer','wafer','reservestation')
a.connectdb()
a.executeSQL("select count(*) from `park` where domainID = '135' and parkName like 'autotest%';")
a.commitSQL()
for row in a.result:
print (row)
a.close_connect()
#-*- coding: utf-8 -*-
import paramiko
class SSH_Client():
def __init__(self, IP, username, passwd, port=22):
self.IP = IP
self.port = port
self.username = username
self.passwd = passwd
self.timeout = 5
def connect_server(self):
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.ssh.connect(self.IP, self.port , self.username, self.passwd,\
timeout=self.timeout)
def exce_command(self, cmdlist):
for i in cmd:
stdin, stdout, stderr = self.ssh.exce_command(i)
out = stdout.readlines()
for j in out:
print (j[:-1])
def close_ssh(self):
self.ssh.close()
if __name__=='__main__':
cmd = ['ls']
username = "waferxa"
passwd = "wafer.com"
ip = '192.168.0.77'
a = SSH_Client(ip, username, passwd)
a.connect_server()
a.exce_command(cmd)
a.close_ssh()
#-*- coding: utf-8 -*-
import paramiko
class SSH_Client():
def __init__(self, IP, username, passwd, port=22):
self.IP = IP
self.port = port
self.username = username
self.passwd = passwd
self.timeout = 5
def connect_server(self):
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.ssh.connect(self.IP, self.port , self.username, self.passwd,\
timeout=self.timeout)
def exce_command(self, cmdlist):
for i in cmd:
stdin, stdout, stderr = self.ssh.exce_command(i)
out = stdout.readlines()
for j in out:
print (j[:-1])
def close_ssh(self):